Swift Parse Push 高级定位不发送 [英] Swift Parse Push advanced targeting not sending

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

问题描述

遵循 有帮助.

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.")
  }
}

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

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)

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

解决方案

Everything above is set up correctly.

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()

This post helped.

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

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