gpt4 book ai didi

swift - iOS Swift 获取惰性 map 集合值

转载 作者:行者123 更新时间:2023-11-30 13:02:50 25 4
gpt4 key购买 nike

我正在尝试获取“alert”的值,但运气不太好。

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

我正在尝试显示带有值警报消息的本地通知。任何想法,将不胜感激。谢谢

最佳答案

这是我的工作解决方案

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)

}
}

关于swift - iOS Swift 获取惰性 map 集合值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39734141/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com