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
The documentation isn't clear on where to put files to be used as a smallIcon resource #504
Comments
I've got the same issue, by default the icon seems to be a alert bell icon which is android default, i've tried to change to file://res/icon/android/small.png and that didn't work, maybe in the latest version the small icon has been removed on accident? |
See https://github.com/katzer/cordova-plugin-local-notifications/wiki/10.-URIs
|
Still doesn't seem to work.
All i see if the main icon.png and where the small icon should be (normally the bell icon on android) there is just a black square, i've confirmed the small icon exists and is in the right location. |
Yeah, this is the same results I've been having. Perhaps something got broken during the recent rewrite? |
@wworley, the reason is that on Android /**
* Small icon resource ID for the local notification.
*/
public int getSmallIcon () {
String icon = options.optString("smallIcon", "");
int resId = assets.getResIdForDrawable(icon);
if (resId == 0) {
resId = android.R.drawable.screen_background_dark;
}
return resId;
} |
@katzer Ok so if i specify the same icon as the one used for param icon it seems to work just fine, however if i specify any other name other than "icon.png" i get the black square even though the icon does exist in the www directory THIS WORKS THIS DOES NOT WORK |
@katzer , I think the trouble I'm having might be related to the different file structures used in your kitchen sink app
and the Ionic starter app that my project is based on.
I've tried various versions of 'res://small' and tried putting my file in every location in the resources folder that I can think of, but I'm still getting a blank icon (strangely, mine is white instead of black). I can't even duplicate @wworley 's success using the same file:// address for both icon & smallIcon. Do you have any idea how I refer to a specific resource in Ionic's file system? What should the string in my controller say? What should I name the file and where should it sit? I'm also suspicious that the file size might be a factor in the problems I'm having. I've been testing with a 24x24px PNG image; should I use something else? |
@carpiediem i think you can rule out the file dimensions and file size as the standard cordova icon is 128X128 and file size of 12KB the small icon i was trying to use was same size and similar in file size. I should mention i'm using phonegap, phonegap build and obviously on android and have not yet tested on iOS |
|
Dropped my icons into the platforms/android/res/drawable folder and pointed to it using file:// and it all works as expected for me. cordova.plugins.notification.local.schedule({title:"notification",message:"yeah boi", icon: 'file://notification_icon.png',smallIcon: 'file://notification_alert',led: '009900'}); |
@tribe84 please tell me how the small icon is working without the file extension? OR is the file extension no required which is why no one else but you can get it to work? |
If you are using Meteorjs, all you need to do is go to this link --> https://forums.meteor.com/t/meteor-cordova-www-directory/3851/5 read the comment and later use the solution @tribe84 provides, and everything will work as expected! |
Not using meteor but, @bolonmedia works perfectly for me. Place in res, lowercase and underscores, use extension. |
A small simple workaround if you fear to change your platform folder manually is to add a Cordova 'after_prepare' hook and copy a file from folder a to platforms/android/res/drawable, this worked for me. Simple code example for such a hook file: #!/usr/bin/env node var filestocopy = [{ var fs = require('fs'); // no need to configure below filestocopy.forEach(function(obj) { |
Working @bolonmedia |
This is working now? |
I use the phonegap for android and want to change the notification icon for the app ,I use your method,but it still not work?would you help me?if in the android workspace(phonegap),which foolder I should choose to put the icon?@bolonmedia |
I'm using ionic and I had the same problem as @carpiediem: the icon was entirely white. I also prepared a similar hook like @souly1.
Also, my configuration looks like this:
|
@wworley I tried your method that works, does not work for me using Phonegap Build. |
I have the same problem #ionic v2 |
We have it working on Ionic 1, with PushWoosh and local notifications. We use a very similar technique to populate the Android folders as @heekinho. The only differences is our start folder locations and we use a shell script and not JavaScript. We don't use smallIcon though. We do use icon and its identical to @heekinho. Works fine for us. |
@flint002 Thanks, the normal work. However, smallIcon and icon conflict, only one |
@flint002 Try it, you can set smallIcon as file: //small.png can be compatible |
Closed issues like 230 and 398 make it clear that the smallIcon must be be placed in the res directory, but I'm having trouble figuring out how to do that in my Ionic project. It includes a resources/android directory with both icon & splash as sub-directories. Do I put the PNG file directly in there? In a new sub-directory? Somewhere else? What do I name the file so that I can refer to it in the schedule function?
The text was updated successfully, but these errors were encountered: