question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] How do I set a custom icon for the notification?

See original GitHub issue

I am trying to set up a custom icon so it no longer shows the white square, but I can’t seem to get it to target a new icon. How do i include more icons in my project and aim this plugin to use a new icon?

I tried adding <resource-file src="img_res/icons/android/icon_noti.png" target="res/drawable/iconnoti.png" /> to my config

<platform name="android">
    <resource-file src="img_res/icons/android/icon_noti.png" target="res/drawable/iconnoti.png" />
    <icon density="ldpi" src="img_res/icons/android/ldpi.png" />
    <icon density="mdpi" src="img_res/icons/android/mdpi.png" />
    <icon density="hdpi" src="img_res/icons/android/hdpi.png" />
    <icon density="xhdpi" src="img_res/icons/android/xhdpi.png" />
    <icon density="xxhdpi" src="img_res/icons/android/xxhdpi.png" />
    <icon density="xxxhdpi" src="img_res/icons/android/xxxhdpi.png" />
    <splash density="port-ldpi" src="img_res/screens/android/splash-port-ldpi.png" />
    <splash density="port-mdpi" src="img_res/screens/android/splash-port-mdpi.png" />
    <splash density="port-hdpi" src="img_res/screens/android/splash-port-hdpi.png" />
    <splash density="port-xhdpi" src="img_res/screens/android/splash-port-xhdpi.png" />
    <splash density="port-xxhdpi" src="img_res/screens/android/splash-port-xxhdpi.png" />
    <splash density="port-xxxhdpi" src="img_res/screens/android/splash-port-xxxhdpi.png" />
</platform>

And using it like this

cordova.plugins.backgroundMode.setDefaults({
    resume: true,
    hidden: false,
    bigText: false,
    icon:'iconnoti'
});

When I search the platforms folder, it did add the icon to the drawable folder. But I still get the white square. I tried different icons, black on transparent, white on transparent, xxxhdpi size, ldpi size, but always a white square.

I’m a bit lost on this. I don’t want to lose the colour icon in the launcher. How do I add an extra icon to the app, and have the plugin use the icon?

Thanks

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

5reactions
TDolacommented, Jul 12, 2018

Update for Cordova Android 7.1’s new file layout

<platform name="android">
        <resource-file src="img_res/icons/android/ldpinoti.png" target="app/src/main/res/mipmap-ldpi/iconnoti.png" />
        <resource-file src="img_res/icons/android/mdpinoti.png" target="app/src/main/res/mipmap-mdpi/iconnoti.png" />
        <resource-file src="img_res/icons/android/hdpinoti.png" target="app/src/main/res/mipmap-hdpi/iconnoti.png" />
        <resource-file src="img_res/icons/android/xhdpinoti.png" target="app/src/main/res/mipmap-xhdpi/iconnoti.png" />
        <resource-file src="img_res/icons/android/xxhdpinoti.png" target="app/src/main/res/mipmap-xxhdpi/iconnoti.png" />
1reaction
TDolacommented, Sep 28, 2020

Update for Cordova Android 7.1’s new file layout

<platform name="android">
        <resource-file src="img_res/icons/android/ldpinoti.png" target="app/src/main/res/mipmap-ldpi/iconnoti.png" />
        <resource-file src="img_res/icons/android/mdpinoti.png" target="app/src/main/res/mipmap-mdpi/iconnoti.png" />
        <resource-file src="img_res/icons/android/hdpinoti.png" target="app/src/main/res/mipmap-hdpi/iconnoti.png" />
        <resource-file src="img_res/icons/android/xhdpinoti.png" target="app/src/main/res/mipmap-xhdpi/iconnoti.png" />
        <resource-file src="img_res/icons/android/xxhdpinoti.png" target="app/src/main/res/mipmap-xxhdpi/iconnoti.png" />

This guide does not allow you to customize the notification icon, because it uses the same launch icon that is installed with the application.

Duplicate those resource lines for every additional icon you need.

Also this plugin is a little bit dead. Try this fork https://bitbucket.org/TheBosZ/cordova-plugin-run-in-background/src/master/ Currently working on android X support

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android: Notification Icons - OneSignal Documentation
Navigate to Messages > New Push > Platform Settings > Google Android Options > Set the icon name without the file extension. With...
Read more >
How do I manage my Canvas notification settings as a student?
Each notification is set to a default setting. To change a notification for a contact method, locate the notification and click the icon...
Read more >
iOS 15 Custom Icons - No Banners / No Notifications ...
iOS 15 Custom Icons - No Banners / No Notifications Automation Method UpdateHow to create the custom iOS 15 icons ? see this ......
Read more >
How To Change App Icons on iPhone iOS 16 [NO ... - YouTube
How To Change App Icons on iPhone iOS 16 [NO NOTIFICATION ]. Watch later. Share. Copy link. Info. Shopping. Tap to unmute.
Read more >
Customize the taskbar notification area - Microsoft Support
To change how icons and notifications appear. Press and hold or right-click any empty space on the taskbar and select Taskbar settings. Under...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found