问题描述
我正在使用后台任务在后台运行计时器以更新用户的位置.它被声明为:
I am using background task to run the timer in the background to update the user's location. It's declared as:
UIBackgroundTaskIdentifier bgTask;
在头文件中,并初始化为:
in the header file, and initialized as:
bgTask = UIBackgroundTaskInvalid;
但是,我仍然在 gdb 中收到此消息:
But still, I am getting this message in the gdb:
无法结束BackgroundTask:不存在标识符为 23dc 的后台任务,或者它可能已经结束.中断 UIApplicationEndBackgroundTaskError() 进行调试.
为什么?我该如何解决这个问题?
Why? And how can I solve this?
推荐答案
我花了很多天时间寻找导致调试控制台中出现此警告的代码或框架 无法结束 BackgroundTask:没有后台任务存在标识符 2 (0x2),或者它可能已经结束.中断 UIApplicationEndBackgroundTaskError() 进行调试.
I lose many days looking for the piece of code or framework that was causing this warning in the debug console Can't end BackgroundTask: no background task exists with identifier 2 (0x2), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.
最后我创建了一个空项目Single View App.只有由 Xcode 生成的代码,我在模拟器上运行应用程序,将其置于后台,我看到相同的警告.所以我可以说这是一个 iOS 13 问题.我希望 Apple 能尽快修复它,因为在 Crashlytics 中,我发现我的应用程序出现了一些由它引起的崩溃.
Finally I've created an empty project Single View App. Only code generated by Xcode, I run the app on simulator, put it in background and I see the same warning.So I can say it's an iOS 13 issue.I hope Apple will fix it quickly because in Crashlytics I found some crash in my app caused by it.
这篇关于Can't endBackgroundTask: 不存在带有标识符的后台任务,或者它可能已经结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!