我正在实现推送工具包并在委托(delegate)方法“didReceiveIncomingPushWithPayload”中接收远程通知,但通知中心未显示该消息。我已检查我的设备“通知-> 应用程序”允许通知和在通知中心显示选项已启用。
最佳答案
如果您使用以下方法。
func pushRegistry(registry: PKPushRegistry!, didReceiveIncomingPushWithPayload payload: PKPushPayload!, forType type: String!)
然后,pushkit 有助于获得静默推送通知,远程通知不会像简单的 APNS 一样进入通知中心。
通过这种方法,当您收到包含所需信息的远程通知时,您现在必须安排 UILocalNotification
,它将进入通知中心。
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
if let notification:UILocalNotification = launchOptions?[UIApplicationLaunchOptionsLocalNotificationKey] as? UILocalNotification {
}
}
即使您可以将 UILocalNotification 对象保留在 NSUserDefault 中,因此您可以在 didFinishLaunchingWithOptions 中检索它,以防用户设备正在重启并且通知信息非常重要。
关于ios - 我正在使用推送套件并接收消息,但通知中心未显示该消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39202529/