rolinger opened a new issue, #289:
URL: https://github.com/apache/cordova-plugin-geolocation/issues/289
# Bug Report
As the title explains, on iOS if your app has watchPosition enabled and
tracking user movement and the user puts your app in the background, later when
the app comes back to the foreground watchPosition does not resume. It does
auto-resume on Android.
### What is expected to happen?
On iOS, for watchPosition to resume tracking the users position when app is
restored to foreground.
### What does actually happen?
watchPosition fails to reactivate
## Information
<!-- Include all relevant information that might help understand and
reproduce the problem -->
On Android, wathcPosition automatically restarts. But for iOS I had to add
this code in my device.ready() :
```
document.addEventListener("resume", onResume, false);
function onResume() {
// Handle the resume event
if (ionic.Platform.isIOS()) {
// gpsInfo.gpsEnbaled = user had already enabled GPS
// gpsInfo.gpsTrackingEnabled = watchPosition() had already been
initiated
// gpsInfo.watchID = current instance of active watchPosition()
if (gpsInfo.gpsEnabled == true && gpsInfo.gpsTrackingEnabled ==
true) {
// if a previous watchID still exists, then kill it.
if (gpsInfo.watchID != null) {
gpsPositionTracking(0) ; // kill existing watchID if exists
}
// restart watchPosition()
gpsPositionTracking(1) ; // restart positionTracking
}
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]