Parse.com

1,545 views

Published on

Published in: Technology
  • Be the first to comment

Parse.com

  1. 1. Parse.comMobile app platformBy John Tubert
  2. 2. Why parse.com?● Free (to start)● No server needed● Easy to use● Multi-platform
  3. 3. How to get started1. Create free account2. Download SDK or blank xcode project3. Start coding
  4. 4. How to really get started1. Add framework to project2. Add import statement to prefix filea. #import <Parse/Parse.h>3. Initialize parse on delegate filea. [Parse setApplicationId:@"" clientKey:@""];4. Add code to read or write to parse.com
  5. 5. Register/login usersShow LoginAndSignUpDemo
  6. 6. WritePFObject *addressObject = [PFObject objectWithClassName:@"Addresses"];[addressObject setObject:@"John Tubert" forKey:@"name"];[addressObject setObject:@"350 west 39th Street" forKey:@"Address"];[addressObject setObject:@"New York" forKey:@"City"];[addressObject setObject:@"NY" forKey:@"State"];[addressObject setObject:@"10018" forKey:@"Zip"];[addressObject save];
  7. 7. CountPFQuery *queryPhotoCount = [PFQuery queryWithClassName:@"Photo"];[queryPhotoCount whereKey:kPAPPhotoUserKey equalTo:[PFUsercurrentUser]];[queryPhotoCount setCachePolicy:kPFCachePolicyCacheThenNetwork];[queryPhotoCount countObjectsInBackgroundWithBlock:^(int number,NSError *error) {if (!error) {NSLog(@"count: %i",number);}}];
  8. 8. ReadPFQuery *query = [PFQuery queryWithClassName:@"Addresses"];[query setCachePolicy:kPFCachePolicyCacheThenNetwork];[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError*error) {if (error) {NSLog(@"error %@",error);}else{NSLog(@"objects %@",objects);}}];
  9. 9. Read (with constraints)PFQuery *query = [PFQuery queryWithClassName:@"Addresses"];[query whereKey:@"name" containsString:@"John"];[query setCachePolicy:kPFCachePolicyCacheThenNetwork];[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError*error) {if (error) {NSLog(@"error %@",error);}else{NSLog(@"objects %@",objects);}}];
  10. 10. More constraintsBasic Constraints- (void)includeKey:(NSString *)key;- (void)whereKeyExists:(NSString *)key;- (void)whereKeyDoesNotExist:(NSString *)key;- (void)whereKey:(NSString *)key equalTo:(id)object;- (void)whereKey:(NSString *)key lessThan:(id)object;- (void)whereKey:(NSString *)key lessThanOrEqualTo:(id)object;- (void)whereKey:(NSString *)key greaterThan:(id)object;- (void)whereKey:(NSString *)key greaterThanOrEqualTo:(id)object;- (void)whereKey:(NSString *)key notEqualTo:(id)object;- (void)whereKey:(NSString *)key containedIn:(NSArray *)array;- (void)whereKey:(NSString *)key notContainedIn:(NSArray *)array;Location Constraints- (void)whereKey:(NSString *)key nearGeoPoint:(PFGeoPoint *)geopoint;- (void)whereKey:(NSString *)key nearGeoPoint:(PFGeoPoint *)geopoint withinMiles:(double)maxDistance;- (void)whereKey:(NSString *)key nearGeoPoint:(PFGeoPoint *)geopoint withinKilometers:(double)maxDistance;- (void)whereKey:(NSString *)key nearGeoPoint:(PFGeoPoint *)geopoint withinRadians:(double)maxDistance;- (void)whereKey:(NSString *)key withinGeoBoxFromSouthwest:(PFGeoPoint *)southwest toNortheast:(PFGeoPoint *)northeast;String Constraints- (void)whereKey:(NSString *)key matchesRegex:(NSString *)regex;- (void)whereKey:(NSString *)key matchesRegex:(NSString *)regex modifiers:(NSString *)modifiers;- (void)whereKey:(NSString *)key containsString:(NSString *)substring;- (void)whereKey:(NSString *)key hasPrefix:(NSString *)prefix;- (void)whereKey:(NSString *)key hasSuffix:(NSString *)suffix;
  11. 11. Saving photosPFObject *photo = [PFObject objectWithClassName:kPAPPhotoClassKey];[photo setObject:[PFUser currentUser] forKey:kPAPPhotoUserKey];[photo setObject:self.photoFile forKey:kPAPPhotoPictureKey];[photo setObject:self.thumbnailFile forKey:kPAPPhotoThumbnailKey];[photo save];
  12. 12. DEMOShow ArchUp demo
  13. 13. Demo: using JS APIhttp://jtubert.com/sketchit/
  14. 14. Server side methods(AKA: cloud code)Parse.Cloud.define("hello", function(request, response) {response.success("Hello Parse world!");});
  15. 15. Getting started: Cloud codeInstall the command line tool:curl -s https://www.parse.com/downloads/cloud_code/installer.sh | sudo /bin/bashCreate new project:$ parse new MyCloudCodeWrite functions:Parse.Cloud.define("hello", function(request, response) {response.success("Hello world!");});Deploy code:$ parse deployCall methods from app:[PFCloud callFunctionInBackground:@"hello" withParameters:@{} block:^(NSString *result, NSError*error) {if (!error) {// result is @"Hello world!"NSLog(@"%@",result);}}];
  16. 16. Questions/Comments
  17. 17. THANKS

×