【发布时间】:2015-08-25 07:00:32
【问题描述】:
我正在开发一个使用 parse 作为后端的社交消息应用程序。当有人在群组中发短信时,我需要向群组成员发送推送通知。
我的代码是:
PFQuery* getMembers = [PFQuery queryWithClassName:@"Group"];
[getMembers whereKey:@"objectId" equalTo:groupId];
[getMembers includeKey:PF_RECENT_USER];
[getMembers findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
NSArray *ar = [[NSArray alloc]init];
ar=[[objects objectAtIndex:0]objectForKey:@"members"];
NSLog(@"members %@",ar);
PFQuery *queryInstallation = [PFInstallation query];
[queryInstallation whereKey:PF_INSTALLATION_USER matchesKey:PF_RECENT_USER inQuery:getMembers];
PFPush *push = [[PFPush alloc] init];
[push setQuery:queryInstallation];
//[push setMessage:text];
NSDictionary *data = [NSDictionary dictionaryWithObjectsAndKeys:
text, @"alert",
@"ursound.caf", @"sound",
@"Increment", @"badge",
// @"Optionally a type was set", @"type",
nil];
[push setData:data];
[push sendPushInBackgroundWithBlock:^(BOOL succeeded, NSError *error)
{
if (error != nil)
{
NSLog(@"SendPushNotification send error.");
}
}];
}
}];
请指导我纠正我的错误。
【问题讨论】:
-
然后会发生什么 -> 没有推送,或者只发送给错误的人?你检查过解析控制台吗?返回的错误是什么?
-
是的,我检查它显示推送已发送 0
-
如果您尝试从推送控制台执行相同的查询,会发生什么?问题可能出在 queryInstallation 中,不是吗?
-
是的,它从推送控制台发送推送
-
如何从控制台发送推送?即,您的细分目标是什么
标签: ios xcode parse-platform push-notification