Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/122.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 解析:向用户发送推送通知_Ios_Parse Platform - Fatal编程技术网

Ios 解析:向用户发送推送通知

Ios 解析:向用户发送推送通知,ios,parse-platform,Ios,Parse Platform,我正在尝试向用户或所有用户的列表发送推送通知。我可以使用以下代码片段在ios设备上成功发送(和接收): // Create our Installation query PFQuery *pushQuery = [PFInstallation query]; [pushQuery whereKey:@"deviceType" equalTo:@"ios"]; // Send push notification to query [PFPush sendPushMessageToQueryInB

我正在尝试向用户或所有用户的列表发送推送通知。我可以使用以下代码片段在ios设备上成功发送(和接收):

// Create our Installation query
PFQuery *pushQuery = [PFInstallation query];
[pushQuery whereKey:@"deviceType" equalTo:@"ios"];

// Send push notification to query
[PFPush sendPushMessageToQueryInBackground:pushQuery
                               withMessage:@"Hello World!"];
但这段代码不起作用:

PFQuery *userQuery = [PFUser query];
NSLog(@"findObjects: %@",[userQuery findObjects]);

[userQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    NSLog(@"findObjectsInBackgroundWithBlock error: %@", error);
    NSLog(@"findObjectsInBackgroundWithBlock objects: %@", objects);   //this log indicated I do have one user named "user name"
}];

    PFQuery *pushQuery = [PFInstallation query];
//    [pushQuery whereKey:@"user" matchesQuery:userQuery];
    [pushQuery whereKey:@"username" containsString:@"user name"];   //neither one of these works


// Send push notification to query
[PFPush sendPushMessageToQueryInBackground:pushQuery
                               withMessage:@"for you only"];
在parse.com站点的推送通知仪表板上,其状态为“完成”,但订阅服务器为0

有什么建议吗

编辑:来自Parse仪表板的更多详细信息:


您必须像现在这样使用PFUser查询来查询您的用户。找到要向其发送推送的用户后,必须使用该“PFUser对象”进行安装查询。(您应该使用整个PFUser对象作为安装查询的键)

如果要向一组用户发送推送,则必须设置Parse的“段”,并将用户分配给该段。阅读解析iOS推送文档

以下是向单个用户发送推送的示例:

PFQuery *qry = [PFUser query];
                [qry getObjectWithId: THE USERS OBJECT ID HERE ];

                PFQuery *pushQuery = [PFInstallation query];
                [pushQuery whereKey:@"user" matchesQuery:qry];

                // Send push notification to query
                PFPush *push = [[PFPush alloc] init];
                [push setQuery:pushQuery]; // Set our Installation query
                NSDictionary *data = [NSDictionary dictionaryWithObjectsAndKeys:
                                      @"A New Push Message was Put HERE!", @"alert",
                                      @"ursound.caf", @"sound",
                                      @"Increment", @"badge",
                                      @"Optionally a type was set", @"type",
                                      nil];
                [push setData:data];


                [push sendPushInBackground];

Edit-Oh和我的示例中的那些初始查询假定已经在后台任务->使用getObjectInBackgroundHithid:^(bla bla..)中,如果不在后台任务中运行此命令

您必须像现在这样使用PFUser查询来查询您的用户。找到要向其发送推送的用户后,必须使用该“PFUser对象”进行安装查询。(您应该使用整个PFUser对象作为安装查询的键)

如果要向一组用户发送推送,则必须设置Parse的“段”,并将用户分配给该段。阅读解析iOS推送文档

以下是向单个用户发送推送的示例:

PFQuery *qry = [PFUser query];
                [qry getObjectWithId: THE USERS OBJECT ID HERE ];

                PFQuery *pushQuery = [PFInstallation query];
                [pushQuery whereKey:@"user" matchesQuery:qry];

                // Send push notification to query
                PFPush *push = [[PFPush alloc] init];
                [push setQuery:pushQuery]; // Set our Installation query
                NSDictionary *data = [NSDictionary dictionaryWithObjectsAndKeys:
                                      @"A New Push Message was Put HERE!", @"alert",
                                      @"ursound.caf", @"sound",
                                      @"Increment", @"badge",
                                      @"Optionally a type was set", @"type",
                                      nil];
                [push setData:data];


                [push sendPushInBackground];

Edit-Oh和我的示例中的那些初始查询假定已经在后台任务->使用getObjectInBackgroundHithid:^(bla bla..)中,如果不在后台任务中运行此命令

事实证明,要接收单个推送通知,接收方应用程序也需要这样做(登录后):


事实证明,要接收单个推送通知,接收方应用程序也需要这样做(登录后):


我尝试使用findObjectsInBackgroundWithBlock,获取返回对象中的第一个对象,然后将其输入getObjectInBackgroundWithId:aUser.objectId。并直接使用GetFirstObjectInBackgroundithBlock,但仍然不起作用。何时仪表板中的“订阅者”状态将显示除0以外的数字?从仪表板添加了更多详细信息。我尝试使用findObjectsInBackgroundWithBlock,获取返回对象中的第一个对象,然后将其输入getObjectInBackgroundWithId:aUser.objectId。并直接使用GetFirstObjectInBackgroundithBlock,但仍然不起作用。何时仪表板中的“订阅者”状态将显示除0以外的数字?从仪表板中添加了更多详细信息。