解析:推送通知可以通过Everyone发送,但不能通过Segment发送

时间:2015-01-21 05:49:45

标签: ios iphone parse-platform push-notification

我正在构建一个聊天应用,并希望在一个用户向另一个用户发送消息时发送推送通知。

我通过从我的模拟器向我的iPhone发送消息来测试它,但它无法接收它。 Parse仪表板看起来像: enter image description here

然后我通过仪表板向所有人发送消息来测试它,它可以工作,我的iPhone收到消息。请参阅下面的信息中心结果:

enter image description here

接下来,我尝试通过仪表板中的Segment发送消息,下面是我的设置屏幕的屏幕截图,注意它说这将发送到1个设备

enter image description here

然而,我的手机也没有收到它。以下是仪表板中新添加的行

enter image description here

由于推送通知是一个非常复杂的过程,我不知道我需要在这里提供哪些其他信息才能解决问题。 奇怪的是我的iPhone没有出现在安装数据表中。

-----------------------已添加---------------------

用户成功登录后,将运行以下代码:

var installation:PFInstallation = PFInstallation.currentInstallation()
                installation["user"] = PFUser.currentUser()
                installation.saveInBackgroundWithBlock(nil)

成功发送用户消息后,将运行以下代码:

var uQuery:PFQuery = PFUser.query()
                    uQuery.whereKey("username", equalTo: self.recipient)

                    var pushQuery:PFQuery = PFInstallation.query()
                    pushQuery.whereKey("user", matchesQuery: uQuery)

                    var push:PFPush = PFPush()
                    push.setQuery(pushQuery)
                    push.setMessage("您有新的消息")
                    push.sendPushInBackgroundWithBlock({ (success: Bool, error:NSError!) -> Void in
                        if success {
                            println("push sent")
                        }else{
                            println("send push failed")
                        }
                    })

在控制台中,我总能看到“推送已发送”

我不确定我是否在聊天应用中发送推送通知的最佳做法。任何建议都表示赞赏。

--------------更新-------------------------------- ---

我的问题现在已经解决了,但我不记得我采取了什么来解决它,只是以一种特殊的方式。谢谢大家的评论。

0 个答案:

没有答案
相关问题