I implemented a function to open an AlertView when I receive a remote notification like this:
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]){
var notifiAlert = UIAlertView()
var NotificationMessage : AnyObject? = userInfo["alert"]
notifiAlert.title = "TITLE"
notifiAlert.message = NotificationMessage as? String
notifiAlert.addButtonWithTitle("OK")
notifiAlert.show()
}
But NotificationMessage is always nil.
My json payload looks like this:
{"aps":{"alert":"Testmessage","badge":"1"}}
我正在使用Xcode6,SWIFT,我正在为iOS8开发. 我找了好几个小时了,但没有找到任何有用的信息. 通知工作正常.如果我单击它,alert 视图将打开. 我的问题是,我无法从userInfo中获取数据.