Swiftparsing推送高级定位不发送
遵循Parse高级定位和推送通知的文档仍然没有发送。 (我可以从Parse的控制台接收推送,并启用客户端推送。)
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推送”。
如果我删除userQuery并只使用PFInstallation查询,我收到通知。
let pushQuery: PFQuery = PFInstallation.query()! pushQuery.whereKey("deviceType", equalTo: "ios") let push = PFPush() push.setQuery(pushQuery) push.setMessage("Hello, World!") push.sendPushInBackgroundWithBlock(nil)
用户查询可能有问题,但我不确定是什么。 返回types与pushQuery.whereKey("user", matchesQuery: userQuery)
不兼容?
以上所有内容都正确设置。
我的Installation
user
列没有与我的用户关联 – 我不得不添加以下内容:
let installation = PFInstallation.currentInstallation() installation["user"] = PFUser.currentUser() installation.saveInBackground()
这个post有帮助。