2016-09-27 5 views
0

나는 "경고"에 대한 가치를 얻으려고하지만별로 운이 없다.iOS Swift 게으른지도 수집 값 가져 오기

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) 

        } 
       }