Hi, when i define the custom icon notificationIcon : res://icon.png or even in the drawable folder, the pulgin works in a very unexpected way by over writing the notificationTitle and notificationText to the default name of the App, once you click on the notification, the takes to to RUNNING APPS program.
What is the standard way of defining and setting the custom Icon
Make sure, that those icons are really available. I've had issues like yours before.
Ok, where are the icons expected to be ?
Very good example is the SampleApp.
I have this exact same problem. If I use:
notificationTitle: 'MyApp',
notificationText: 'MyApp is continuing to track your location',
Then the notification gets that correct title and text. If I change it to:
notificationIcon: 'icon',
notificationTitle: 'MyApp',
notificationText: 'MyApp is continuing to track your location',
Then the icon appears as desired, but the text changes to what netbitsolutions mentions. The icon is definitely available (it appears fine).
Same problem here. The icon is visible (although not notificationColor), but not the title and text:
Title: AppName is running
Text: Touch for more information or to stop the app.
That's the default system message, that from my experience is shown when icon is not found.
It's not exactly bug, but it's kind of my fault. The icon has to be in drawable folder, which is not created by cordova add platform by default and has to be created in cordova script or manually.
In your project folder make sure folder platforms/android/res/drawable exists and has these two files notification_icon_large.png and notification_icon_small.png.
Yes, that really worked. Thank you!
At the moment, if I want to change the notification titlte and/or text, it seems that I would have to stop the service, (re)configure and then start the service again. I think that the notification should be more configurable or maybe an option to disable it (and use another plugin more specified for it).
@mauron85 I forked and updated the plugin a little bit for more configuration, but as I am not very much familiar with Java, then I must ask for your help. If this works, I will PR this repo.
So, I created a "middleman" setNotification: function(title, text, ticker, usesChronometer, when) and the corresponding action constant and case for execute method in BackgroundGeolocationPlugin.java. Some pieces of it:
this.config.setNotificationText(notificationText);
this.config.setNotificationTitle(notificationTitle);
this.config.setNotificationTicker(notificationTicker);
this.config.setNotificationChronometer(notificationChronometer);
this.config.setNotificationWhen(notificationWhen);
So, what I do not know, is how to call a method from AbstractLocationService.java. I will be creating a new method in there to rebuild notification and I would not need to start and stop the service.
@RistoNiinemets all notification related stuff is on lines 97 - 113. Probably post some more code, so I can help.
The custom icon is working fine except one thing, it does not change it's color, keeps white.
Created the icon with AndroidAssetStudio, used my own PNG and tried one Clipart, but same result, the icon keeps white.
The text color changed as expected.
white color accent is how notifications now works on android. nothing i can do about it.
Most helpful comment
That's the default system message, that from my experience is shown when icon is not found.
It's not exactly bug, but it's kind of my fault. The icon has to be in drawable folder, which is not created by cordova add platform by default and has to be created in cordova script or manually.
In your project folder make sure folder
platforms/android/res/drawableexists and has these two filesnotification_icon_large.pngandnotification_icon_small.png.