使用parse从移动设备向特定用户发送推送通知
我已经在instalation类中保存了用户指针。 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];
我的安装类确实有这个用户指针(友元对象),逻辑上它应该是通知的接收者。
AM我错过了什么? 任何build议将是伟大的。 感谢您宝贵的时间
只要您在名为user
的Installation
类中有一个名为Pointer<My_User>
并且实际上已经填充了它,那么您的代码应该可以工作。
推送通知文档中有一节介绍了如何将数据添加到Installation
类: