Cordova-plugin-local-notifications: I want to keep custom icon for notifications different from my app icon

Created on 8 Jan 2021  ·  4Comments  ·  Source: katzer/cordova-plugin-local-notifications

WARNING: IF YOU IGNORE THIS TEMPLATE, WE'LL IGNORE YOUR ISSUE. YOU MUST FILL THIS IN!

Okay so I have been searching a fix for a lot of days.
When the app shows a notification, there is a notification icon that shows which app the notification is from.
I DONT mean the icons or images inside the notification box.

I tried doing this -
cordova.plugins.notification.local.schedule({ id: 1, title: 'title', text: 'text', icon: 'file://med/icon.png', smallIcon: 'file://med/icon.png', color: '#44c54d' });
and this is the output
image

now see - I do not want the green blob before the name of the app. That icon is the app icon I have set in the config file. Instead I want the icon showing in the right inside the box to be where the green blob is.

Your Environment

  • Plugin version: "cordova-plugin-local-notification": "^0.9.0-beta.2", "cordova-plugin-local-notifications-mm": "^1.0.13",
  • Platform: Android
  • OS version: 10
  • Device manufacturer / model: MI A2
  • Cordova version (cordova -v): 10.0.0

Expected Behavior

The transparent icon showing inside the box should not be there but on the top before the name of the app "Writeroo".
image

Actual Behavior

The app icon which I set as a local file on my pc (given below) is being shown as the icon for the notification besides the app name "Writeroo". (it appears as a green blob which is because of my android making icons single color.)

icon_home
(App Icon)

But I want that icon to be changed to another custom Icon I have made, shown below
icon
(Icon I want to show)

Most helpful comment

Yes you can create yourself.
A demo project : https://github.com/fcastell/cordovalocalnotif
To create icon you can use this tool : http://romannurik.github.io/AndroidAssetStudio/index.html

All 4 comments

Hello,

Create a resource file inside resources/android/notification and inside config.xml :

<platform name="android">
  <resource-file src="resources/android/notification/drawable-mdpi/notif.png" target="app/src/main/res/drawable-mdpi/notif.png" />
  <resource-file src="resources/android/notification/drawable-hdpi/notif.png" target="app/src/main/res/drawable-hdpi/notif.png" />
  <resource-file src="resources/android/notification/drawable-xhdpi/notif.png" target="app/src/main/res/drawable-xhdpi/notif.png" />
  <resource-file src="resources/android/notification/drawable-xxhdpi/notif.png" target="app/src/main/res/drawable-xxhdpi/notif.png" />
  <resource-file src="resources/android/notification/drawable-xxxhdpi/notif.png" target="app/src/main/res/drawable-xxxhdpi/notif.png" />

In your code :

cordova.plugins.notification.local.schedule({ id: 1, title: 'title', text: 'text', icon: 'res://notif.png', smallIcon: 'res://notif.png', color: '#44c54d' });

It work in my Ionic app (v3 and v5)

I hope this will help you

Fabien

okay so I am clearly new to this, I cant find a resources folder in my cordova directory. Can you guide me where to find this or do I create this folder myself?
I am using plain cordova.

Yes you can create yourself.
A demo project : https://github.com/fcastell/cordovalocalnotif
To create icon you can use this tool : http://romannurik.github.io/AndroidAssetStudio/index.html

Thank you so much! Just produced the apk, my issue is now solved! Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ThorvaldAagaard picture ThorvaldAagaard  ·  3Comments

mino922 picture mino922  ·  3Comments

neshke89 picture neshke89  ·  4Comments

Kasendwa picture Kasendwa  ·  3Comments

ibnbd picture ibnbd  ·  4Comments