question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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 (cordova-lib@9.0.1) 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 (cordova-lib@9.0.1)
  • 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

Context

Debug logs

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:12

github_iconTop GitHub Comments

1reaction
alvarollmenezescommented, Sep 11, 2019

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

1reaction
chrisreed01commented, Aug 24, 2019

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" />

Read more comments on GitHub >

github_iconTop Results From Across the Web

Notifications not coming when application is in background or ...
when the application gets killed or it is in background don't receive notifications when geofence is crossed in Android and works fine in ......
Read more >
Ionic 3: cannot receive push notification after restarting the app
When I enable the push notification inside the app, everything works fine. But when I exit the app completely and reopen it later,...
Read more >
Background Modes Tutorial: Getting Started
Build and run the app on a physical device. Check the Xcode console for a message to confirm the background refresh is scheduled....
Read more >
IONIC push notification not triggered when in foreground iOS
The Push Notifications are working in foreground, background and even in the killed state for Android and iOS both. The problem here is...
Read more >
Location - Expo Documentation
Open Android Studio, and launch your AVD in the emulator. Then, on the options bar for your device, click the icon for "More"...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found