cordova-plugin-local-notifications icon indicating copy to clipboard operation
cordova-plugin-local-notifications copied to clipboard

Icon is not showing

Open ran-j opened this issue 4 years ago • 8 comments

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

Provide a general summary of the issue.

Your Environment

  • Plugin version: 0.9.0-beta.2
  • Platform: Android
  • OS version: 8.0.0
  • Device manufacturer / model: Google Pixel 2 XL
  • Cordova version (cordova -v): 9.0.0
  • Cordova platform version (cordova platform ls): 8.1.0
  • Plugin config
  • Ionic Version (if using Ionic) NO

Expected Behavior

icon on notification.

Actual Behavior

Icons are not displaying, I spend hours reading issues and I cant make it work.

My config:

<platform name="android">
        <allow-intent href="market:*" />
        <resource-file src="google-services.json" target="app/google-services.json" />
        <resource-file src="www/res/drawable-hdpi/myandroid.png" target="res/drawable-hdpi/myandroid.png" />
        <resource-file src="www/res/mipmap-mdpi/myandroid.png" target="res/mipmap-mdpi/myandroid.png" />
    </platform>

This is the icon : https://material.io/resources/icons/?icon=android&style=baseline

And my code :

cordova.plugins.notification.local.schedule({
            id: 15,
            title: 'Chat with Irish',
            icon: 'res://myandroid',
            smallicon: 'res://myandroid',
            text: [
                { message: 'I miss you' },
                { person: 'Irish', message: 'I miss you more!' },
                { message: 'I always miss you more by 10%' }
            ]
        });

And then image

ran-j avatar Jan 07 '20 22:01 ran-j

in cordova 9.0.0 target folder changed - please add app/src/main path for target

ivanov84 avatar Jan 19 '20 20:01 ivanov84

Add where ?

ran-j avatar Jan 20 '20 02:01 ran-j

@ran-j here:

<platform name="android"> <allow-intent href="market:*" /> <resource-file src="google-services.json" target="app/google-services.json" /> <resource-file src="www/res/drawable-hdpi/myandroid.png" target="app/src/main/res/drawable-hdpi/myandroid.png" /> <resource-file src="www/res/mipmap-mdpi/myandroid.png" target="app/src/main/res/mipmap-mdpi/myandroid.png" /> </platform>

ivanov84 avatar Jan 21 '20 10:01 ivanov84

image

the icon works but smalicon dont

ran-j avatar Jan 21 '20 13:01 ran-j

I think it should be "smallIcon" (with a capital i).

timkellypa avatar Apr 23 '20 03:04 timkellypa

@timkellypa @ran-j Do you guys have prohjects on github where i could see your whole setup of how you guys did it - I cant seem to set icons at all with this plugin!

(the docs are not specific, they merely mention things without detailing each options carefully)

boltex avatar Jul 20 '20 19:07 boltex

@boltex Unfortunately, I have nothing really to share, although when I find some time, I may attempt to build a quick sandbox for this if nobody has already. I agree that the docs aren't very descriptive, but if you look at CHANGELOG.md, that is sometimes more helpful.

The important bits for the icon, I think, are that your config.xml should have your resources in it under the Android node. They should appear as follows:

<resource-file src="www/path-to-your-image/24.png" target="app/src/main/res/drawable-mdpi/icon_key.png" /> <resource-file src="www/path-to-your-image/36.png" target="app/src/main/res/drawable-hdpi/icon_key.png" /> <resource-file src="www/path-to-your-image/48.png" target="app/src/main/res/drawable-xhdpi/icon_key.png" /> <resource-file src="www/path-to-your-image/72.png" target="app/src/main/res/drawable-xxhdpi/icon_key.png" /> <resource-file src="www/path-to-your-image/96.png" target="app/src/main/res/drawable-xxxhdpi/icon_key.png" />

Then you just use "res://name-of-your-target" as the path for icon and smallIcon. So for this example it would be

smallIcon: 'res://icon_key'

If you see a blank gray box for your icons, this just means that you are on a device that only supports monochrome icons. I think that is Android 7 and 8 (maybe? They re-added support for multi-color icons in more recent versions.) If you're using or testing on any of those devices, the trick is to make your icon any color you want (the OS will make it gray or white depending on when it is displayed), but make the background transparent. The system will use that to create a monochrome image in the notification.

timkellypa avatar Jul 21 '20 02:07 timkellypa

I see, Thank you!

My config.xml only has the src parts, not the target parts, its an ooder cordova project that I upgraded to a more recent cordova-android platform...

anyways,

Many thanks again!

boltex avatar Jul 21 '20 03:07 boltex