【发布时间】:2015-05-29 04:31:38
【问题描述】:
【问题讨论】:
标签: ios parse-platform push-notification
【问题讨论】:
标签: ios parse-platform push-notification
与一个 parse.com 连接
[Parse setApplicationId:@"xxxx"
clientKey:@"xxxx"];
获取设备目录
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 证书文件。然后您将根据应用发送推送,例如使用渠道。一个应用程序的一个频道名称,第二个应用程序的另一个频道。您还可以在安装类中添加额外的字段,以便您可以通过查询用户向用户发送提前推送通知。
还有一个helpful link
【讨论】: