Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Parse Overview and Hosting

jamesjyu
July 15, 2013

Parse Overview and Hosting

A talk given at the Silicon Valley iOS Meetup about Parse and Parse Hosting.

The code for the live coding portion is here: https://github.com/ParsePlatform/LandingPageDemo

jamesjyu

July 15, 2013
Tweet

More Decks by jamesjyu

Other Decks in Technology

Transcript

  1. Database REST API Z Z Z Server + + +

    users + security Monday, July 15, 13
  2. Database REST API Z Z Z Server + + +

    users + security Networking Monday, July 15, 13
  3. Database REST API Z Z Z Server + + +

    users + security Caching Networking + Monday, July 15, 13
  4. Database REST API Z Z Z Server + + +

    users + security Caching Networking + + The fun stuff! Monday, July 15, 13
  5. Database REST API Z Z Z Server + + +

    users + security Caching Networking + + The fun stuff! Monday, July 15, 13
  6. Database REST API Z Z Z Server + + +

    users + security Caching Networking + + The fun stuff! no no no no no yes! Monday, July 15, 13
  7. Android OS X WP8 Win 8 .NET Cloud Code REST

    JavaScript Monday, July 15, 13
  8. Users Facebook & Twitter Follow Pictures Comments & Likes Location

    Displaying all this data Monday, July 15, 13
  9. Users Facebook & Twitter Follow Pictures Push Noti cation Comments

    & Likes Location Displaying all this data Monday, July 15, 13
  10. Sign up a user PFUser *user = [PFUser user]; [user

    setUsername:@"Apps"]; [user setPassword:@"r0ck"]; [user signUpInBackground:...]; Monday, July 15, 13
  11. Sign up a user PFUser *user = [PFUser user]; [user

    setUsername:@"Apps"]; [user setPassword:@"r0ck"]; [user signUpInBackground:...]; Login a user [PFUser logInWithUsernameInBackground:@"Apps" password:@"r0ck" block:...]; Monday, July 15, 13
  12. Sign up a user PFUser *user = [PFUser user]; [user

    setUsername:@"Apps"]; [user setPassword:@"r0ck"]; [user signUpInBackground:...]; Login a user [PFUser logInWithUsernameInBackground:@"Apps" password:@"r0ck" block:...]; [PFUser currentUser]; Monday, July 15, 13
  13. Facebook Users [PFFacebookUtils logInWithPermissions:permissions block:...]; ...even Twitter Users [PFTwitterUtils logInWithBlock:...];

    [PFFacebookUtils linkUser:[PFUser currentUser] permissions:permissions block:...]; [PFTwitterUtils linkUser:[PFUser currentUser] block:...]; Monday, July 15, 13
  14. PFObject *comment = [PFObject objectWithClassName:@"Comment"]; [comment setObject:@"Great pic!" forKey:@"text"]; [comment

    saveInBackground]; [comment setObject:[PFUser currentUser] forKey:@"user"]; Monday, July 15, 13
  15. PFObject *comment = [PFObject objectWithClassName:@"Comment"]; [comment setObject:@"Great pic!" forKey:@"text"]; [comment

    saveInBackground]; [comment setObject:[PFUser currentUser] forKey:@"user"]; Monday, July 15, 13
  16. PFObject *comment = [PFObject objectWithClassName:@"Comment"]; [comment setObject:@"Great pic!" forKey:@"text"]; [comment

    saveInBackground]; [comment setObject:[PFUser currentUser] forKey:@"user"]; [comment setObject:point forKey:@"location"]; PFGeoPoint *point = [PFGeoPoint geoPointWithLatitude:40.0 longitude:-30.0]; Monday, July 15, 13
  17. PFObject *comment = [PFObject objectWithClassName:@"Comment"]; [comment setObject:@"Great pic!" forKey:@"text"]; [comment

    saveInBackground]; [comment setObject:[PFUser currentUser] forKey:@"user"]; [comment setObject:point forKey:@"location"]; PFGeoPoint *point = [PFGeoPoint geoPointWithLatitude:40.0 longitude:-30.0]; Monday, July 15, 13
  18. PFObject *comment = [PFObject objectWithClassName:@"Comment"]; [comment setObject:@"Great pic!" forKey:@"text"]; [comment

    saveInBackground]; [comment setObject:[PFUser currentUser] forKey:@"user"]; [comment setObject:point forKey:@"location"]; PFGeoPoint *point = [PFGeoPoint geoPointWithLatitude:40.0 longitude:-30.0]; Monday, July 15, 13
  19. PFObject *picture = [PFObject objectWithClassName:@"Picture"]; [picture setObject:@"Seoul nightlife" forKey:@"title"]; [picture

    saveInBackground]; NSData *imageData = UIImagePNGRepresentation(image); PFFile *imageFile = [PFFile fileWithData:imageData]; [imageFile saveInBackground]; [picture setObject:imageFile forKey:@"image"]; Monday, July 15, 13
  20. PFObject *picture = [PFObject objectWithClassName:@"Picture"]; [picture setObject:@"Red Hot Chili Peppers!"

    forKey:@"title"]; [picture saveInBackground]; NSData *imageData = UIImagePNGRepresentation(image); PFFile *imageFile = [PFFile fileWithData:imageData]; [imageFile saveInBackground]; [picture setObject:imageFile forKey:@"image"]; Monday, July 15, 13
  21. PFObject *picture = [PFObject objectWithClassName:@"Picture"]; [picture setObject:@"Red Hot Chili Peppers!"

    forKey:@"title"]; [picture saveInBackground]; NSData *imageData = UIImagePNGRepresentation(image); PFFile *imageFile = [PFFile fileWithData:imageData]; [imageFile saveInBackground]; [picture setObject:imageFile forKey:@"image"]; Monday, July 15, 13
  22. Users Facebook & Twitter Follow Pictures Push Noti cation Comments

    & Likes Location Displaying all this data Monday, July 15, 13
  23. Users Facebook & Twitter Follow Pictures Push Noti cation Comments

    & Likes Location Displaying all this data Monday, July 15, 13
  24. Users Facebook & Twitter Follow Pictures Push Noti cation Comments

    & Likes Location Displaying all this data Monday, July 15, 13
  25. Users Facebook & Twitter Follow Pictures Push Noti cation Comments

    & Likes Location Displaying all this data Monday, July 15, 13
  26. Users Facebook & Twitter Follow Pictures Push Noti cation Comments

    & Likes Location Displaying all this data Monday, July 15, 13
  27. Users Facebook & Twitter Follow Pictures Push Noti cation Comments

    & Likes Location Displaying all this data Monday, July 15, 13
  28. PFQuery *query = [PFQuery queryForClass:@"Picture"]; [query whereKey:@"user" equalTo:[PFUser currentUser]]; [query

    whereKey:@"createdAt" greaterThan:dateOneWeekAgo]; [query findObjectsInBackgroundWithBlock:...]; Monday, July 15, 13
  29. PFQuery *query = [PFQuery queryForClass:@"Picture"]; [query whereKey:@"user" equalTo:[PFUser currentUser]]; [query

    whereKey:@"createdAt" greaterThan:dateOneWeekAgo]; [query findObjectsInBackgroundWithBlock: ^(NSArray *objects, NSError *error) { if (!error) { // The find succeeded. NSLog(@"Successfully retrieved objects!”); } else { // Log details of the failure NSLog(@"Error: %@ %@", error, [error userInfo]); } } ]; Monday, July 15, 13
  30. PFUser *user = [PFUser currentUser]; PFRelation *relation = [user relationForKey:@"following"];

    [relation addObject:newFriend]; [relation addObject:anotherFriend]; Monday, July 15, 13
  31. PFUser *user = [PFUser currentUser]; PFRelation *relation = [user relationForKey:@"following"];

    [relation addObject:newFriend]; [user saveInBackground]; [relation addObject:anotherFriend]; Monday, July 15, 13
  32. PFQuery *query = [PFInstallation query]; [query whereKey:@"owner" matchesQuery:peopleNearConf63]; PFInstallation *inst

    = [PFInstallation currentInstallation]; [inst setObject:[PFUser currentUser] forKey:@"owner"]; Push to Query Monday, July 15, 13
  33. PFQuery *query = [PFInstallation query]; [query whereKey:@"owner" matchesQuery:peopleNearConf63]; [PFPush sendPushMessageToQuery:query

    withMessage:@"Mobile Dev Con Today!" error:error]; PFInstallation *inst = [PFInstallation currentInstallation]; [inst setObject:[PFUser currentUser] forKey:@"owner"]; Push to Query Monday, July 15, 13
  34. Users Facebook & Twitter Follow Pictures Push Noti cation Comments

    & Likes Location Displaying all this data Monday, July 15, 13
  35. Users Facebook & Twitter Follow Pictures Push Noti cation Comments

    & Likes Location Displaying all this data Monday, July 15, 13
  36. Users Facebook & Twitter Follow Pictures Push Noti cation Comments

    & Likes Location Displaying all this data Monday, July 15, 13
  37. Users Facebook & Twitter Follow Pictures Push Noti cation Comments

    & Likes Location Displaying all this data Monday, July 15, 13
  38. 01011010001010100101010101010101011110010100110110110101011001001000 01010101110101101100001001001010101011100110001010101010001011000110 10011001010011110001110010101110001110001010101011010001010100101010 01011110010100110110110101011001001000100110101010101110101101100001 10101011100110001010101010001011000110011100010011001010011110001110 10001110001010101011010001010100101010101010101011110010100110110110 01001000100110101010101110101101100001001001010101011100110001010101 11000110011100010011001010011110001110010101110001110001010101011010 00101010101010101011110010100110110110101011001001000100110101010101 01100001001001010101011100110001010101010001011000110011100010011001

    10001110010101110001110001010101011010001010100101010101010101011110 10110110101011001001000100110101010101110101101100001001001010101011 01010101010001011000110011100010011001010011110001110010101110001110 01011010001010100101010101010101011110010100110110110101011001001000 01010101110101101100001001001010101011100101010111010110110000100100 01110011000101010101000101100011001110001001100101001111000111001010 11000101010101101000101010010101010101010101111001010011011011010101 It’s code in the Monday, July 15, 13
  39. 01011010001010100101010101010101011110010100110110110101011001001000 01010101110101101100001001001010101011100110001010101010001011000110 10011001010011110001110010101110001110001010101011010001010100101010 01011110010100110110110101011001001000100110101010101110101101100001 10101011100110001010101010001011000110011100010011001010011110001110 10001110001010101011010001010100101010101010101011110010100110110110 01001000100110101010101110101101100001001001010101011100110001010101 11000110011100010011001010011110001110010101110001110001010101011010 00101010101010101011110010100110110110101011001001000100110101010101 01100001001001010101011100110001010101010001011000110011100010011001

    10001110010101110001110001010101011010001010100101010101010101011110 10110110101011001001000100110101010101110101101100001001001010101011 01010101010001011000110011100010011001010011110001110010101110001110 01011010001010100101010101010101011110010100110110110101011001001000 01010101110101101100001001001010101011100101010111010110110000100100 01110011000101010101000101100011001110001001100101001111000111001010 11000101010101101000101010010101010101010101111001010011011011010101 It’s JavaScript in the Cloud Monday, July 15, 13
  40. 01011010001010100101010101010101011110010100110110110101011001001000 01010101110101101100001001001010101011100110001010101010001011000110 10011001010011110001110010101110001110001010101011010001010100101010 01011110010100110110110101011001001000100110101010101110101101100001 10101011100110001010101010001011000110011100010011001010011110001110 10001110001010101011010001010100101010101010101011110010100110110110 01001000100110101010101110101101100001001001010101011100110001010101 11000110011100010011001010011110001110010101110001110001010101011010 00101010101010101011110010100110110110101011001001000100110101010101 01100001001001010101011100110001010101010001011000110011100010011001

    10001110010101110001110001010101011010001010100101010101010101011110 10110110101011001001000100110101010101110101101100001001001010101011 01010101010001011000110011100010011001010011110001110010101110001110 01011010001010100101010101010101011110010100110110110101011001001000 01010101110101101100001001001010101011100101010111010110110000100100 01110011000101010101000101100011001110001001100101001111000111001010 11000101010101101000101010010101010101010101111001010011011011010101 Parse.Cloud.define("averageLikes", function(request, response) { }); var query = new Parse.Query("Photo"); query.equalTo("user", Parse.User.current()); query.find({ }); error: function() { response.error("Oops, something went wrong."); } success: function(results) { var sum = 0; for (var i = 0; i < results.length; ++i) { sum += results[i].get("likes"); } response.success(sum / results.length); }, Monday, July 15, 13
  41. 01011010001010100101010101010101011110010100110110110101011001001000 01010101110101101100001001001010101011100110001010101010001011000110 10011001010011110001110010101110001110001010101011010001010100101010 01011110010100110110110101011001001000100110101010101110101101100001 10101011100110001010101010001011000110011100010011001010011110001110 10001110001010101011010001010100101010101010101011110010100110110110 01001000100110101010101110101101100001001001010101011100110001010101 11000110011100010011001010011110001110010101110001110001010101011010 00101010101010101011110010100110110110101011001001000100110101010101 01100001001001010101011100110001010101010001011000110011100010011001

    10001110010101110001110001010101011010001010100101010101010101011110 10110110101011001001000100110101010101110101101100001001001010101011 01010101010001011000110011100010011001010011110001110010101110001110 01011010001010100101010101010101011110010100110110110101011001001000 01010101110101101100001001001010101011100101010111010110110000100100 01110011000101010101000101100011001110001001100101001111000111001010 11000101010101101000101010010101010101010101111001010011011011010101 Is that it...? Monday, July 15, 13
  42. 01011010001010100101010101010101011110010100110110110101011001001000 01010101110101101100001001001010101011100110001010101010001011000110 10011001010011110001110010101110001110001010101011010001010100101010 01011110010100110110110101011001001000100110101010101110101101100001 10101011100110001010101010001011000110011100010011001010011110001110 10001110001010101011010001010100101010101010101011110010100110110110 01001000100110101010101110101101100001001001010101011100110001010101 11000110011100010011001010011110001110010101110001110001010101011010 00101010101010101011110010100110110110101011001001000100110101010101 01100001001001010101011100110001010101010001011000110011100010011001

    10001110010101110001110001010101011010001010100101010101010101011110 10110110101011001001000100110101010101110101101100001001001010101011 01010101010001011000110011100010011001010011110001110010101110001110 01011010001010100101010101010101011110010100110110110101011001001000 01010101110101101100001001001010101011100101010111010110110000100100 01110011000101010101000101100011001110001001100101001111000111001010 11000101010101101000101010010101010101010101111001010011011011010101 Parse.Cloud.beforeSave("Comment", function(request, response) { }); var text = request.object.get("text"); if (text.length > 140) { request.object.set("text",text.substring(0,137 + "..."); } response.success(); Monday, July 15, 13
  43. 01011010001010100101010101010101011110010100110110110101011001001000 01010101110101101100001001001010101011100110001010101010001011000110 10011001010011110001110010101110001110001010101011010001010100101010 01011110010100110110110101011001001000100110101010101110101101100001 10101011100110001010101010001011000110011100010011001010011110001110 10001110001010101011010001010100101010101010101011110010100110110110 01001000100110101010101110101101100001001001010101011100110001010101 11000110011100010011001010011110001110010101110001110001010101011010 00101010101010101011110010100110110110101011001001000100110101010101 01100001001001010101011100110001010101010001011000110011100010011001

    10001110010101110001110001010101011010001010100101010101010101011110 10110110101011001001000100110101010101110101101100001001001010101011 01010101010001011000110011100010011001010011110001110010101110001110 01011010001010100101010101010101011110010100110110110101011001001000 01010101110101101100001001001010101011100101010111010110110000100100 01110011000101010101000101100011001110001001100101001111000111001010 11000101010101101000101010010101010101010101111001010011011011010101 What about 3rd party APIs? Monday, July 15, 13
  44. 01010111010110110000100100101010101110011000101010101000101100011001 01100101001111000111001010111000111000101010101101000101010010101010 01111001010011011011010101100100100010011010101010111010110110000100 10101110011000101010101000101100011001110001001100101001111000111001 00111000101010101101000101010010101010101010101111001010011011011010 00100010011010101010111010110110000100100101010101110011000101010101 00011001110001001100101001111000111001010111000111000101010101101000 10101010101010101111001010011011011010101100100100010011010101010111 10000100100101010101110011000101010101000101100011001110001001100101 00111001010111000111000101010101101000101010010101010101010101111001

    11011010101100100100010011010101010111010110110000100100101010101110 01010101000101100011001110001001100101001111000111001010111000111000 01101000101010010101010101010101111001010011011011010101100100100010 01010111010110110000100100101010101110010101011101011011000010010010 11001100010101010100010110001100111000100110010100111100011100101011 00010101010110100010101001010101010101010111100101001101101101010110 01001101010101011101011011000010010010101010111001 Parse.Cloud.httpRequest({ url: 'http://www.parse.com/', success: function(httpResponse) { console.log(httpResponse.text); }, error: function(httpResponse) { console.error('Request failed: ' + httpResponse.status); } }); Monday, July 15, 13
  45. Static Hosting • Choose a domain: myapp.parseapp.com (or custom) •

    Initialize your parse directory Monday, July 15, 13
  46. Static Hosting • Choose a domain: myapp.parseapp.com (or custom) •

    Initialize your parse directory • Create public/helloword.html Monday, July 15, 13
  47. Static Hosting • Choose a domain: myapp.parseapp.com (or custom) •

    Initialize your parse directory • Create public/helloword.html • Type parse deploy Monday, July 15, 13
  48. Static Hosting • Choose a domain: myapp.parseapp.com (or custom) •

    Initialize your parse directory • Create public/helloword.html • Type parse deploy • Your web page is live Monday, July 15, 13
  49. express.js • Web framework built for node • Now with

    Cloud Code + Parse JS SDK • Simple but expressive Monday, July 15, 13
  50. Directory Structure -cloud/ main.js Cloud Code app.js Express code -views/

    View templates hello.ejs -public/ example.html Static HTML files -stylesheets/ CSS stylesheets style.css Monday, July 15, 13
  51. Hello World + Template <!DOCTYPE html> <html> <head> <title>Sample App</title>

    </head> <body> <h1>Hello World</h1> </body> </html> hello.ejs Monday, July 15, 13
  52. Hello World + Dynamic Template <!DOCTYPE html> <html> <head> <title>Sample

    App</title> </head> <body> <h1><%= message %></h1> </body> </html> hello.ejs Monday, July 15, 13
  53. Hello World + Dynamic Template app.get('/', function(req, res) { res.render('hello',

    { message: req.query.msg }); }); app.js http://myapp.parseapp.com/?msg=hi Monday, July 15, 13
  54. What Else? • Full blown web apps • Admin interfaces

    • Web hooks • Cloud Modules: send emails, texts charge cc’s, etc Monday, July 15, 13
  55. Further Reading • Guide: parse.com/docs/cloud_code_guide • Express: expressjs.com • Anymeme:

    www.anymeme.org • Anyblog: github.com/ParsePlatform/AnyBlog Monday, July 15, 13