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.

Add documentation/examples for icon/smallIcon

See original GitHub issue

I see no option to submit a PR to the wiki, so I’m posting my suggestion as an issue.

Lots of questions are going around about how to set the icon/smallIcon resource. This could be explained on https://github.com/katzer/cordova-plugin-local-notifications/wiki/04.-Scheduling or https://github.com/katzer/cordova-plugin-local-notifications/wiki/10.-URIs

I suggest the following addition:


What type or size of icons to generate?

Icons should be placed in the platforms/android/res/drawable-* folders.

The resource should then be set like this (without extension):

smallIcon: "res://my_notification_icon",

When using a build service like Ionic Pro, you cannot place the images in platforms/android/ directly. You can make Cordova copy the files from a source folder by configuring your icons in config.xml with <resource-file>:

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

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:10
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
pzanitticommented, Feb 22, 2018

Great post.

Heads up: If using Cordova Android 7 (<engine name="android" spec="^7.0.0" />) this won’t work, you won’t know why and it will also break your platform. You have to prepend app/src/main/ to the target path like so:

<platform name="android">
    ...
    <resource-file src="res/my_notification_icon/android/ldpi.png" target="app/src/main/res/drawable-ldpi/my_notification_icon.png" />
    <resource-file src="res/my_notification_icon/android/mdpi.png" target="app/src/main/res/drawable-mdpi/my_notification_icon.png" />
    <resource-file src="res/my_notification_icon/android/hdpi.png" target="app/src/main/res/drawable-hdpi/my_notification_icon.png" />
    <resource-file src="res/my_notification_icon/android/xhdpi.png" target="app/src/main/res/drawable-xhdpi/my_notification_icon.png" />
    <resource-file src="res/my_notification_icon/android/xxhdpi.png" target="app/src/main/res/drawable-xxhdpi/my_notification_icon.png" />
    <resource-file src="res/my_notification_icon/android/xxxhdpi.png" target="app/src/main/res/drawable-xxxhdpi/my_notification_icon.png" />
</platform>
0reactions
boltexcommented, Jul 20, 2020

I’ve spent a couple hours reading contradicting tutorials about how to set icon, and smallIcon for this plugin. I just could not get it to work,. going to fallback on the ‘bell’ icon for now. oh well…

I wish there was a ‘recent’ project (not done for some old android 4.0) where we could actually see explicitly how to get those icons to appear. (required file format, required file location, required path specification when specifying this in JS. with or without file extension, with or without filepath, etc…)

Thanks in advance for anyone endeavoring such a thing! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Insert icons in PowerPoint - Microsoft Support
You can insert icons into Microsoft 365 documents. You can rotate, color, and resize them with no loss of image quality. These icons...
Read more >
Insert icons for Docs - Google Workspace Marketplace
Browse 1800+ icons from Font Awesome and Google Material Design, available in every colors and insert them in your document.
Read more >
Design and implement macOS document icons - Discover
Build document icons in your app. To create your document icon types, you'll need to integrate these elements into your Xcode project. Bring ......
Read more >
Android: Notification Icons - OneSignal Documentation
Step 1. Generate Icons.. REQUIRED: Add every icon size listed below. You must add each image with listed size and ...
Read more >
Icons Available for TinyMCE | Docs
Complete list of icon identifiers. ; code-sample, code-sample.svg ; color-levels, color-levels.svg ; color-picker, color-picker.svg ; color-swatch-remove-color ...
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