Hi,
I’m using capacitor local notification plugin to schedule the local notification. But I’m wondering that how to change the default small icon.
I’ve refer this docuement (https://capacitorjs.com/docs/apis/local-notifications ), but it’s quite unclear about how to change the icon. I also tried “smallIcon”: “assets/img/xxx.png”, which fails as well.
Also, I’m facing an issue that the notification only have sound, but the device will not vibrate even after I set the notification channel on android platform…
Hope someone familiar with this plugin could help to solve mentioned two issues. Thanks in advance.
1 Like
Epiq
November 4, 2020, 1:48pm
2
Same question here.
It appears that we have two options:
either set an icon globally in capacitor.config.json
:
...
"LocalNotifications": {
"smallIcon": "ic_some_android_icon"
}
...
or set a smallIcon
field of LocalNotification
to an icon prefixed with res://
, e.g. res://ic_some_android_icon
where do you put the icons? im trying to put it under resources then using cordova-res but it doesnt seem to generate the drawables
Set the icon in notification as
let options:ScheduleOptions={
notifications:[{
largeIcon: 'res://drawable/icon_msg48',
smallIcon: 'res://drawable/icon_msg48',
id:123,
or globally in capacitor.config.ts
plugins: {
LocalNotifications: {
smallIcon: 'res://drawable/icon_msg48',
sound: "birds.wav",
iconColor: "#488AFF",
},
}
Run the command ionic cap sync android
You will get android folder added in your project.
Put the icons files in
android → app->src->main->res->drawable folder
you will get step by step demonstration at
///Ionic 6 capacitor Local Notifications - YouTube
1 Like