Marco24690
Marco24690

Reputation: 355

Add new icon for the push notification in Phonegap

I use the phonegap-plugin-push plugin in mine Phonegap app, and I want to set a different icon instead of the used logo app, for the push notification. Following the documentations I do it with this code; anyway this not work, it always use the app icon instead of the new one that I want.

var push = PushNotification.init({
    "android": {
        "senderID": "xxx",
        "icon": "ic_stat_icon"
    }
});

I put my ic_stat_icon.png image in the platform/android/res folder

Upvotes: 2

Views: 1413

Answers (2)

Jamie Brown
Jamie Brown

Reputation: 1053

I've spent the whole afternoon on this problem - done everything that it says in the Push Plugin documentation and more - and it appears that putting an extra tag in your Android manifest fixes the problem:

<meta-data android:name="com.google.firebase.messaging.default_notification_icon"
    android:resource="@drawable/icontrans" />

... where icontrans is the name of my icon.

For reference, I also put the icons into each of the res/drawable folders using the following in my config.xml:

    <resource-file src="res/icon/icon-18-trans.png" target="res/drawable-ldpi/icontrans.png" />
    <resource-file src="res/icon/icon-24-trans.png" target="res/drawable-mdpi/icontrans.png" />
    <resource-file src="res/icon/icon-36-trans.png" target="res/drawable-hdpi/icontrans.png" />
    <resource-file src="res/icon/icon-48-trans.png" target="res/drawable-xhdpi/icontrans.png" />
    <resource-file src="res/icon/icon-72-trans.png" target="res/drawable-xxhdpi/icontrans.png" />
    <resource-file src="res/icon/icon-96-trans.png" target="res/drawable-xxxhdpi/icontrans.png" />

Not sure if it's something to do with the later platforms (I'm targeting SDK 26) or the fact I'm using Firebase to send the notifications.

Upvotes: 1

shino47
shino47

Reputation: 213

Try putting your image in platform/android/res/drawable.

I don't know if it's necessary but you can try also put your images in the others drawables folders (drawable-ldpi, drawable-mdpi, drawable-hdpi, etc).

Upvotes: 0

Related Questions