Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ihebConverto opened this issue Aug 24, 2020 · 8 comments
Open

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

ihebConverto opened this issue Aug 24, 2020 · 8 comments

Comments

@ihebConverto
Copy link

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
Copy link
Author

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

@JorgeRomano
Copy link

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
Copy link

MelanieMarval commented Oct 29, 2020

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
Copy link

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
Copy link

tobika commented Nov 19, 2020

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
Copy link

@tobika This is probably the threads you're looking for:
#688
#691

@tobika
Copy link

tobika commented Nov 20, 2020

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

@bogomips
Copy link

bogomips commented Jan 3, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants