解析,如何向目标用户发送推送通知 [英] Parse, how to send push notification to targeted users

查看:90
本文介绍了解析,如何向目标用户发送推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功设置了解析推送通知,并且在我的安装表中同时包含安装和设备令牌.我真正想做的是向某些用户而不是某些设备发送推送通知.如何将安装表与使用"表结合在一起,以便我可以由用户进行查询并获取设备ID以推送到

I have successfully setup parse push notifications and in my installation table I have both an installation, and device token. What I'm really trying to do is send a push notification to certain users, rather than certain devices. How do I bing the installations table to the uses table, so that I can make a query by users and get back a deviceid to push to

推荐答案

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

From https://parse.com/docs/push_guide#top/iOS, section "Using Advanced Targeting".

您甚至可以在安装对象之间创建关系 和其他保存在Parse上的类.要将PFInstallation与 特定的用户,例如,您可以简单地将当前用户存储在 PFInstallation.

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

现在,您可以在安装表上创建查询,其中用户"是您要向其发送推送通知的用户.

Now you can create a query on the installation table, where "user" is the user you want to send a push notification to.

最后,在构造推入对象时使用该查询.

Finally, use that query when constructing the push object.

Objective-C中的示例(如果您以其他语言发送推送,则进行相应调整):

Example in Objective-C (adjust accordingly, if you're sending the push in some other language):

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

这篇关于解析,如何向目标用户发送推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆