2
我想在表格視圖中顯示多個(遠程)通知。 我的問題是,只有一條消息正在顯示。iOS處理多個推送通知
在我AppDelegate.swift我這有:
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]){
let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let rVC = storyboard.instantiateViewControllerWithIdentifier("PushVC")
let push = rVC as! PushVC
self.window!.rootViewController = rVC
if let aps = userInfo["aps"] as? NSDictionary {
if let alert = aps["alert"] as? NSDictionary {
if let message = alert["message"] as? NSString {
push.addPushNote(message as String)
}
} else if let alert = aps["alert"] as? NSString {
push.addPushNote(alert as String)
}
}
}
addPushNote是我的ViewController一個方法,將新通知添加到表視圖:
public func addPushNote(message: String){
pushNotes.append(message)
table.reloadData()
print(message)
}
當接收多條消息,打印(信息)顯示我所有 - 但只是第一個顯示。 我懷疑,對於每個推送通知,該消息都被添加到不同的PushVC實例。
任何幫助將不勝感激。
你是如何加載你的表視圖的其餘部分?或者你只希望有一個入口? – beyowulf