3.0.7android10emulatoryescordova -v): 9.0.0 ([email protected])cordova platform ls): android 8.1.0Show custom icon for permanent notification
Whatever I configure, the notification icon is not customized. Shows just a dot or GPS crosshair
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',
Most helpful comment
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 casenotification) _without extension_ as config parameter: