在Phonegap中为推送通知添加新图标

时间:2017-02-15 08:33:17

标签: android cordova phonegap-plugins phonegap-pushplugin

我在我的Phonegap应用中使用<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> </head> <body> <p>Paragraph One</p> <div id="to_remove"> <p>Beginning of the part to be removed</p> <a href="mailto:ertwtz@gmail.com">E-Mail</a><br><br> This is simply something other. Etc. Etc. <p>End of the part to be removed</p> </div> <p>Paragraph Ten</p> <script type="text/javascript"> var param = 11; if(param >10) document.getElementById("to_remove").remove(); //OR if you want to show the div later use this: //if(param>10) document.getElementById("to_remove").style.display = 'none'; </script> </body> </html>插件,我想为推送通知设置一个不同的图标而不是用过的徽标应用。 在文档之后,我使用此代码执行此操作;无论如何这不起作用,它总是使用应用程序图标而不是我想要的新图标。

phonegap-plugin-push

我将var push = PushNotification.init({ "android": { "senderID": "xxx", "icon": "ic_stat_icon" } }); 图片放入ic_stat_icon.png文件夹

1 个答案:

答案 0 :(得分:1)

我整个下午花了这个问题 - 完成了Push Plugin文档中所说的所有内容 - 而且看起来在Android清单中添加额外的标签可以解决问题:

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

...其中icontrans是我的图标的名称。

作为参考,我还使用config.xml中的以下内容将图标放入每个res / drawable文件夹中:

    <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" />

不确定它是否与后续平台(我定位SDK 26)或我使用Firebase发送通知的事实有关。