ios - 使用解析从移动设备向特定用户发送推送通知 [Parse IOS]

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

我已将用户指针保存在安装类中。 Web 后端显示 0 个订阅者 Response

我使用下面的代码发送通知

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

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

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

最佳答案

只要你有一个关于Installation的专栏类名为 user其类型为Pointer<My_User>并且您实际上已经填充了它,您的代码应该可以工作。

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

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

关于ios - 使用解析从移动设备向特定用户发送推送通知 [Parse IOS],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25160595/

相关文章:

ios - 加速、移动元素

ios - 使附件类型成为所选单元格的复选标记

ios - Ionic 3 + One Signal handleNotificationReceived 不会被触发

javascript - 如何使用 require 来组织我的代码

swift - 解析嵌套的完成处理程序

ios - 调用将 UIViewController 插入闭包内部的函数,就好像它在外面一样

ios - “AppDelegate”仅适用于 iOS 10.0 或更新版本

swift - XCode6 beta 6 Swift 编译器错误

Cordova PushPlugin 注册出现错误

ios - 从推送通知中提取 "alert"文本