Top Banner
Writing Parse Apps Armenian Dev Meetup
21

Introduction to Parse backend for mobile developers

Jul 01, 2015

Download

Software

Introduction to Parse mobile backend service. Presented at Armenian Developer's Meetup #3 on 10/14/2014.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction to Parse backend for mobile developers

Writing Parse AppsArmenian Dev Meetup

Page 2: Introduction to Parse backend for mobile developers

What is MBaaS?

Page 3: Introduction to Parse backend for mobile developers

Why Parse?

● Learning curve● Documentation● Examples● Support

Page 4: Introduction to Parse backend for mobile developers

● Platform for mobile developers● Founded Jun 2011, YC● Acquired by Facebook, Apr 2013● Built on Amazon Web Services

Parse

Page 5: Introduction to Parse backend for mobile developers

Parse Architecture

Page 6: Introduction to Parse backend for mobile developers

Products

Page 7: Introduction to Parse backend for mobile developers

Client SDKs

Page 8: Introduction to Parse backend for mobile developers

Quickstart

Page 9: Introduction to Parse backend for mobile developers

Object Model

PFObject - unstructured key-value data objectPFObject *book = [PFObject objectWithClassName:@”Book”];book[@”title”] = @”The Little Prince”;[book saveInBackground];...int pages = [[book objectForKey:@”pages”] intValue];NSString *objectId = hotel.objectId;NSDate *createdAt = hotel.createdAt; (updatedAt)...[book saveEventually];

Page 10: Introduction to Parse backend for mobile developers

QueriesPFQuery *query = [PFQuery queryWithClassName:@”Book”];[query getObjectInBackgroundWithId:@”xWMyZ4YEGZ” block:^(PFObject *book, NSError *error) {

NSLog(@”%@”, book);}…[query whereKey:@”author” equalTo:@”Jack London”];[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError

*error) {…}]…query.limit = 5; query.skip = 10;[query orderByAscending:@”title”];[query selectKeys:@[@”title”, @”pages”];

Page 11: Introduction to Parse backend for mobile developers

Relational QueriesPFQuery *query = [PFQuery queryWithClassName:@”Comment”];[query whereKey:@”book” equalTo:theBook];…PFQuery *innerQuery = [PFQuery queryWithClassName:@”Book”];[innerQuery whereKeyExists:@”image”];PFQuery *query = [PFQuery queryWithClassName:@”Comment”];[query whereKey:@”book” matchesQuery:innerQuery];…query.cachePolicy = kPFCachePolicyNetworkElseCache;[query includeKey:@”author”];…PFQuery *query = [PFQuery orQueryWithSubqueries:@[queryA, queryB]];

Page 12: Introduction to Parse backend for mobile developers

Files and ImagesNSData *data = UIImagePNGRepresentation(image); // (up to 10MB)PFFile *file = [PFFile filwWithName:@”attachment.png” data:data];[file saveInBackground]; …PFObject *message = [PFObject objectWithClassName:@”Message”];message[@”attatchment”] = file;[message saveInBackground];…PFFile *imageFile = article[@”imageFile”];[imageFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {if (!error) {UIImage *image = [UIImage imageWithData:data];}];

Page 13: Introduction to Parse backend for mobile developers

Users

PFUser - user subclass of PFObjectPFUser *user = [PFUser user];user.username = @“myname”; // requireduser.password = @”mypass”; // required on signupuser.email = @”[email protected]”; // optional[user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error){...}];[PFUser logInUsernameInBackground@”myname” password:@”mypass” block:^(PFUser *user, NSError *error) {...}];PFUser *currentUser = [PFUser currentUser];[PFUser logOut];[PFUser requestPasswordRequestForEmailInBackground:@”[email protected]”];

Page 14: Introduction to Parse backend for mobile developers

Social Integrations

● Facebook and Twitter● Login & Signup● Link & unlinking existing users● API calls

Page 15: Introduction to Parse backend for mobile developers

Cloud Code

● Custom code on server● Command line tool (parse new, deploy)Parse.Cloud.define(“hello”, function(request, response) {

response.success(“hello world”); // 15 sec limit});[PFCloud callFunctionInBackground:@”hello” withParameters:@{}

block:^(NSString *results, NSError *error) {...} }];Parse.Cloud.beforeSave(“Book”, …); // 3 sec limitParse.Cloud.afterDelete(Parse.User, …);

Page 16: Introduction to Parse backend for mobile developers

UI Components

● PFLoginViewController● PFSignUpViewController ● PFQueryTableViewController● PFImageView● PFTableCellView

Page 17: Introduction to Parse backend for mobile developers

Data Browser

Page 18: Introduction to Parse backend for mobile developers

Analytics

Page 19: Introduction to Parse backend for mobile developers

Pricing

Page 20: Introduction to Parse backend for mobile developers

Recommendations

● Prototyping● Wrap Parse API● Development vs. Production● ACL● Cloud Code

Page 21: Introduction to Parse backend for mobile developers

Q&A

Thanks!