gpt4 book ai didi

ios - didReceiveRemoteNotification 中的崩溃

转载 作者:行者123 更新时间:2023-11-28 23:37:35 26 4
gpt4 key购买 nike

实时应用程序发生崩溃。我无法获取崩溃日志。我可以在“管理器”->“崩溃”中看到以下内容,单击它会将我带到下面提到的以下行。如何调试或防止此崩溃?

Crash in Organizer

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {

// Crash happens here
let tabBar:UITabBarController = self.window?.rootViewController as? UITabBarController
}

最佳答案

我不明白为什么你只检查rootViewControllerUITabBarController。但我认为,崩溃的发生是因为你没有调用completionHandler。尝试在方法末尾添加:

completionHandler(.noData) // or with other parameters of UIBackgroundFetchResult type.

来自 Apple 文档:

As soon as you finish processing the notification, you must call the block in the handler parameter or your app will be terminated. Your app has up to 30 seconds of wall-clock time to process the notification and call the specified completion handler block. In practice, you should call the handler block as soon as you are done processing the notification. The system tracks the elapsed time, power usage, and data costs for your app’s background downloads. Apps that use significant amounts of power when processing remote notifications may not always be woken up early to process future notifications.

检查苹果documentation

关于ios - didReceiveRemoteNotification 中的崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54496674/

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