2016-09-27 11 views
0

私は "警告"の価値を得ようとしていますが、運があまりありません。iOS Swift Getting Lazy Map Collection Values

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

動作しない私は、値警告のメッセージとローカル通知を表示しようとしています。任意のアイデアをいただければ幸いです。何を意味「正常に動作しない」んあなた

+1

のですか?それは何をし、何をすることを期待していますか?そして、この 'LazyMapCollection'はその下のコードにどのように関連していますか? –

+0

通知に「テストメッセージ」である「警告」の値を表示しようとしています。このコード行は例外をスローしますmsg =(userInfo ["alert"]?String)! –

答えて

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) 

        } 
       }