【问题标题】:Sending Push Notification from mobile to particular user using parse [Parse IOS]使用 parse [Parse IOS] 从移动设备向特定用户发送推送通知
【发布时间】:2014-08-06 12:35:06
【问题描述】:

我已将用户指针保存在安装类中。 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];

我的安装类确实有这个用户指针(朋友对象),逻辑上它应该是通知的接收者。

我错过了什么吗?任何建议都会很棒。感谢您宝贵的时间

【问题讨论】:

  • 请再次发布您的答案

标签: ios push-notification parse-platform parse-framework


【解决方案1】:

只要您在 Installation 类中有一个名为 user 类型为 Pointer<My_User> 的列,并且您已经实际填充了它,您的代码就应该可以工作。

推送通知文档中有一个部分讨论了将数据添加到 Installation 类:

https://parse.com/docs/push_guide#sending-queries/iOS

【讨论】:

  • 我的安装类确实有指向用户类的指针,我可以从移动设备发送推送通知。但未收到通知(我的意思是订阅者 0 )正在解析后端显示。
  • 我已经编辑了我的问题并添加了详细信息。现在解析服务器,显示通知正在发送但 0 个订阅者。
  • 您的Installation 类“用户”列的类型为Pointer<TBUser>,但您的查询将其与内置的用户类进行比较,因此期待Pointer<_User>
  • 数以百万计的感谢。我已经修改了我的查询,现在可以正确接收推送通知。 PFQuery *qry = [PFQuery queryWithClassName:@"TBUser"]; [qry whereKey:@"objectId" equalTo:friendObject.objectId]; PFQuery *pushQuery = [PFInstallation 查询]; [pushQuery whereKey:@"user" matchesQuery:qry];
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-05-17
  • 1970-01-01
  • 1970-01-01
  • 2016-03-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多