Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I want to keep custom icon for notifications different from my app icon #1939

Closed
skks1212 opened this issue Jan 8, 2021 · 4 comments
Closed

Comments

@skks1212
Copy link

skks1212 commented Jan 8, 2021

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)

@fcastell
Copy link

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

@skks1212
Copy link
Author

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.

@fcastell
Copy link

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

@skks1212
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants