崩溃didReceiveRemoteNotification

问题描述 投票:0回答:1

碰撞是发生在现场的应用。我无法获取崩溃日志。我可以看到下面的Organizer->崩溃,点击它带我到下面的行如下所述。如何调试这个崩溃或预防呢?

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 
}
ios swift
1个回答
0
投票

我不明白你为什么只检查rootViewControllerUITabBarController。但我认为,暴跌是因为你不叫completionHandler。尝试在方法的末尾添加:

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

从苹果的文档:

只要处理完的通知,则必须调用处理器参数块或您的应用程序将被终止。您的应用的挂钟时间长达30秒的处理通知,并调用指定的完成处理程序块。在实践中,你应该尽快调用处理程序块,你都做了处理通知。该系统跟踪所经过的时间,用电量,并为您的应用程序的后台下载数据的成本。处理远程通知时使用显著的功率的应用可能不总是被唤醒早来处理将来的通知。

检查苹果documentation

© www.soinside.com 2019 - 2024. All rights reserved.