I am using Ionic framework to develop my app, I've followed the documentation, everything works fine on Android; however on iOS it shows the blue bar that says that the app is tracking the current location on the background (only for the first 40 seconds), then that blue bar disappears and the app stop tracking the current location.
cordova -v): 7.0.1cordova platform ls): ios 4.4.0It should track the user current location in iOS even if the app goes to the background.
When going to the background, it shows the blue bar that says that the app is taking the current location on the background (only for the first 40 seconds), then that blue bar disappears and stop tracking the current location.
On the other hand, I have the same code working perfectly on Android devices, so I guess that there is an issue with the iOS.
Just follow the documentation on the following link : https://ionicframework.com/docs/native/background-geolocation/
Then run the app under iOS
Track drivers location and update the database of the current driver location each 10 seconds.
Same problem. Other people have been having running into the same issue as well.
I am also experiencing problems with tracking location after the app has been closed. Any new clues about this?
@gregor-srdic Yeah, this repo is no longer supported. There is a much better, working plugin here:
https://github.com/transistorsoft/cordova-background-geolocation-lt
Thanks. I managed to get this plugin working on the Android (the one you linked requires purchasing a license). I also managed to get this one working on iOS with debug mode on and some more conservative settings (larger desiredAccuracy, stationaryRadius and distanceFilter values and saveBatteryOnBackground: true) - it just returned some values after about a day of being in the background. I don't have the sim card in my iOS phone, so that might be affecting the behaviour as well.
I also prefer this plugin because it is included in the ionic native package I am working with, but if it does not work well, I will certainly try the one you linked for the iOS platform.
@gregor-srdic have you find any solution for IOS? I am also facing the same issue
Actually I got it working, but not sure what was the solution. Could be the config:
const config: BackgroundGeolocationConfig = {
desiredAccuracy: 100,
stationaryRadius: 20,
distanceFilter: 20,
debug: false,
stopOnTerminate: false,
maxLocations: 1,
httpHeaders: { 'X-FOO': '...'},
url: 'https://...',
// android only
interval: 60 * 1000,
startOnBoot: true,
startForeground: false,
// iOS only
pauseLocationUpdates: false,
saveBatteryOnBackground: true
};
@gregor-srdic it did not work :( I think maybe this plugin is not supporting ios 11 . .. If anyone has solution for it please share me .. I just want to track in IOS when APP is killed or in background
I haven't tested on iOS 11 yet, will let you know if it seems to work in my app ...
@laddhadhiraj, look at this fork: https://github.com/iMarvinS/cordova-plugin-background-geolocation
I tried it, but it not work on app kill, I am making a app which will be
track user and also want to know if user turn off gps when app kill. , Is
it possible through this background location plugin in ionic 2
On Wed, Oct 18, 2017 at 1:37 PM, s-perfilev notifications@github.com
wrote:
@laddhadhiraj https://github.com/laddhadhiraj, look at this fork:
https://github.com/iMarvinS/cordova-plugin-background-geolocation—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/mauron85/cordova-plugin-background-geolocation/issues/324#issuecomment-337495269,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAYDf6K2ZOdE_1PY9D3NOqXozqOxUkJ3ks5stbGogaJpZM4O_HpM
.
@laddhadhiraj, unfortunately, it's impossible by design of iOS. Currently, I can't find doc reference, but you can start your research with https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/LocationAwarenessPG/CoreLocation/CoreLocation.html#//apple_ref/doc/uid/TP40009497-CH2-SW10.
I hope I understood your task correctly
I have same issue with IOS background
I want to track user coordinates every 10 seconds in background so I used cordova-plugin-mauron85-background-geolocation.It works very well at the android in foreground or background but in IOS it does not work in background(it works only in foreground)
In background it does not fire success( SetLocationUpdates ) function and also it give not error,it does not fire error function.
here is my config.xml
<plugin name="cordova-plugin-mauron85-background-geolocation" source="npm" spec="2.3.2">
<variable name="LOCATION_ALWAYS_USAGE_DESCRIPTION" value="xxx" />
<variable name="LOCATION_WHEN_IN_USE_USAGE_DESCRIPTION" value="xxx" />
<variable name="LOCATION_ALWAYS_AND_WHEN_IN_USE_USAGE_DESCRIPTION" value="xxx" />
</plugin>
<preference name="phonegap-version" value="cli-7.0.1" />
and here is my html page code
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript">
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady () {
backgroundGeolocation.configure(SetLocationUpdates, onError, {
desiredAccuracy: 10,
stationaryRadius:1,
distanceFilter: 1,
interval: 10000
});
backgroundGeolocation.start();
//backgroundGeolocation.switchMode(backgroundGeolocation.mode.FOREGROUND);
}
}
function onError(error) {
alert("error:"+error.message);
}
function SetLocationUpdates(position){
//store position to database via ajax call.....
it works very well in foreground so i try to force it to foreground in switch mode but it does not work
backgroundGeolocation.switchMode(backgroundGeolocation.mode.FOREGROUND,switchModesuccess, switchModefail);
try adding pauseLocationUpdates: false
EDIT: according https://developer.apple.com/documentation/corelocation/cllocationmanager/1620553-pauseslocationupdatesautomatical?language=objc
It was very clear before, but apple added following section:
After a pause occurs, it is your responsibility to restart location services again when you determine that they are needed.
I added pauseLocationUpdates: false, but it still does not work in IOS in background
here is my index.html
<script type="text/javascript">
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady () {
var SetLocationUpdates1=function(position){ backgroundGeolocation.finish();}
var onError=function(error) {
backgroundGeolocation.finish();
alert("Hata:"+error.message);
}
backgroundGeolocation.configure(SetLocationUpdates1, onError, {
desiredAccuracy: 0,
stationaryRadius:0,
distanceFilter: 0,
url: 'https://www.elevitturizm.com.tr/home/locations',
httpHeaders: { 'X-FOO': 'bar' },
interval: 10000,
debug:true,
startOnBoot: true,
pauseLocationUpdates: false,
saveBatteryOnBackground: true
});
backgroundGeolocation.start();
backgroundGeolocation.switchMode(backgroundGeolocation.mode.FOREGROUND,switchModesuccess, switchModefail);
backgroundGeolocation.getLogEntries(100, printIosLogs);
}
</script>
and here is my config
<plugin name="cordova-plugin-geolocation" source="npm" spec="2.4.1" />
<plugin name="cordova-plugin-mauron85-background-geolocation" source="npm" spec="2.3.0">
<variable name="ALWAYS_USAGE_DESCRIPTION" value="xxx" />
<!-- <variable name="xx" /> -->
<!-- <variable name="LOCATION_ALWAYS_AND_WHEN_IN_USE_USAGE_DESCRIPTION" value="xxx" /> -->
</plugin>
<preference name="phonegap-version" value="cli-7.0.1" />
In IOS in background mode sound is SIRI stop listening sound
what does it mean?If client change his location in a kilometers is it get active again?
what is meaning of "Passive geolocation engaged" Is that error?Or it will get tracking after big location changed?
@bharat-saralweb
Hi
are there any problem with my code?What should I do?Can you give suggestion please @HamzaLJ @gregor-srdic @mauron85
Notice: this issue has been closed because it has been reported for branch 2.x or later. It could be already fixed in v3 or is not relevant anymore. You may reopen this issue if it has been closed in error.
Can anyone please validate this does work as expected with v3?
Most helpful comment
Same problem. Other people have been having running into the same issue as well.