Skip to content Skip to sidebar Skip to footer

Res/drawable Files In Intel Xdk

Is there a way in xdk to transfer files to the android/res/drawable folder? I've the following files: src/android/drawable/noti_icon.png www/src/android/drawable/noti_icon.png And

Solution 1:

This actually is part of the solution to a popular problem with the local notifications plugin in Intel XDK. The wiki tells us that there are 3 possibilities to load the notification icon, but only when using the res type it seemed to work for me. I haven't found any other clear solution on this and I haven't been able to test it on iOS, but here is what I did on Android:

  1. I located the plugin folder in my Intel XDK project (de.appplant.cordova.plugin.local-notification for me, but I'll call it local-notification from now on).

  2. Created android res folder: local-notification\src\android\res

  3. Since I'm still not sure about all the different resolutions, I created 4 folders: drawable-hdpi, drawable-mdpi, drawable-xhdpi and drawable-xxhdpi and put my differently sized icons in them. So in the end I had f.e.: local-notification/src/android/res/drawable-hdpi/noti_icon.png

  4. Now I followed Tom's instructions and the hint given in this reply and added the following lines to local-notification\plugin.xml file:

    <resource-filesrc="src/android/res/drawable-hdpi/noti_icon.png"target="res/drawable-hdpi/noti_icon.png" /><resource-filesrc="src/android/res/drawable-mdpi/noti_icon.png"target="res/drawable-mdpi/noti_icon.png" /><resource-filesrc="src/android/res/drawable-xhdpi/noti_icon.png"target="res/drawable-xhdpi/noti_icon.png" /><resource-filesrc="src/android/res/drawable-xxhdpi/noti_icon.png"target="res/drawable-xxhdpi/noti_icon.png" />

The icon is now finally available as ressource and can be used via the res type with the local notifcations plugin by simply:

cordova.plugins.notification.local.schedule({
    ...your other options... ,
    icon: "noti_icon",
    smallicon:"noti_icon"
});

(You don't need to add the filetype or "res://" type)

Finally, instead of seeing the Android bell icon, you should now see your own icon.

There are some other google guidelines to take care of, like a transparent background on your .png, but I'm not sure and haven't tested if these specs have any influence on the appearance.

Solution 2:

I beilive this question is asked to get over the nasty white icon of a cordova app when it receive a push notification.

One painless way is to use this popular plugin to register and receive push notifications: https://github.com/phonegap/phonegap-plugin-push

Then just simply put the icon somewhere in your apps's folder and when sending the message from your push server, specify the icon by the image property like this:

{"registration_ids":["my device id"],"data":{"title":"Large Icon","message":"Loaded from assets folder","image":"www/image/logo.png"}}

You can reffer to this link: https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md

Post a Comment for "Res/drawable Files In Intel Xdk"