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