parse introduction
DESCRIPTION
TRANSCRIPT
初めての Parse株式会社 ミクシィ田村 航弥
12年7月23日月曜日
agenda
• @tamotamago
• what’s Parse?
• Data Store
• Query
• Push Notification
12年7月23日月曜日
@tamotamago について
12年7月23日月曜日
@tamotamago について• 田村 航弥
• 東京 2 年目 iOS App developer
• mixi for iPhone, iPad 開発
• http://alpha.mixi.co.jp/2012/10974/• tamotamago.com
12年7月23日月曜日
@tamotamago について
• 第2回 iphone_dev_jp 東京iPhone/Mac勉強会
http://alpha.mixi.co.jp/2012/11000/
mixi の iOS アプリ開発
@k_kinukawa
12年7月23日月曜日
What’s Parse?
12年7月23日月曜日
What’s Parse
• Parse は BaaS (Backend as a Service)
12年7月23日月曜日
What’s Parse
• Parse の機能
•ユーザ認証機能
•データストア、検索
• remote notification
• twitter, facebok SDK をラップ
• and so on ...12年7月23日月曜日
12年7月23日月曜日
Parse の導入
• Parse Quick Start
• tamotamago.com [Objective-C][Parse]初めてのParse ー導入編ー
12年7月23日月曜日
Data Storehttps://parse.com/docs/ios/api/Classes/PFObject.html
12年7月23日月曜日
Data Store
• Key Value Store
•ブラウザからデータ閲覧、編集が可能
•リレーションも持たせることができる
12年7月23日月曜日
Data Store
12年7月23日月曜日
Data Store
テーブル名みたいなもの かってにつくられる
自分でつくっていく
12年7月23日月曜日
Save -blocks-
PFObject *object = [[PFObject alloc]initWithClassName:@"TestClass"];[object setObject:@"tamotamago" forKey:@"name"];[object saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) { NSString *result = succeeded ? @"success" : @"error"; NSLog(@"result : %@", result);}];
12年7月23日月曜日
Save -callbacks-- (void)viewDidLoad{ [super viewDidLoad];! // Do any additional setup after loading the view, typically from a nib. PFObject *object = [[PFObject alloc]initWithClassName:@"TestClass"]; [object setObject:@"tamotamago2" forKey:@"name"]; [object saveInBackgroundWithTarget:self selector:@selector(saveCallback:error:)];}
-(void)saveCallback:(NSNumber*)result error:(NSError*)error{ if(!error){ NSLog(@"%@", result); }else{ NSLog(@"%@", error); }}
12年7月23日月曜日
UpdatePFObject *object = [[PFObject alloc]initWithClassName:@"TestClass"];[object setObject:@"tamotamago3" forKey:@"name"];[object saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) { [object setObject:@"tamotamago4" forKey:@"name"]; [object save];}];
PFObject が 1 タプル
12年7月23日月曜日
Array Data
PFObject *object = [[PFObject alloc]initWithClassName:@"TestClass"];NSArray *names = [NSArray arrayWithObjects:@"tamotamago5", @"tamotamago6", nil];[object addUniqueObjectsFromArray:names forKey:@"names"];[object save];
12年7月23日月曜日
Relation -one-to-many-
Post
Comment Comment Comment
parent
12年7月23日月曜日
Relation -one-to-many-PFObject *myPost = [PFObject objectWithClassName:@"Post"];[myPost setObject:@"I'm Hungry" forKey:@"title"];[myPost setObject:@"Where should we go for lunch?" forKey:@"content"]; // Create the commentPFObject *myComment = [PFObject objectWithClassName:@"Comment"];[myComment setObject:@"Let's do Sushirrito." forKey:@"content"]; // Add a relation between the Post and Comment[myComment setObject:myPost forKey:@"parent"]; // This will save both myPost and myComment[myComment saveInBackground];
12年7月23日月曜日
Relation -one-to-many-PFObject *myPost = [PFObject objectWithClassName:@"Post"];[myPost setObject:@"I'm Hungry" forKey:@"title"];[myPost setObject:@"Where should we go for lunch?" forKey:@"content"]; // Create the commentPFObject *myComment = [PFObject objectWithClassName:@"Comment"];[myComment setObject:@"Let's do Sushirrito." forKey:@"content"]; // Add a relation between the Post and Comment[myComment setObject:myPost forKey:@"parent"]; // This will save both myPost and myComment[myComment saveInBackground];
12年7月23日月曜日
Relation -many-to-many-
PostPost Post
user useruser
like
12年7月23日月曜日
Relation -many-to-many-Parse blog : A More Scalable Many-to-Many Approach
PFObject *post2 = [PFObject objectWithClassName:@"Post"];[post2 setObject:@"I'm Hungry" forKey:@"title"];[post2 setObject:@"Where should we go for dinner?" forKey:@"content"];PFRelation *relation = [post2 relationforKey:@"likes"];
for (PFObject *object in objects){ [relation addObject: object];}
[post2 save];
12年7月23日月曜日
Relation -many-to-many-Parse blog : A More Scalable Many-to-Many Approach
PFObject *post2 = [PFObject objectWithClassName:@"Post"];[post2 setObject:@"I'm Hungry" forKey:@"title"];[post2 setObject:@"Where should we go for dinner?" forKey:@"content"];PFRelation *relation = [post2 relationforKey:@"likes"];
for (PFObject *object in objects){ [relation addObject: object];}
[post2 save];
12年7月23日月曜日
Relation -many-to-many-Parse blog : A More Scalable Many-to-Many Approach
PFObject *post2 = [PFObject objectWithClassName:@"Post"];[post2 setObject:@"I'm Hungry" forKey:@"title"];[post2 setObject:@"Where should we go for dinner?" forKey:@"content"];PFRelation *relation = [post2 relationforKey:@"likes"];
for (PFObject *object in objects){ [relation addObject: object];}
[post2 save];
12年7月23日月曜日
Querieshttps://parse.com/docs/ios/api/Classes/PFQuery.html
12年7月23日月曜日
Basic Query
12年7月23日月曜日
Basic QueryPFQuery *query = [PFQuery queryWithClassName:@"TestClass"];[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { if (!error) { // The find succeeded. for (PFObject *object in objects){ NSLog(@"object name -> %@", [object objectForKey:@"name"]); } } else { // Log details of the failure NSLog(@"Error: %@ %@", error, [error userInfo]); }}];
2012-07-20 13:14:29.786 ParseTest[948:f803] object name -> tamotamago2012-07-20 13:14:29.787 ParseTest[948:f803] object name -> tamotamago22012-07-20 13:14:29.787 ParseTest[948:f803] object name -> tamotamago42012-07-20 13:14:29.788 ParseTest[948:f803] object name -> (null)2012-07-20 13:14:29.788 ParseTest[948:f803] object name -> tamotamago7
12年7月23日月曜日
Basic QueryPFQuery *query = [PFQuery queryWithClassName:@"TestClass"];[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { if (!error) { // The find succeeded. for (PFObject *object in objects){ NSLog(@"object name -> %@", [object objectForKey:@"name"]); } } else { // Log details of the failure NSLog(@"Error: %@ %@", error, [error userInfo]); }}];
2012-07-20 13:14:29.786 ParseTest[948:f803] object name -> tamotamago2012-07-20 13:14:29.787 ParseTest[948:f803] object name -> tamotamago22012-07-20 13:14:29.787 ParseTest[948:f803] object name -> tamotamago42012-07-20 13:14:29.788 ParseTest[948:f803] object name -> (null)2012-07-20 13:14:29.788 ParseTest[948:f803] object name -> tamotamago7
12年7月23日月曜日
Where 句
[query whereKey:@"name" equalTo:@"tamotamago"];
12年7月23日月曜日
OrderBy
[query orderByAscending:@"name"];
12年7月23日月曜日
IN 句
NSArray *array = [NSArray arrayWithObjects: @"tamotamago", @"tamotamago2", nil];[query whereKey:@"name" containedIn:array];
12年7月23日月曜日
Relation query
12年7月23日月曜日
Relation query
PFQuery *query = [[PFQuery alloc] initWithClassName:@"Post"];[query findObjectsInBackgroundWithBlock:^(NSArray *posts, NSError *error) { for (PFObject *post in posts){ PFRelation *relation = [post relationforKey:@"likes"]; PFQuery *relationQuery = [relation query]; [relationQuery findObjectsInBackgroundWithBlock:^(NSArray *tamotamagos, NSError *error) { for(PFObject *object in tamotamagos){ NSLog(@"%@", [object objectForKey:@"name"]); } }]; }}];
12年7月23日月曜日
Paging
[query findObjects]; query.skip = 3;[query findObjects];
object name -> tamotamagoobject name -> tamotamago2object name -> tamotamago4object name -> (null)object name -> tamotamago7
object name -> (null)object name -> tamotamago7
12年7月23日月曜日
Push Notificationhttps://parse.com/docs/ios/api/Classes/PFPush.html
12年7月23日月曜日
Setup
https://www.parse.com/tutorials/ios-push-notifications
証明書の発行とか
12年7月23日月曜日
Setup
12年7月23日月曜日
Setup- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ // Override point for customization after application launch. [Parse setApplicationId:@"app id" clientKey:@"client key"]; [application registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge| UIRemoteNotificationTypeAlert| UIRemoteNotificationTypeSound]; return YES;}
- (void)application:(UIApplication *)applicationdidRegisterForRemoteNotificationsWithDeviceToken:(NSData *)newDeviceToken{ // Tell Parse about the device token. [PFPush storeDeviceToken:newDeviceToken]; // Subscribe to the global broadcast channel. [PFPush subscribeToChannelInBackground:@""];}
12年7月23日月曜日
12年7月23日月曜日
channel
Push を投げるゾーン
12年7月23日月曜日
channel
- (void)application:(UIApplication *)applicationdidRegisterForRemoteNotificationsWithDeviceToken:(NSData *)newDeviceToken{ // Tell Parse about the device token. [PFPush storeDeviceToken:newDeviceToken]; // Subscribe to the global broadcast channel. [PFPush subscribeToChannelInBackground:@""]; [PFPush subscribeToChannelInBackground:@"tamotamago"];}
12年7月23日月曜日
channel
Broadcast
tamotamago
12年7月23日月曜日
channel
12年7月23日月曜日
channel
Broadcasttamotamagotamotamago2
tamotamago3
12年7月23日月曜日
send notification
PFPush *push = [[PFPush alloc] init];NSArray *channels = [NSArray arrayWithObjects:@"tamotamago", nil];[push setChannels:channels];[push setMessage:@"push test"];[push sendPushInBackgroundWithBlock:^(BOOL succeeded, NSError *error) { }];
12年7月23日月曜日
channel
Broadcasttamotamagotamotamago2
tamotamago3
push!!
12年7月23日月曜日
おわりに
12年7月23日月曜日
Others
• Users• https://parse.com/docs/ios/api/Classes/PFUser.html
• Geo Points• https://parse.com/docs/ios/api/Classes/PFGeoPoint.html
• Facebook Users• https://parse.com/docs/ios/api/Classes/PFFacebookUtils.html
• and so on ...
12年7月23日月曜日
でもお高いんでしょう?
12年7月23日月曜日
12年7月23日月曜日
enjoy
12年7月23日月曜日