解析:如何从iOS应用程序向每个人发送推送通知?

时间:2014-09-07 10:23:20

标签: ios push-notification parse-platform

有没有办法直接从app向所有人发送推送通知,就像在控制台中一样? 如果我尝试下面的代码:

PFPush *push = [[PFPush alloc] init];
[push setMessage:@"Invio Push"];
[push sendPushInBackground];
看着安慰 它说已经发送给0个用户,并且它试图向所有人发送i / o频道。 如果我从控制台发送消息,我设法发送给每个人,没有问题 有没有办法从app获得相同的结果?

P.S。 自然如果我添加

PFPush *push = [[PFPush alloc] init];
[push setChannel:@"Mychannel"];
[push setMessage:@"Invio Push"];
[push sendPushInBackground];

推送通知正确发送到“Mychannel”频道

非常感谢 的Fabrizio

1 个答案:

答案 0 :(得分:0)

是的,您也可以直接从移动应用程序发送推送通知。请记住,您需要在Parse应用程序的设置选项卡中启用此功能,方法是选择“启用客户端推送?”标题下的“是”。可以调用几种方法来发送推送通知。

我的例子:

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

// Send push notification to query
[PFPush sendPushMessageToQueryInBackground:pushQuery 
                               withMessage:@"TEST1234"];
相关问题