iOS 应用通知 Parse.com
iOS App Notification with Parse.com
我有两个 iOS 应用程序与两个应用程序的一个 Parse app account. Now we want to implement push notifications using same Parse 帐户相关联。
这可能吗?
连接了一个 parse.com
[Parse setApplicationId:@"xxxx"
clientKey:@"xxxx"];
获取设备 Tocan
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:deviceToken];
currentInstallation.channels = @[ @"globle" ];
[currentInstallation saveInBackground];
NSString * udid=[[[[deviceToken description]
stringByReplacingOccurrencesOfString: @"<" withString: @""]
stringByReplacingOccurrencesOfString: @">" withString: @""]
stringByReplacingOccurrencesOfString: @" " withString: @""];
发送推送通知
NSMutableArray * arrUserParseQuery=[[NSMutableArray alloc]init];
//add user to send pushNotification
for (NSString * strObjectId in arrUsers) {
PFQuery * objUserQuery=[PFQuery queryWithClassName:@"_User"];
[objUserQuery whereKey:@"objectId" equalTo:strObjectId];
[arrUserParseQuery addObject:objUserQuery];
}
[pushQuery whereKey:@"UserId" matchesQuery:[PFQuery orQueryWithSubqueries:arrUserParseQuery]];
PFPush *push = [[PFPush alloc] init];
[push setQuery:pushQuery]; // Set our Installation query
[push setMessage:@"Notification text"];
[push sendPushInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
NSLog(@"Errer of push notification %@",error);
}];
您必须在 parse.com 中设置 Certificates 才能发送 pushNotification。
是的,有可能。请参考下面的屏幕截图,您可以在其中为多个 iOS 应用上传多个 p12 证书文件。然后您将根据应用程序发送推送,例如使用频道。一个应用程序的一个频道名称,第二个应用程序的另一个频道名称。您还可以向 Installation class 添加额外的字段,以便您可以通过查询用户向用户发送预先推送通知。
再来一个helpful link
我有两个 iOS 应用程序与两个应用程序的一个 Parse app account. Now we want to implement push notifications using same Parse 帐户相关联。
这可能吗?
连接了一个 parse.com
[Parse setApplicationId:@"xxxx"
clientKey:@"xxxx"];
获取设备 Tocan
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:deviceToken];
currentInstallation.channels = @[ @"globle" ];
[currentInstallation saveInBackground];
NSString * udid=[[[[deviceToken description]
stringByReplacingOccurrencesOfString: @"<" withString: @""]
stringByReplacingOccurrencesOfString: @">" withString: @""]
stringByReplacingOccurrencesOfString: @" " withString: @""];
发送推送通知
NSMutableArray * arrUserParseQuery=[[NSMutableArray alloc]init];
//add user to send pushNotification
for (NSString * strObjectId in arrUsers) {
PFQuery * objUserQuery=[PFQuery queryWithClassName:@"_User"];
[objUserQuery whereKey:@"objectId" equalTo:strObjectId];
[arrUserParseQuery addObject:objUserQuery];
}
[pushQuery whereKey:@"UserId" matchesQuery:[PFQuery orQueryWithSubqueries:arrUserParseQuery]];
PFPush *push = [[PFPush alloc] init];
[push setQuery:pushQuery]; // Set our Installation query
[push setMessage:@"Notification text"];
[push sendPushInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
NSLog(@"Errer of push notification %@",error);
}];
您必须在 parse.com 中设置 Certificates 才能发送 pushNotification。
是的,有可能。请参考下面的屏幕截图,您可以在其中为多个 iOS 应用上传多个 p12 证书文件。然后您将根据应用程序发送推送,例如使用频道。一个应用程序的一个频道名称,第二个应用程序的另一个频道名称。您还可以向 Installation class 添加额外的字段,以便您可以通过查询用户向用户发送预先推送通知。
再来一个helpful link