katzer / cordova-plugin-background-mode

Keep app running in background
Apache License 2.0
1.38k stars 1.01k forks source link

How to set up notification icon in cordova-android 7 #459

Open LucaTrip opened 5 years ago

LucaTrip commented 5 years ago

I'm trying to change the notification icon but with poor results. This is what I do: cordova.plugins.backgroundMode.setDefaults({ title: 'my title', text: 'my text', icon: 'icon' // this will look for icon.png in platforms/android/res/drawable|mipmap }); inside enable event. I created the res/drawable/ folder in platforms/android because in cordova-android 7 the res folder is in another place. inside the drawable folder there is icon.png with lpdi density but doesn't work.

giok57 commented 5 years ago

Per me è la cipolla.

ayanonly1 commented 4 years ago

I am also facing a similar issue. Icon- Screenshot 2019-09-01 at 1 18 41 AM Inside details-

Screenshot 2019-09-01 at 1 19 02 AM

Please help.

asoap commented 4 years ago

I have figured this out.
You have to look into the folder: \platforms\android\app\src\main\res In there you'll see folders like "mipmap-ldpi" Inside of those you'll see files named "ic_launcher.png"

This is the name of your icon file.

Now when you set your defaults you put that name (without .png) in the icon property:

  cordova.plugins.backgroundMode.setDefaults({

    title: 'your name',

    text: 'your text',

    icon: 'ic_launcher',

    resume: true,

    hidden: false

});

Now I think the icon also has to be black and white for some reason. But I can't confirm yes/no in regards to that.

Unreach3D commented 4 years ago

I have figured this out. You have to look into the folder: \platforms\android\app\src\main\res In there you'll see folders like "mipmap-ldpi" Inside of those you'll see files named "ic_launcher.png"

This is the name of your icon file.

Now when you set your defaults you put that name (without .png) in the icon property:

  cordova.plugins.backgroundMode.setDefaults({

    title: 'your name',

    text: 'your text',

    icon: 'ic_launcher',

    resume: true,

    hidden: false

});

Now I think the icon also has to be black and white for some reason. But I can't confirm yes/no in regards to that.

Thx a lot!! I got into the same problem :). Testing it within drawable but it has to be in mimap to work. My icon is white with transparent BG.