ios-background-mode

Is it possible to execute something on main thread after didEnterBackground is called?

女生的网名这么多〃 提交于 2020-08-09 19:34:08
问题 First of all I'd like to say sorry in case you consider my question dummy, I'm new to iOS and multithreading and just want to understand how things are going on. As far as I know didEnterBackground is the last function that iOS calls before app suspension and the app has about 5 secs to return from it otherwise iOS will kill the app. I'm currently thinking about such a situation - I have some task that is happening on the background thread(e.g. network download) and its completion block

iOS - Background Services when app is terminated

混江龙づ霸主 提交于 2020-06-26 07:28:12
问题 Do background mode functions like Background fetch and Location update work if the app is terminated? Or it only works if the app enters background? Thanks 回答1: Yes, it works (most of the time), if you set up everything correctly and have the permissions. Your app need's to be launched at least 1 time, so it can subscribe to the updates. For background fetch, set UIApplication.shared.setMinimumBackgroundFetchInterval(3600) at the didFinishLaunching method, implement the

iOS 13 - Using BGTaskScheduler doesn't work all the time

天涯浪子 提交于 2020-05-29 04:04:53
问题 THE PROBLEM: I want to run a simple function, 5 seconds after app goes into background. I had to implement BGTaskScheduler, to support iOS 13. The old implementation for BackgroundTask works for me on older iOS versions. I added background modes as requested (BLE accessories is ticked because we perform a small BLE operation in this function): Then, I prepared the Info.plist according to the docs ( Identifier is fake just for StackOverflow question): Before didFinishLaunchingWithOptions is

iOS 13 - WkWebView: audio stops when in background

倖福魔咒の 提交于 2020-05-09 17:57:46
问题 I've an app that uses WkWebView to play audio from Soundcloud, on iOS 13 Beta 6 the audio stops when the app is not in foreground, even when Audio is on in Background Modes . When starting the playback this assertions is thrown: Error acquiring assertion: <NSError: 0x282cf67c0; domain: RBSAssertionErrorDomain; code: 2; reason: "Required client entitlement is missing"> { userInfo = { RBSAssertionAttribute = <RBSLegacyAttribute: 0x1592432e0; requestedReason: MediaPlayback; reason: MediaPlayback

Timers not running when screen is turned off / device is locked in iOS

☆樱花仙子☆ 提交于 2020-01-04 02:56:10
问题 The app is in the background and it receives a callback upon disconnection with the BLE device, after which the app has to wait for sometime(1minute) and then execute some piece of code. The app behaves as expected even when in the background if the screen is turned on. But if the screen is turned off then the timer is not working and the app is not executing as expected. This is the code in AppDelegate to start a timer in background: func startTimerWith(timeInterval: TimeInterval) {

Keeping the app in background mode for continuos location updates

跟風遠走 提交于 2020-01-02 12:26:41
问题 My project is using a CLLocationManager object, receiving updates via: locationManager:didUpdateToLocations: I want these updates even though my app is in the background. So in info.plist i have set the, "Required background modes" list to App registers for location updates. But my testing shows that it does not receive the updates in background state. However, i'm not sure i'm having the correct perception of background state/ suspended state. This is how i think it works: After the home

How to continue tracking location after the user restarts the phone?

大憨熊 提交于 2019-12-23 12:27:30
问题 My application need to post the location data to my backend. I have set the location permissions to always and set the pausesLocationUpdatesAutomatically to false for CLLocationManager and need to continue tracking the phones location even when the application is in background or after the phone is restarted. I'm able to make it work when the application is in background mode. But it stops working when the phone is restarted. How can I do this? By the way, I know the 回答1: This is WELL

iOS 12 terminates apps in the background for no reason

雨燕双飞 提交于 2019-12-17 17:33:39
问题 Starting from iOS 12 the CLLocationManager doesn't run endless anymore in the background. The app get's terminated without a crashlog at random times. This was working fine before iOS 12. To demonstrate this problem I've created an sample app here The demo app just launches an CLLocationManager and keep this running in the background. While running on the background we keep track of it by logging it. The problem is that the app get terminated by iOS. The demo app is created to demonstrate

UIPasteboard returns nil in the background

久未见 提交于 2019-12-11 15:57:10
问题 I am trying to read the Pasteboard for 5 times in the applicatioDidEnterBackground section of the AppDelegate. To print the string I use print(UIPasteboard.general.string!) but it works only into the function and it doesn't in the other nested functions. Let me explain: func applicationDidEnterBackground(_ application: UIApplication) { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application

Background location service stops working in a period of time

感情迁移 提交于 2019-12-08 08:12:51
问题 I'm developing an iOS application that users can save their traveling route to server (by posting their locations through API). The issue I am struggling with is several users reported that the route they saved is interrupted in the middle of the trip. In detail, when users review their saved route on map, there is a part of route being just a straight line because somehow locations of that route section are not sent to server or just because the device can not receive locations at that time.