Reputation: 4265
I'm searching for a way to implement background geolocation support on iOS without that the app getting terminated by OS and stopping the tracking of the device. In my application I'm using these two plugins to get geolocation support in the background:
https://github.com/katzer/cordova-plugin-background-mode
and https://github.com/apache/cordova-plugin-geolocation
But after the app is a while in the background the app gets terminated by iOS and isn't sending any tracking points.
I already found this plugin for our purpose:
https://github.com/transistorsoft/cordova-background-geolocation-lt
But this plugin even tracks the geolocation even if the app gets terminated by the user manually, so I think there might be a hack or something like that so it wouldn't pass the iOS testing phase.
So how do I achieve this without any hacks?
Upvotes: 2
Views: 1275
Reputation: 153
I'm the creator of Cordova-background-geolocation
There's no hack involved here and the plugin is 100% compatible with Apple guidelines. The plugin's ability to keep tracking on app terminate / device reboot is granted simply because iOS itself persists listeners on geofences. The plugin subscribes to a geofence around the last known position while in stationary mode. When the app is terminated, the plugin, in its last dying breath, simply ensured a geofence exists around the last known position.
In addition, the plugin also subscribes to the iOS Background Fetch API, another API which iOS persists in spite of app terminate / device reboot.
No magic here.
Upvotes: 1