斯威夫特解析推高级定位不发送 [英] Swift Parse Push advanced targeting not sending

查看:180
本文介绍了斯威夫特解析推高级定位不发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

遵循解析文档高级定位和推送通知仍然不发送。 (从parse的控制台和客户端推送启用我可以接收推。)

Followed the documentation for Parse advanced targeting and push notifications are still not sending. (I can receive pushes from Parse's console and client push is enabled.)

let userQuery: PFQuery = PFUser.query()!
userQuery.whereKey("objectId", equalTo: "JrePAMWUbm") // The user I am logged in with

let pushQuery: PFQuery = PFInstallation.query()!
pushQuery.whereKey("user", matchesQuery: userQuery)

let push = PFPush()
push.setQuery(pushQuery)
push.setMessage("Hello, World!")

push.sendPushInBackgroundWithBlock {
  success, error in

  if success {
    println("The push succeeded.")
  } else {
    println("The push failed.")
  }
}

我不断收到推成功了。不过,我看推送细节,和它说:0推发送。

I keep getting "The push succeeded." But I look at Push Details, and it says "0 Pushes Sent."

如果我删除userQuery并且只使用一个PFInstallation查询,我收到通知。

If I remove the userQuery and only use a PFInstallation query, I receive a notification.

let pushQuery: PFQuery = PFInstallation.query()!
pushQuery.whereKey("deviceType", equalTo: "ios")

let push = PFPush()
push.setQuery(pushQuery)
push.setMessage("Hello, World!")

push.sendPushInBackgroundWithBlock(nil)

东西可能是错误的 userQuery ,但我不知道是什么。返回类型与 pushQuery.whereKey兼容(用户,matchesQuery:userQuery)?

Something is likely wrong with userQuery, but I'm not sure what. Return type isn't compatible with pushQuery.whereKey("user", matchesQuery: userQuery)?

推荐答案

以上一切都设置正确。

我的安装 用户列并没有与我的用户关联 - 我不得不添加以下内容:

My Installation user column was not associating with my users -- I had to add the following:

let installation = PFInstallation.currentInstallation()
installation["user"] = PFUser.currentUser()
installation.saveInBackground()

这<一个href=\"https://groups.google.com/forum/#!searchin/parse-developers/user$20installation$20query/parse-developers/gLH2DRgNe90/nYjs0QiyhasJ\"相对=nofollow>帖子帮助。

这篇关于斯威夫特解析推高级定位不发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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