Change icon in local notifications plugin Cordova


#1

Hi

I’m still working on the application where i want to display notifications. Now I want to add a self made icon into the notifications.

I made an icon and i added it in the /img folder. (see picture )


So i thought I could reach it like this :
$cordov

aLocalNotification.schedule({
                    id: count,
                    text: $scope.notificationsPerCoach[i].content,
                    at: new Date(now + 60 * 60 * 24 * 1000 * count),
                    icon: "img/johnIcon.png"
                }); 

Is this the right way to do it or not?

Thanks in advance


#2

According to Cordova docs, that seems like the right way to do set the icon.
https://www.npmjs.com/package/cordova-plugin-local-notifications


#3

I always get this “icon” instead. Do you have to place the image somewhere else then your /img folder?


#4

I would say you’re using the wrong path.

If your javascript is inside a js folder then you need to use this path:

aLocalNotification.schedule({
                id: count,
                text: $scope.notificationsPerCoach[i].content,
                at: new Date(now + 60 * 60 * 24 * 1000 * count),
                icon: "../img/johnIcon.png"
            });

Remember that this is a relative path, in your case, plugin was looking in this location:

js/img/johnIcon.png

#5

Did you fix this problem? I have the same issue.


#6

same problem here…


#7

Hope this will help.


#8

I had the same problem. I solved it with “res:/icon.png” or “file:/path” only 1 “/”.
Question:
Why my icon always appear in white color if my icon is green??


#9

Did you solve this problem?

Why my icon always appear in white color if my icon is green??


#10

The notifications icons don’t allow colors. You have to create the icon in white and transparent color.


#11

thanks, @CSantos8, I have done the icon with a white and transparent color, if we want to add color to that icon is there any possible ways…