Ios 解析不发送推送通知的高级目标
我正在使用高级定位和解析。在Parse仪表板上,它显示通知已成功发送,但在仪表板中单击通知时,它没有显示发送给谁。我也在App Delegate中正确设置了我的PFInstallation。以下是我发送通知的代码:Ios 解析不发送推送通知的高级目标,ios,swift,parse-platform,notifications,Ios,Swift,Parse Platform,Notifications,我正在使用高级定位和解析。在Parse仪表板上,它显示通知已成功发送,但在仪表板中单击通知时,它没有显示发送给谁。我也在App Delegate中正确设置了我的PFInstallation。以下是我发送通知的代码: let message = "\(PFUser.currentUser()?.username) has invited you to a match!" let username = defender let query = PFInstallation.
let message = "\(PFUser.currentUser()?.username) has invited you to a match!"
let username = defender
let query = PFInstallation.query()!
query.whereKey("username", equalTo: username)
let push = PFPush()
push.setQuery(query)
push.setMessage(message)
push.sendPushInBackgroundWithBlock { (success: Bool, error: NSError?) -> Void in
if error == nil && success{
print("push notification sent to user \(defender)!")
}
}
Username是目标用户名。仪表板将用户名显示为键。以下是推送通知的详细信息:
推送详细信息
推送ID
hOX5Ulhcds
瞄准
用户名为“”
发送时间
2015年12月21日下午2:02
到期日
没有
全部目标
{
“用户名”:”
}
完整数据
{
“警报”:“可选(\“John Cena\”)已邀请您参加比赛!”
}
这是用户登录或注册时我运行的代码:
let currentInstallation = PFInstallation.currentInstallation()
currentInstallation["username"] = PFUser.currentUser()?.username
currentInstallation.saveInBackground()
如何使代码工作?安装是否具有名为username的属性?@danh是的。它是一根绳子。