我已成功设置解析推送通知,并且在我的安装表中我同时拥有安装和设备令牌。我真正想做的是将推送通知发送给某些用户,而不是某些设备。如何将安装表绑定到使用表,以便我可以由用户进行查询并返回要推送到的设备ID
From https://parse.com/docs/push_guide#top/iOS https://parse.com/docs/push_guide#top/iOS,“使用高级定位”部分。
您甚至可以在安装对象之间创建关系
以及保存在 Parse 上的其他类。将 PFInstallation 与
特定用户,例如,您可以简单地将当前用户存储在
PF 安装。
// Associate the device with a user
PFInstallation *installation = [PFInstallation currentInstallation];
installation[@"user"] = [PFUser currentUser];
[installation saveInBackground];
现在您可以在安装表上创建查询,其中“user”是您想要向其发送推送通知的用户。
最后,在构造推送对象时使用该查询。
Objective-C 中的示例(如果您使用其他语言发送推送,请进行相应调整):
PFQuery *pushQuery = [PFInstallation query];
[pushQuery whereKey:@"user" equalTo:someUser]; // where some user is the user object that is to receive a push notification
PFPush *push = [[PFPush alloc] init];
[push setQuery:pushQuery];
[push setMessage:@"Hi there!"];
[push sendPushInBackground];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)