使用解析[Parse IOS]从移动设备向特定用户发送推送通知 [英] Sending Push Notification from mobile to particular user using parse [Parse IOS]
问题描述
我已将用户指针保存在安装类中. Web后端显示0个订阅者
I have saved user pointer in instalation class. Web backend shows 0 subscribers
我正在使用以下代码发送通知
I am sending notification using below code
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];
我的安装类确实具有该用户指针(朋友对象),并且从逻辑上讲,它应该是通知的接收者.
My installation class does have this user pointer (friend object) and logically it should be receiver of the notification .
我错过了什么吗?任何建议都很好.感谢您的宝贵时间
AM i missing something? any suggestion would be great . Thanks for your valuable time
推荐答案
只要您在Installation
类上名为user
的列为Pointer<My_User>
类型,并且实际上已经填充了该列,代码应该可以工作.
As long as you have a column on the Installation
class called user
that is of type Pointer<My_User>
and you've actually populated it, your code should work.
推送通知"文档中有一节讨论将数据添加到Installation
类:
There's a section in the Push Notification documentation that talks about adding data to the Installation
class:
https://parse.com/docs/push_guide#sending-queries/iOS
这篇关于使用解析[Parse IOS]从移动设备向特定用户发送推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!