无法endBackgroundTask:不存在带有标识符的后台任务,或者它可能已经结束 [英] Can't endBackgroundTask: no background task exists with identifier, or it may have already been ended

查看:1683
本文介绍了无法endBackgroundTask:不存在带有标识符的后台任务,或者它可能已经结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用后台任务在后台运行计时器以更新用户的位置.声明为:

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:

不能endBackgroundTask:不存在标识符为23dc的后台任务,或者它可能已经结束.中断UIApplicationEndBackgroundTaskError()进行调试.

Can't endBackgroundTask: no background task exists with identifier 23dc, or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.

为什么?而我该如何解决呢?

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问题. 我希望苹果能够迅速修复它,因为在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.

这篇关于无法endBackgroundTask:不存在带有标识符的后台任务,或者它可能已经结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆