gpt4 book ai didi

ios - 推送通知在 UIApplication LaunchOptions RemoteNotificationKey 中不起作用

转载 作者:搜寻专家 更新时间:2023-11-01 07:19:43 24 4
gpt4 key购买 nike

因为我更新了我的 AppDelegate 类中的所有 Notification 方法。 PushNotification 在应用打开和关闭模式时接收。当我的应用程序关闭并收到通知并尝试点击通知时,我遇到了这个问题,它打开了应用程序屏幕,但是这些代码行没有被调用:

let remoteNotification: NSDictionary! = launchOptions?[UIApplicationLaunchOptionsRemoteNotificationKey] as? NSDictionary
print("remoteNotification = \(remoteNotification)")
if (remoteNotification != nil) {
print("***************************************\n\n\n\n\n launchOptions = \(launchOptions)\n ***************************************\n\n\n\n\n")

self.notificationHandlingFunction(remoteNotification)
}

当我想查看日志时,它不会出现在 Log 列表中:

enter image description here

我的设备连接了 Xcode 但没有运行。在代码中我打印 RemoteNotification 但是当我搜索这个关键字时它没有显示。我在 Swift 中遇到了这个问题。

出现这种情况时,如何管理我的Notification 方法。

最佳答案

转到项目>功能,打开后台模式并启用远程通知

enter image description here

然后在 app delegates 中简单地添加以下方法

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
self.notificationHandlingFunction(remoteNotification)
}

适用于所有情况

关于ios - 推送通知在 UIApplication LaunchOptions RemoteNotificationKey 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39912802/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com