SlideShare une entreprise Scribd logo
1  sur  40
Télécharger pour lire hors ligne
Parse
Parse Data     Parse Push




Parse Social   Cloud Code
iOS          OS X      Android   Javascript




Windows Phone   Windows 8    .NET     Rest API
Parse Data
criando uma nova classe
criando uma nova classe
criando uma nova classe
criando um novo objeto

ParseObject profile = new ParseObject("Profile");
profile.put("age", 45);
profile.put("name", "John Doe");
profile.saveInBackground();
objetos com relacionamento

// Cria um post
ParseObject myPost = new ParseObject("Post");
myPost.put("title", "Estou com fome!");
myPost.put("content", "Vamos almoçar aonde?");
 
// Cria um comentário
ParseObject myComment = new ParseObject("Comment");
myComment.put("content", "Vamos no Estação.");

myComment.put("parent", myPost);
myComment.saveInBackground();
buscando objetos

ParseQuery query = new ParseQuery("Profile");
query.whereEqualTo("age", 45);
query.findInBackground(new FindCallback() {
    public void done(List<ParseObject> profileList, ParseException e) {
       if (e == null) {
          Log.d("profile", "Retrieved " + profileList.size() + " profiles");
       } else {
          Log.d("profile", "Error: " + e.getMessage());
       }
    }
});




int age = profile.getInt("age");
String name = profile.getString("name");
outras funções úteis

ParseObject profile = new ParseObject("Profile");
profile.put("age", 27);
profile.put("name", "Mary Moe");
                                                                      er!
profile.saveEventually();                                        o pud
                                                            quand
                                                    Salve



profile.increment("age");
profile.saveInBackground();




profile.deleteInBackground();




profile.remove("name");
profile.saveInBackground();
api requests
Parse Push
interface código
        ou
via interface
adicionando a um canal de envio

// Salva a instalação no Parse.
ParseInstallation.getCurrentInstallation().saveInBackground();




// Adiciona o usuário no canal “Giants”.
PushService.subscribe(context, "Giants", YourActivity.class);
via código

ParsePush push = new ParsePush();
push.setChannel("Giants");
push.setMessage("Touchdown para os Giants! O time vira contra os Mets.");
push.sendInBackground();
pushs enviados
Parse Social
SSO   vs   Link
facebook connect

ParseFacebookUtils.initialize("ID DA APP DO FACEBOOK");




@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  ParseFacebookUtils.finishAuthentication(requestCode, resultCode, data);
}
ParseFacebookUtils.logIn(this, new LogInCallback() {
  @Override
  public void done(ParseUser user, ParseException err) {
    if (user == null) {
      Log.d("MeuApp", "Ops. O usuário cancelou o login do Facebook.");
    } else if (user.isNew()) {
      Log.d("MeuApp", "Usuário criado e logado via Facebook!");
    } else {
      Log.d("MeuApp", "Usuário logado via Facebook!");
    }
  }
});                                                                        SSO


if (!ParseFacebookUtils.isLinked(user)) {
  ParseFacebookUtils.link(user, this, new SaveCallback() {
    @Override
    public void done(ParseException ex) {
      if (ParseFacebookUtils.isLinked(user)) {
        Log.d("MeuApp", "Boa! Usuário conectou sua conta do Facebook!");
      }
    }
  });
}                                                                          LINK
twitter connect

ParseTwitterUtils.initialize("CONSUMER KEY", "CONSUMER SECRET");
ParseTwitterUtils.logIn(this, new LogInCallback() {
  @Override
  public void done(ParseUser user, ParseException err) {
    if (user == null) {
      Log.d("MeuApp", "Ops. O usuário cancelou o login do Twitter.");
    } else if (user.isNew()) {
      Log.d("MeuApp", "Usuário criado e logado via Twitter!");
    } else {
      Log.d("MeuApp", "Usuário logado via Twitter!");
    }
  }
});                                                                       SSO



if (!ParseTwitterUtils.isLinked(user)) {
  ParseTwitterUtils.link(user, this, new SaveCallback() {
    @Override
    public void done(ParseException ex) {
      if (ParseTwitterUtils.isLinked(user)) {
        Log.d("MeuApp", "Boa! Usuário conectou sua conta do Twitter!");
      }
    }
  });
}                                                                         LINK
Cloud Code
command line tool

$ curl -s https://www.parse.com/downloads/cloud_code/installer.sh | sudo /bin/bash




$ parse new LightningTalkCloudCode
Email: gustavocsb@gmail.com
Password:
1:Foliao
2:Lightning Talk
Select an App: 2
$ cd LightningTalkCloudCode
cloud/main.js

Parse.Cloud.define("hello", function(request, response) {
  response.success("Hello world!");
});
deploy

$ parse deploy

New release is named v1




$ curl -X POST 
  -H "X-Parse-Application-Id: <INSERIR PARSE APP ID>" 
  -H "X-Parse-REST-API-Key: <INSERIR PARSE REST API KEY>" 
  -H "Content-Type: application/json" 
  -d '{}' 
  https://api.parse.com/1/functions/hello

{
  "result": "Hello world!"
}
cloud functions

Parse.Cloud.define("averageStars", function(request, response) {
  var query = new Parse.Query("Review");
  query.equalTo("movie", request.params.movie);
  query.find({
    success: function(results) {
      var sum = 0;
      for (var i = 0; i < results.length; ++i) {
        sum += results[i].get("stars");
      }
      response.success(sum / results.length);
    },
    error: function() {
      response.error("movie lookup failed");
    }
  });
});
cloud functions - validations

Parse.Cloud.beforeSave("Review", function(request, response) {
  if (request.object.get("stars") < 1) {
    response.error("you cannot give less than one star");
  } else if (request.object.get("stars") > 5) {
    response.error("you cannot give more than five stars");
  } else {
    response.success();
  }
});
logging

Parse.Cloud.define("Logger", function(request, response) {
  console.log(request.params);
  response.success();
});
networking

Parse.Cloud.httpRequest({
  method: 'GET’,
  url: 'http://www.parse.com/',
  success: function(httpResponse) {
    console.log(httpResponse.text);
  },
  error: function(httpResponse) {
    console.error('Request failed with response code ' + httpResponse.status);
  }
});
cloud modules
obrigado,
Gustavo Barbosa

  gustavo.barbosa@quatix.com.br

  facebook.com/gustavocsb

  twitter.com/gustavocsb

  github.com/barbosa

Contenu connexe

Tendances

Aller plus loin avec Doctrine2
Aller plus loin avec Doctrine2Aller plus loin avec Doctrine2
Aller plus loin avec Doctrine2André Tapia
 
Tugas pemrograman jaringan
Tugas pemrograman jaringanTugas pemrograman jaringan
Tugas pemrograman jaringanBanser Sahara
 
ECMA2015 INSIDE
ECMA2015 INSIDEECMA2015 INSIDE
ECMA2015 INSIDEJun Ho Lee
 
jQuery sans jQuery
jQuery sans jQueryjQuery sans jQuery
jQuery sans jQuerygoldoraf
 
Device Orientation & WebSocket API
Device Orientation & WebSocket APIDevice Orientation & WebSocket API
Device Orientation & WebSocket APIComparto Web
 
How to stop writing spaghetti code - JSConf.eu 2010
How to stop writing spaghetti code - JSConf.eu 2010How to stop writing spaghetti code - JSConf.eu 2010
How to stop writing spaghetti code - JSConf.eu 2010Tom Croucher
 
Assalamualaykum warahmatullahi wabarakatuu
Assalamualaykum warahmatullahi wabarakatuuAssalamualaykum warahmatullahi wabarakatuu
Assalamualaykum warahmatullahi wabarakatuuiswan_di
 
aggregation and indexing with suitable example using MongoDB.
aggregation and indexing with suitable example using MongoDB.aggregation and indexing with suitable example using MongoDB.
aggregation and indexing with suitable example using MongoDB.bhavesh lande
 
Node.js Scalability Tips
Node.js Scalability TipsNode.js Scalability Tips
Node.js Scalability TipsLuciano Mammino
 
Praktik Pengembangan Konten HTML5 untuk E-Learning (Extended)
Praktik Pengembangan Konten HTML5 untuk E-Learning (Extended)Praktik Pengembangan Konten HTML5 untuk E-Learning (Extended)
Praktik Pengembangan Konten HTML5 untuk E-Learning (Extended)Muhammad Yusuf
 
RxJava, Getting Started - David Wursteisen - 16 Octobre 2014
RxJava, Getting Started - David Wursteisen - 16 Octobre 2014RxJava, Getting Started - David Wursteisen - 16 Octobre 2014
RxJava, Getting Started - David Wursteisen - 16 Octobre 2014SOAT
 
Java script.trend(spec)
Java script.trend(spec)Java script.trend(spec)
Java script.trend(spec)dynamis
 
Hacer una calculadora en Java y en Visual Basic
Hacer una calculadora en Java y en Visual BasicHacer una calculadora en Java y en Visual Basic
Hacer una calculadora en Java y en Visual BasicHumbertoWuwu
 

Tendances (19)

Discover ServiceWorker
Discover ServiceWorkerDiscover ServiceWorker
Discover ServiceWorker
 
Einführung in Meteor
Einführung in MeteorEinführung in Meteor
Einführung in Meteor
 
Aller plus loin avec Doctrine2
Aller plus loin avec Doctrine2Aller plus loin avec Doctrine2
Aller plus loin avec Doctrine2
 
Tugas pemrograman jaringan
Tugas pemrograman jaringanTugas pemrograman jaringan
Tugas pemrograman jaringan
 
ECMA2015 INSIDE
ECMA2015 INSIDEECMA2015 INSIDE
ECMA2015 INSIDE
 
jQuery sans jQuery
jQuery sans jQueryjQuery sans jQuery
jQuery sans jQuery
 
Marresearch
MarresearchMarresearch
Marresearch
 
Aplicacion turbogenerador java
Aplicacion turbogenerador javaAplicacion turbogenerador java
Aplicacion turbogenerador java
 
Device Orientation & WebSocket API
Device Orientation & WebSocket APIDevice Orientation & WebSocket API
Device Orientation & WebSocket API
 
How to stop writing spaghetti code - JSConf.eu 2010
How to stop writing spaghetti code - JSConf.eu 2010How to stop writing spaghetti code - JSConf.eu 2010
How to stop writing spaghetti code - JSConf.eu 2010
 
Assalamualaykum warahmatullahi wabarakatuu
Assalamualaykum warahmatullahi wabarakatuuAssalamualaykum warahmatullahi wabarakatuu
Assalamualaykum warahmatullahi wabarakatuu
 
aggregation and indexing with suitable example using MongoDB.
aggregation and indexing with suitable example using MongoDB.aggregation and indexing with suitable example using MongoDB.
aggregation and indexing with suitable example using MongoDB.
 
Node.js Scalability Tips
Node.js Scalability TipsNode.js Scalability Tips
Node.js Scalability Tips
 
Praktik Pengembangan Konten HTML5 untuk E-Learning (Extended)
Praktik Pengembangan Konten HTML5 untuk E-Learning (Extended)Praktik Pengembangan Konten HTML5 untuk E-Learning (Extended)
Praktik Pengembangan Konten HTML5 untuk E-Learning (Extended)
 
RxJava, Getting Started - David Wursteisen - 16 Octobre 2014
RxJava, Getting Started - David Wursteisen - 16 Octobre 2014RxJava, Getting Started - David Wursteisen - 16 Octobre 2014
RxJava, Getting Started - David Wursteisen - 16 Octobre 2014
 
Java script.trend(spec)
Java script.trend(spec)Java script.trend(spec)
Java script.trend(spec)
 
Hacer una calculadora en Java y en Visual Basic
Hacer una calculadora en Java y en Visual BasicHacer una calculadora en Java y en Visual Basic
Hacer una calculadora en Java y en Visual Basic
 
Testování prakticky
Testování praktickyTestování prakticky
Testování prakticky
 
Socket.io - Intro
Socket.io - IntroSocket.io - Intro
Socket.io - Intro
 

En vedette

En vedette (18)

Seguimiento del power 2.1
Seguimiento del power 2.1Seguimiento del power 2.1
Seguimiento del power 2.1
 
App development company
App development companyApp development company
App development company
 
Derrame pleural
Derrame pleuralDerrame pleural
Derrame pleural
 
Tecnoliga
TecnoligaTecnoliga
Tecnoliga
 
Raman spectrometer: Chemische identificatie voor een veilige omgeving
Raman spectrometer: Chemische identificatie voor een veilige omgevingRaman spectrometer: Chemische identificatie voor een veilige omgeving
Raman spectrometer: Chemische identificatie voor een veilige omgeving
 
Taller word
Taller wordTaller word
Taller word
 
Competencia liderazgo
Competencia liderazgoCompetencia liderazgo
Competencia liderazgo
 
Cadenas Carbonadas
Cadenas CarbonadasCadenas Carbonadas
Cadenas Carbonadas
 
Apresiasi puisi syair
Apresiasi puisi   syairApresiasi puisi   syair
Apresiasi puisi syair
 
Mcte2013 participant
Mcte2013 participantMcte2013 participant
Mcte2013 participant
 
Presentation about China Exhibition Industry
Presentation about China Exhibition IndustryPresentation about China Exhibition Industry
Presentation about China Exhibition Industry
 
2015 Toyota Sequoia | Toyota Dealer Serving Wilkes-Barre
2015 Toyota Sequoia | Toyota Dealer Serving Wilkes-Barre2015 Toyota Sequoia | Toyota Dealer Serving Wilkes-Barre
2015 Toyota Sequoia | Toyota Dealer Serving Wilkes-Barre
 
Geology 2 eso
Geology 2 esoGeology 2 eso
Geology 2 eso
 
Navidad
NavidadNavidad
Navidad
 
Creating a modern brand on a budget
Creating a modern brand on a budgetCreating a modern brand on a budget
Creating a modern brand on a budget
 
Tic´s
Tic´sTic´s
Tic´s
 
Lesson of Love
Lesson of Love   Lesson of Love
Lesson of Love
 
Investor Relations Podcasts Using Buzzsprout
Investor Relations Podcasts Using BuzzsproutInvestor Relations Podcasts Using Buzzsprout
Investor Relations Podcasts Using Buzzsprout
 

Parse

  • 2.
  • 3. Parse Data Parse Push Parse Social Cloud Code
  • 4. iOS OS X Android Javascript Windows Phone Windows 8 .NET Rest API
  • 5.
  • 7.
  • 11. criando um novo objeto ParseObject profile = new ParseObject("Profile"); profile.put("age", 45); profile.put("name", "John Doe"); profile.saveInBackground();
  • 12. objetos com relacionamento // Cria um post ParseObject myPost = new ParseObject("Post"); myPost.put("title", "Estou com fome!"); myPost.put("content", "Vamos almoçar aonde?");   // Cria um comentário ParseObject myComment = new ParseObject("Comment"); myComment.put("content", "Vamos no Estação."); myComment.put("parent", myPost); myComment.saveInBackground();
  • 13. buscando objetos ParseQuery query = new ParseQuery("Profile"); query.whereEqualTo("age", 45); query.findInBackground(new FindCallback() { public void done(List<ParseObject> profileList, ParseException e) { if (e == null) { Log.d("profile", "Retrieved " + profileList.size() + " profiles"); } else { Log.d("profile", "Error: " + e.getMessage()); } } }); int age = profile.getInt("age"); String name = profile.getString("name");
  • 14. outras funções úteis ParseObject profile = new ParseObject("Profile"); profile.put("age", 27); profile.put("name", "Mary Moe"); er! profile.saveEventually(); o pud quand Salve profile.increment("age"); profile.saveInBackground(); profile.deleteInBackground(); profile.remove("name"); profile.saveInBackground();
  • 19. adicionando a um canal de envio // Salva a instalação no Parse. ParseInstallation.getCurrentInstallation().saveInBackground(); // Adiciona o usuário no canal “Giants”. PushService.subscribe(context, "Giants", YourActivity.class);
  • 20.
  • 21. via código ParsePush push = new ParsePush(); push.setChannel("Giants"); push.setMessage("Touchdown para os Giants! O time vira contra os Mets."); push.sendInBackground();
  • 24.
  • 25. SSO vs Link
  • 26. facebook connect ParseFacebookUtils.initialize("ID DA APP DO FACEBOOK"); @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {   super.onActivityResult(requestCode, resultCode, data);   ParseFacebookUtils.finishAuthentication(requestCode, resultCode, data); }
  • 27. ParseFacebookUtils.logIn(this, new LogInCallback() {   @Override   public void done(ParseUser user, ParseException err) {     if (user == null) {       Log.d("MeuApp", "Ops. O usuário cancelou o login do Facebook.");     } else if (user.isNew()) {       Log.d("MeuApp", "Usuário criado e logado via Facebook!");     } else {       Log.d("MeuApp", "Usuário logado via Facebook!");     }   } }); SSO if (!ParseFacebookUtils.isLinked(user)) {   ParseFacebookUtils.link(user, this, new SaveCallback() {     @Override     public void done(ParseException ex) {       if (ParseFacebookUtils.isLinked(user)) {         Log.d("MeuApp", "Boa! Usuário conectou sua conta do Facebook!");       }     }   }); } LINK
  • 29. ParseTwitterUtils.logIn(this, new LogInCallback() {   @Override   public void done(ParseUser user, ParseException err) {     if (user == null) {       Log.d("MeuApp", "Ops. O usuário cancelou o login do Twitter.");     } else if (user.isNew()) {       Log.d("MeuApp", "Usuário criado e logado via Twitter!");     } else {       Log.d("MeuApp", "Usuário logado via Twitter!");     }   } }); SSO if (!ParseTwitterUtils.isLinked(user)) {   ParseTwitterUtils.link(user, this, new SaveCallback() {     @Override     public void done(ParseException ex) {       if (ParseTwitterUtils.isLinked(user)) {         Log.d("MeuApp", "Boa! Usuário conectou sua conta do Twitter!");       }     }   }); } LINK
  • 31.
  • 32. command line tool $ curl -s https://www.parse.com/downloads/cloud_code/installer.sh | sudo /bin/bash $ parse new LightningTalkCloudCode Email: gustavocsb@gmail.com Password: 1:Foliao 2:Lightning Talk Select an App: 2 $ cd LightningTalkCloudCode
  • 33. cloud/main.js Parse.Cloud.define("hello", function(request, response) {   response.success("Hello world!"); });
  • 34. deploy $ parse deploy New release is named v1 $ curl -X POST   -H "X-Parse-Application-Id: <INSERIR PARSE APP ID>"   -H "X-Parse-REST-API-Key: <INSERIR PARSE REST API KEY>"   -H "Content-Type: application/json"   -d '{}'   https://api.parse.com/1/functions/hello {   "result": "Hello world!" }
  • 35. cloud functions Parse.Cloud.define("averageStars", function(request, response) {   var query = new Parse.Query("Review");   query.equalTo("movie", request.params.movie);   query.find({     success: function(results) {       var sum = 0;       for (var i = 0; i < results.length; ++i) {         sum += results[i].get("stars");       }       response.success(sum / results.length);     },     error: function() {       response.error("movie lookup failed");     }   }); });
  • 36. cloud functions - validations Parse.Cloud.beforeSave("Review", function(request, response) {   if (request.object.get("stars") < 1) {     response.error("you cannot give less than one star");   } else if (request.object.get("stars") > 5) {     response.error("you cannot give more than five stars");   } else {     response.success();   } });
  • 37. logging Parse.Cloud.define("Logger", function(request, response) {   console.log(request.params);   response.success(); });
  • 38. networking Parse.Cloud.httpRequest({ method: 'GET’,   url: 'http://www.parse.com/',   success: function(httpResponse) {     console.log(httpResponse.text);   },   error: function(httpResponse) {     console.error('Request failed with response code ' + httpResponse.status);   } });
  • 40. obrigado, Gustavo Barbosa gustavo.barbosa@quatix.com.br facebook.com/gustavocsb twitter.com/gustavocsb github.com/barbosa