cordova-plugin-background-geolocation icon indicating copy to clipboard operation
cordova-plugin-background-geolocation copied to clipboard

Plugin Not working In background Mode (ionic 3)

Open ihebConverto opened this issue 4 years ago • 8 comments

Your Environment

  • Plugin version: 3.0.0-alpha.50

  • Platform: Android

  • OS version: 7.1.4

  • Running in Simulator: No

  • Cordova version :8.1.1

  • Plugin configuration options:

    const bgGeolocationConfig: BackgroundGeolocationConfig = { desiredAccuracy: 10, stationaryRadius: 20, distanceFilter: 5, interval: 5000, debug: false, // enable this hear sounds for background-geolocation life-cycle. stopOnTerminate: false, // enable this to clear background location settings when the app terminates stopOnStillActivity: false, startOnBoot: true, maxLocations: 500, url: ${this.appConfig.apiUrl}/locate, httpHeaders: { 'Accept': 'application/json', 'Authorization': Bearer ${this.currentToken}, 'Content-Type': 'application/json' }, // customize post properties postTemplate: { latitude: '@latitude', longitude: '@longitude', } };

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 avatar Aug 24 '20 09:08 ihebConverto

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

ihebConverto avatar Sep 01 '20 09:09 ihebConverto

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.

JorgeRomano avatar Oct 16 '20 18:10 JorgeRomano

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

MelanieMarval avatar Oct 29 '20 14:10 MelanieMarval

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);

JorgeRomano avatar Oct 30 '20 17:10 JorgeRomano

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?

tobika avatar Nov 19 '20 13:11 tobika

@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

tlacroix avatar Nov 20 '20 19:11 tlacroix

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

tobika avatar Nov 20 '20 19:11 tobika

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) => {

bogomips avatar Jan 03 '21 17:01 bogomips