OGeek|极客世界-中国程序员成长平台

标题: ios - 使用 parse [Parse IOS] 从移动设备向特定用户发送推送通知 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 11:01
标题: ios - 使用 parse [Parse IOS] 从移动设备向特定用户发送推送通知

我已将用户指针保存在安装类中。 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 对象),逻辑上它应该是通知的接收者。

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



Best Answer-推荐答案


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

Push Notification 文档中有一节谈到将数据添加到 Installation 类:

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

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






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4