我已将用户指针保存在安装类中。 Web 后端显示 0 个订阅者
我使用下面的代码发送通知
PFQuery *qry = [PFUser query];
[qry getObjectWithId:friendObject.objectId]; //friend object is ok like @"Fefl5x7nhl"
PFQuery *pushQuery = [PFInstallation query];
[pushQuery whereKey:@"user" matchesQuery:qry];
// Send push notification to query
PFPush *push = [[PFPush alloc] init];
NSString *msgString=[NSString stringWithFormat:@"%@ :%@",
[newMessage objectForKey:@"userName"],
tfEntry.text];
[push setQuery:pushQuery]; // Set our Installation query
NSDictionary *data = [NSDictionary dictionaryWithObjectsAndKeys:
msgString, @"alert",
@"ursound.caf", @"sound",
@"Increment", @"badge",
// @"Optionally a type was set", @"type",
nil];
[push setData:data];
[push sendPushInBackground];
我的安装类确实有这个用户指针( friend 对象),从逻辑上讲它应该是通知的接收者。
我错过了什么吗?任何建议都会很棒。感谢您宝贵的时间
最佳答案
只要你有一个关于Installation
的专栏类名为 user
其类型为Pointer<My_User>
并且您实际上已经填充了它,您的代码应该可以工作。
推送通知文档中有一节讨论了将数据添加到 Installation
类:
关于ios - 使用解析从移动设备向特定用户发送推送通知 [Parse IOS],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25160595/