Cordova-plugin-background-geolocation: Ionic 4 on ios: notification on interval, it doesn't track in background app and I can't remove notification after stop (android)

Created on 17 Jun 2019  Â·  12Comments  Â·  Source: mauron85/cordova-plugin-background-geolocation

Your Environment


`Ionic:

Ionic CLI : 5.0.2 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.4.0
@angular-devkit/build-angular : 0.13.9
@angular-devkit/schematics : 7.3.9
@angular/cli : 7.3.9
@ionic/angular-toolkit : 1.5.1

Cordova:

Cordova CLI : 9.0.0 ([email protected])
Cordova Platforms : android 8.0.0, ios 5.0.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.0.1, (and 13 other plugins)

Utility:

cordova-res : not installed
native-run : 0.2.2

System:

Android SDK Tools : 26.1.1 (...)
ios-deploy : 1.9.4
ios-sim : 8.0.1
NodeJS : v10.15.3 (/usr/local/bin/node)
npm : 6.9.0
OS : macOS Mojave
Xcode : Xcode 10.2.1
`

  • Plugin version: cordova-plugin-mauron85-background-geolocation 3.0.3 "CDVBackgroundGeolocation"
  • Platform: iOS or Android
  • OS version: MacOS Mojave 10.14.5
  • Device manufacturer and model: iPHONE AND SAMSUNG
  • Running in Simulator: no
  • Cordova version (cordova -v): 9.0.0 ([email protected])
  • Cordova platform version (cordova platform ls): Installed platforms:
    android 8.0.0
    ios 5.0.1
  • Plugin configuration options:
let config :BackgroundGeolocationConfig = {
        desiredAccuracy: 10, // precisione in metri
        stationaryRadius: 5, // stazionamento
        distanceFilter: 1,
        interval: 3000,
        fastestInterval: 3000,
        activitiesInterval: 3000,
        debug: true,
        locationProvider: 1, //ANDROID_DISTANCE_FILTER_PROVIDER,
        notificationTitle: "Registrazione percorso...",
        notificationText: "",
        stopOnTerminate: false,
        activityType: "AutomotiveNavigation", //AutomotiveNavigation - Fitness
        pauseLocationUpdates: false,
        saveBatteryOnBackground: false,
      };
  • Link to your project: (local)

Context

On ios, every 3s, a new notification is shown
On android can't close the notification after I stopped the rec.
Also both when the app is in background don't rec.

Expected Behavior


I want just one notification on ios, after finish() to close it, also on android i want to close the notification and also rec in background mode, when maybe I use facebook

Actual Behavior


On ios, every 3s, a new notification is shown
On android can't close the notification after I stopped the rec.
Also both when the app is in background don't rec.

Possible Fix

Steps to Reproduce



1.
2.
3.
4.

Context

Debug logs

stale

All 12 comments

Same issue here :(

Same here, android notification does not get removed never and it's impossible to track location in background.

All this issues started when I upgraded android cordova version to 8.0.0 because of Firebase changes.

I’m in the exact same boat @pserna95. For me, on the latest build, I am able to initially trigger the background tracking process but am then unable to kill it, and the notification stays up until the android system decides to kill the process. The system will also kill the process even if I pass the flag to not kill it, and then will cause crashing issues with the app when I try and force close it. Are you seeing this as well?

Yep, I have noticed the same issues. I can trigger geolocation service when I build and open the app and it will work for 10 or 15 minutes but then the service stops sending locations to the server and the notification in the toolbar can't be removed even I call BackgroundGeolocation.stop() in the code so I have to kill the proccess manually from the Settings/Applications section in my device

@mauron85 can we please have your assistance here! Looks like things are a bit wonky :(

Not sure if you guys found a solution for tracking in the background. I had the same issue and think I have resolved by installing background mode plugin https://ionicframework.com/docs/native/background-mode

And then in my code I have added:

this.backgroundMode.enable()

this.backgroundMode.disableWebViewOptimizations(); 

I also needed to add the following permission (or the app crashed each time I left the app).
I added directly into my AndroidManifest.xml file.

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

Only adding <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> works for me.

@alvarollmenezes It works for you even if you more than one hour in the backgroud?
Can you share please your BackgroundGeolocationConfig?

Did not test it over an hour, as the usage of the app doesn't fit with more
than an hour in the background. We will test though.

@hoisel Can you share our config?
@vizeke fyi

On Thu, Sep 12, 2019, 06:39 ProximaHaiz notifications@github.com wrote:

@alvarollmenezes https://github.com/alvarollmenezes It works for you
even if you more than one hour in backgroud?
Can you share please your BackgroundGeolocationConfig?

—
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/598?email_source=notifications&email_token=ACEQJSXMQTGGDEGPOK7Q3KLQJIE6FA5CNFSM4HYXI4PKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6RJISQ#issuecomment-530748490,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACEQJSTRNKH6LDPMGEGTQHDQJIE6FANCNFSM4HYXI4PA
.

Not sure if you guys found a solution for tracking in the background. I had the same issue and think I have resolved by installing background mode plugin https://ionicframework.com/docs/native/background-mode

And then in my code I have added:

this.backgroundMode.enable()

this.backgroundMode.disableWebViewOptimizations(); 

I also needed to add the following permission (or the app crashed each time I left the app).
I added directly into my AndroidManifest.xml file.

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

How long time can your app works with it in background?
I have only 25-30 minutes than my app reboot

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically closed, because it has not had recent activity. If you believe this issue shouldn't be closed, please reopen or write down a comment requesting issue reopening with explanation why you think it's important. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mauron85 picture mauron85  Â·  4Comments

frankzhangxd picture frankzhangxd  Â·  6Comments

kleeb picture kleeb  Â·  8Comments

anusree-mmlab picture anusree-mmlab  Â·  5Comments

mahmed-ntd picture mahmed-ntd  Â·  10Comments