gpt4 book ai didi

push-notification - 解析,如何向目标用户发送推送通知

转载 作者:行者123 更新时间:2023-11-30 14:10:53 25 4
gpt4 key购买 nike

我已成功设置解析推送通知,并且在我的安装表中我同时拥有安装和设备 token 。我真正想做的是将推送通知发送给某些用户,而不是某些设备。如何将安装表绑定(bind)到使用表,以便我可以由用户进行查询并返回要推送到的设备ID

最佳答案

来自https://parse.com/docs/push_guide#top/iOS ,“使用高级定位”部分。

You can even create relationships between your Installation objects and other classes saved on Parse. To associate a PFInstallation with a particular user, for example, you can simply store the current user on the PFInstallation.

// 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];

关于push-notification - 解析,如何向目标用户发送推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31778910/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com