ݺߣ

ݺߣShare a Scribd company logo
Parse
Parse
Parse Data     Parse Push




Parse Social   Cloud Code
iOS          OS X      Android   Javascript




Windows Phone   Windows 8    .NET     Rest API
Parse
Parse Data
Parse
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 comentrio
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 cdigo
        ou
via interface
adicionando a um canal de envio

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




// Adiciona o usurio no canal Giants.
PushService.subscribe(context, "Giants", YourActivity.class);
Parse
via cdigo

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
Parse
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 usurio cancelou o login do Facebook.");
????} else if (user.isNew()) {
??????Log.d("MeuApp", "Usurio criado e logado via Facebook!");
????} else {
??????Log.d("MeuApp", "Usurio 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! Usurio 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 usurio cancelou o login do Twitter.");
????} else if (user.isNew()) {
??????Log.d("MeuApp", "Usurio criado e logado via Twitter!");
????} else {
??????Log.d("MeuApp", "Usurio 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! Usurio conectou sua conta do Twitter!");
??????}
????}
??});
}                                                                         LINK
Cloud Code
Parse
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

More Related Content

What's hot (19)

Discover ServiceWorker
Discover ServiceWorkerDiscover ServiceWorker
Discover ServiceWorker
Sandro Paganotti
?
Einfhrung in Meteor
Einfhrung in MeteorEinfhrung in Meteor
Einfhrung in Meteor
Michael Johann
?
Aller plus loin avec Doctrine2
Aller plus loin avec Doctrine2Aller plus loin avec Doctrine2
Aller plus loin avec Doctrine2
Andr Tapia
?
Tugas pemrograman jaringan
Tugas pemrograman jaringanTugas pemrograman jaringan
Tugas pemrograman jaringan
Banser Sahara
?
ECMA2015 INSIDE
ECMA2015 INSIDEECMA2015 INSIDE
ECMA2015 INSIDE
Jun Ho Lee
?
jQuery sans jQuery
jQuery sans jQueryjQuery sans jQuery
jQuery sans jQuery
goldoraf
?
Marresearch
MarresearchMarresearch
Marresearch
anurag894712
?
Aplicacion turbogenerador java
Aplicacion turbogenerador javaAplicacion turbogenerador java
Aplicacion turbogenerador java
Jos Antonio Sandoval Acosta
?
Device Orientation & WebSocket API
Device Orientation & WebSocket APIDevice Orientation & WebSocket API
Device Orientation & WebSocket API
Comparto 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 2010
Tom Croucher
?
Assalamualaykum warahmatullahi wabarakatuu
Assalamualaykum warahmatullahi wabarakatuuAssalamualaykum warahmatullahi wabarakatuu
Assalamualaykum warahmatullahi wabarakatuu
iswan_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 Tips
Luciano 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 2014
SOAT
?
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 Basic
HumbertoWuwu
?
Testovn prakticky
Testovn praktickyTestovn prakticky
Testovn prakticky
Filip Prochzka
?
Socket.io - Intro
Socket.io - IntroSocket.io - Intro
Socket.io - Intro
Antonio Kobashikawa Carrasco
?
Aller plus loin avec Doctrine2
Aller plus loin avec Doctrine2Aller plus loin avec Doctrine2
Aller plus loin avec Doctrine2
Andr Tapia
?
Tugas pemrograman jaringan
Tugas pemrograman jaringanTugas pemrograman jaringan
Tugas pemrograman jaringan
Banser Sahara
?
jQuery sans jQuery
jQuery sans jQueryjQuery sans jQuery
jQuery sans jQuery
goldoraf
?
Device Orientation & WebSocket API
Device Orientation & WebSocket APIDevice Orientation & WebSocket API
Device Orientation & WebSocket API
Comparto 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 2010
Tom Croucher
?
Assalamualaykum warahmatullahi wabarakatuu
Assalamualaykum warahmatullahi wabarakatuuAssalamualaykum warahmatullahi wabarakatuu
Assalamualaykum warahmatullahi wabarakatuu
iswan_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
?
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 2014
SOAT
?
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 Basic
HumbertoWuwu
?

Viewers also liked (18)

Seguimiento del power 2.1Seguimiento del power 2.1
Seguimiento del power 2.1
giseladanderfer
?
App development company
App development companyApp development company
App development company
Soft Prodigy System Solution (P) Ltd
?
Derrame pleuralDerrame pleural
Derrame pleural
XochitlDeGraciaDeLaG
?
Tecnoliga
TecnoligaTecnoliga
Tecnoliga
Katerinzita Correa
?
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
AED Solutions
?
Taller word
Taller wordTaller word
Taller word
Katerinzita Correa
?
Competencia liderazgoCompetencia liderazgo
Competencia liderazgo
Tito Perez
?
Cadenas Carbonadas
Cadenas CarbonadasCadenas Carbonadas
Cadenas Carbonadas
joshman valarezo
?
Apresiasi puisi syair
Apresiasi puisi   syairApresiasi puisi   syair
Apresiasi puisi syair
Harman Aris
?
Mcte2013 participant
Mcte2013 participantMcte2013 participant
Mcte2013 participant
Jen Heymoss
?
Presentation about China Exhibition Industry
Presentation about China Exhibition IndustryPresentation about China Exhibition Industry
Presentation about China Exhibition Industry
Christopher Kappes
?
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
scranton toyota
?
Geology 2 eso
Geology 2 esoGeology 2 eso
Geology 2 eso
iesmontecarrasco
?
Navidad
NavidadNavidad
Navidad
Adriana Prez Vieira
?
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
Sharon McKellar
?
Lesson of Love
Lesson of Love   Lesson of Love
Lesson of Love
DrSonica Krishan
?
Investor Relations Podcasts Using Buzzsprout
Investor Relations Podcasts Using BuzzsproutInvestor Relations Podcasts Using Buzzsprout
Investor Relations Podcasts Using Buzzsprout
IR Smartt Inc.
?
Seguimiento del power 2.1Seguimiento del power 2.1
Seguimiento del power 2.1
giseladanderfer
?
Derrame pleuralDerrame pleural
Derrame pleural
XochitlDeGraciaDeLaG
?
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
AED Solutions
?
Competencia liderazgoCompetencia liderazgo
Competencia liderazgo
Tito Perez
?
Apresiasi puisi syair
Apresiasi puisi   syairApresiasi puisi   syair
Apresiasi puisi syair
Harman Aris
?
Mcte2013 participant
Mcte2013 participantMcte2013 participant
Mcte2013 participant
Jen Heymoss
?
Presentation about China Exhibition Industry
Presentation about China Exhibition IndustryPresentation about China Exhibition Industry
Presentation about China Exhibition Industry
Christopher Kappes
?
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
scranton toyota
?
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
Sharon McKellar
?
Investor Relations Podcasts Using Buzzsprout
Investor Relations Podcasts Using BuzzsproutInvestor Relations Podcasts Using Buzzsprout
Investor Relations Podcasts Using Buzzsprout
IR Smartt Inc.
?

Parse

  • 3. Parse Data Parse Push Parse Social Cloud Code
  • 4. iOS OS X Android Javascript Windows Phone Windows 8 .NET Rest API
  • 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 comentrio 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 usurio no canal Giants. PushService.subscribe(context, "Giants", YourActivity.class);
  • 21. via cdigo ParsePush push = new ParsePush(); push.setChannel("Giants"); push.setMessage("Touchdown para os Giants! O time vira contra os Mets."); push.sendInBackground();
  • 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 usurio cancelou o login do Facebook."); ????} else if (user.isNew()) { ??????Log.d("MeuApp", "Usurio criado e logado via Facebook!"); ????} else { ??????Log.d("MeuApp", "Usurio 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! Usurio 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 usurio cancelou o login do Twitter."); ????} else if (user.isNew()) { ??????Log.d("MeuApp", "Usurio criado e logado via Twitter!"); ????} else { ??????Log.d("MeuApp", "Usurio 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! Usurio conectou sua conta do Twitter!"); ??????} ????} ??}); } LINK
  • 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
  • 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