我正在努力获得"警报"但没有太多运气。
LazyMapCollection<Dictionary<AnyHashable, Any>, AnyHashable>(_base: [AnyHashable("google.c.a.e"): 1, AnyHashable("google.c.a.ts"): 1475009164, AnyHashable("google.c.a.udt"): 0, AnyHashable("gcm.n.e"): 1, AnyHashable("aps"): {
alert = "test message";
}, AnyHashable("google.c.a.c_id"): 9039575328704479116, AnyHashable("gcm.message_id"): 0:1475009164740581%df6f7f01df6f7f01], _transform: (Function))
这是代码是使用但它无法正常工作
if (userInfo["aps"] != nil) {
let msg = (userInfo["alert"] as? String)!
let alert1 = UIAlertController(title: "Notification", message: msg, preferredStyle: .alert)
alert1.addAction(UIAlertAction(title: "Ok", style: .default, handler: { (action) -> Void in
}))
self.window?.rootViewController?.present(alert1, animated: true, completion: nil)
completionHandler(.newData)
}
我正在尝试使用值alert的消息显示本地通知。任何想法,将不胜感激。谢谢
答案 0 :(得分:0)
这是我的工作解决方案
if (userInfo["aps"] != nil) {
if let notification = userInfo["aps"] as? NSDictionary,
let alert = notification["alert"] as? String {
let alert1 = UIAlertController(title: "Notification", message: alert, preferredStyle: .alert)
alert1.addAction(UIAlertAction(title: "Ok", style: .default, handler: { (action) -> Void in
}))
self.window?.rootViewController?.present(alert1, animated: true, completion: nil)
completionHandler(.newData)
}
}