iOS "prevent suspend" mode. Posted on 14 Feb 16:14 , 0 comments

iOS is far more strict when it comes to background operation than Android.  For an app which uses our Background Geolocation plugin, as soon as the plugin enters stationary mode, iOS will immediately suspend your app. In stationary-mode, the Background Geolocation plugin has created a geofence around the current position and iOS will not interrogate this geofence until a "significant-change" event occurs. A significant-change event is generated when the device changes cell-towers. This typically takes several urban city blocks of movement but can take a kilometer (or more, it depends on the nature of the network environment).

preventSuspend: true

When you configure the Background Geolocation plugin with preventSuspend: true, the plugin will prevent iOS from suspending your app (without using any hacks) and constantly monitor the accelerometer, allowing the Javascript in your app to run indefinitely. Since your app is constantly running in the background, the plugin is much more responsive with detecting "stationary" exit, typically requiring just a few meters of movement.

However, great care should be taken to manage preventSuspend mode since it will have a big impact on battery usage, since your app is constantly running in the background. This mode isn't meant to be used by everyone -- it should only be used in special cases (preferably applications where the phone is probably plugged into power) where the user is aware that your app is trading battery-power for tracking-responsiveness.