【发布时间】:2017-08-16 15:20:23
【问题描述】:
我正在使用以下库来生成推送通知。
https://github.com/edamov/pushok
我得到了推送通知,但我不知道如何在 Swift 3 中提取响应。
这就是我所拥有的。
// Push notification received
func application(_ application: UIApplication, didReceiveRemoteNotification data: [AnyHashable : Any]) {
// Print notification payload data
print("Push notification received: \(data)")
let aps = data[AnyHashable("aps")]!
print(aps)
}
我可以创建推送通知,控制台消息有效,但打印出来...
Push notification received: [AnyHashable("samplekey"): samplevalue, AnyHashable("aps"): {
alert = {
body = hey;
title = "Hello!";
};
sound = default;
}]
{
alert = {
body = hey;
title = "Hello!";
};
sound = default;
}
所以我的问题是如何访问警报中的“正文”和“标题”数据?
我尝试访问变量,但我不断收到错误,因为我不确定我应该如何访问它,并且在任何教程中都找不到有关此主题的任何文档。
【问题讨论】:
-
您能否分享示例代码,因为我是 laravel 中
push-notification的新手
标签: ios push-notification swift3 apple-push-notifications ios10