次のようなリモート通知を受け取ったときに AlertView を開く関数を実装しました。
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()
}
ただし、NotificationMessage は常に nil です。
私のjsonペイロードは次のようになります。
{"aps":{"alert":"Testmessage","badge":"1"}}
Xcode 6、Swift を使用しており、iOS8 向けに開発しています。何時間も検索しましたが、有益な情報は見つかりませんでした。通知は完全に機能します..クリックすると、アラートビューが開きます。私の問題は、userInfo からデータを取得できないことです。