Can't endBackgroundTask: no background task exists with identifier, or it may have already been ended

前端 未结 9 844
时光说笑
时光说笑 2020-11-27 02:42

I am using background task to run the timer in the background to update the user\'s location. It\'s declared as:

UIBackgroundTaskIdentifier bgTask;
         


        
9条回答
  •  星月不相逢
    2020-11-27 03:24

    Regarding the “Can’t end BackgroundTask: no background task exists with identifier ...” message, as others have said, this can be a red herring, unrelated to what you’re doing.

    Regarding your goal of trying to periodically retrieve the user’s location, rather than trying to keep your app running in the background with a timer, you should instead avail yourself of various services for updating the user location in the background, such as the visits location service or the significant change location service. With these services, the OS can wake your app when there is a change in the user’s location.

提交回复
热议问题