Swift Parse:如何将通知推送到特定设备/ objectId [英] Swift Parse : How to Push Notification To a Specific Device/objectId

查看:67
本文介绍了Swift Parse:如何将通知推送到特定设备/ objectId的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将通知推送到我的用户表中的特定用户,但我的功能不起作用,我不明白为什么。

i'm trying to push notification to a specific user in my User Table, but my function didn't work and i don't understand why.

func testPush(){
    let message = "Alert !!"
    let id = "88yhi9j0"

    var data = [ "title": "Some Title",
        "alert": message]

    var userQuery: PFQuery = PFUser.query()
    userQuery.whereKey("objectId", equalTo: id)
    var query: PFQuery = PFInstallation.query()
    query.whereKey("currentUser", equalTo: userQuery)

    var push: PFPush = PFPush()
    push.setQuery(query)
    push.setData(data)
    push.sendPushInBackground()
}

有没有人有想法?

推荐答案

问题在于:

query.whereKey("currentUser", equalTo: userQuery)

应该是:

query.whereKey("currentUser", matchesQuery: userQuery)

我希望这能解决这个问题。

I hope this solves the issue.

这篇关于Swift Parse:如何将通知推送到特定设备/ objectId的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆