mauron85 / cordova-plugin-background-geolocation

Background and foreground geolocation plugin for Cordova.
Apache License 2.0
538 stars 406 forks source link

Plugin Not working In background Mode (ionic 3) #720

Open ihebConverto opened 4 years ago

ihebConverto commented 4 years ago

Your Environment

Context

It work perfectly in the foreground but in the background when we close the App the server is not receiving any request from the plugin

ihebConverto commented 4 years ago

The application stopped programming due to this problem .. any ideas to solve it ...

JorgeRomano commented 4 years ago

It may be that the app needs authorization for background data. See: https://www.samsung.com/hk_en/support/mobile-devices/how-do-i-restrict-background-data/ You must enable "Allow aap while Data saver on" too.

MelanieMarval commented 4 years ago

I have the same problem, the app has authorization to work in the background and the battery optimization is disabled, even so it stops saving locations or updating them by url. Any suggestion? I am using Ionic 5

JorgeRomano commented 4 years ago

I've also installed these CORDOVA plugins and I've better result: cordova-plugin-powermanagement-orig and cordova-plugin-backgroud-mode .

IONIC : @ionic-native/background-mode => ...enable(); ...disableWebViewOptimizations();

and @ionic-native/power-management => ...powerManagement.dim(); ...powerManagement.setReleaseOnPause(false);

tobika commented 4 years ago

I'm currently debugging this. It seems for me that in android 9 background location is still working. In the simulator for android 10 & 11 I can only give location permissions to "while app is running" and not in the background all the time. Am I missing something?

tlacroix commented 4 years ago

@tobika This is probably the threads you're looking for: https://github.com/mauron85/cordova-plugin-background-geolocation/issues/688 https://github.com/mauron85/cordova-plugin-background-geolocation/issues/691

tobika commented 4 years ago

@tlacroix thanks a lot, sorry I didn't write before but I also found this posts and it works well now :+1:

bogomips commented 3 years ago

not sure if this is related: If I use url: 'server.tld:port' I keep receiving data (the object is inside an array though) What basically stops working in background is the callback

this.backgroundGeolocation.on(BackgroundGeolocationEvents.location).subscribe((location: BackgroundGeolocationResponse) => {