mauron85/cordova-plugin-background-geolocation

Can not set custom notification icon - what are the steps?

Closed this issue · 1 comments

Your Environment

  • Plugin version: 3.0.7
  • Platform: iOS or Android android
  • OS version: 10
  • Device manufacturer and model: emulator
  • Running in Simulator: yes
  • Cordova version (cordova -v): 9.0.0 (cordova-lib@9.0.1)
  • Cordova platform version (cordova platform ls): android 8.1.0
  • Plugin configuration options:

Expected Behavior

Show custom icon for permanent notification

Actual Behavior

Whatever I configure, the notification icon is not customized. Shows just a dot or GPS crosshair

Steps to Reproduce

package.json

"cordova-plugin-background-geolocation": {
"GOOGLE_PLAY_SERVICES_VERSION": "11+",
"ANDROID_SUPPORT_LIBRARY_VERSION": "26+",
"ICON": "@mipmap/notification",
"SMALL_ICON": "@mipmap/notification",
"ALWAYS_USAGE_DESCRIPTION": "App requires background tracking ",
"MOTION_USAGE_DESCRIPTION": "App requires motion detection"
}

config.xml

<resource-file src="src/assets/icon/notification.png" target="app/src/main/res/drawable/notification.png" />
<resource-file src="src/assets/icon/notification.png" target="app/src/main/res/mipmap/notification.png" />

...

<plugin name="cordova-plugin-background-geolocation" spec="@mauron85/cordova-plugin-background-geolocation@^3.0.7">
    <variable name="GOOGLE_PLAY_SERVICES_VERSION" value="11+" />
    <variable name="ANDROID_SUPPORT_LIBRARY_VERSION" value="26+" />
    <variable name="ICON" value="@mipmap/notification" />
    <variable name="SMALL_ICON" value="@mipmap/notification" />
    <variable name="ALWAYS_USAGE_DESCRIPTION" value="App requires background tracking " />
    <variable name="MOTION_USAGE_DESCRIPTION" value="App requires motion detection" />
</plugin>

app.ts

BackgroundGeolocation.configure({
    locationProvider: BackgroundGeolocation.RAW_PROVIDER,
    desiredAccuracy: BackgroundGeolocation.MEDIUM_ACCURACY,
    stationaryRadius: 10, // [m] When stopped, the minimum distance the device must move beyond the stationary location
    distanceFilter: 10, // [m] The minimum distance a device must move horizontally before an update event is generated
    stopOnStillActivity: false, // @deprecated
    activityType: 'Fitness', // ios
    pauseLocationUpdates: false, // ios
    saveBatteryOnBackground: false, // ios
    stopOnTerminate: false,
    startOnBoot: true, // android
    startForeground: true, // android
    debug: environment.production ? false : true,
    interval: environment.production ? 60000 : 10000, // location update interval
    fastestInterval: 60000, // activity only
    activitiesInterval: 60000, // activity only
});

I finally got it working after 2 hours try and error.
You have to pass the target file name (from config.xml <resource-file>, in my case notification) without extension as config parameter:

notificationIconLarge: 'notification',
notificationIconSmall: 'notification',