图标不显示在离子2中的推送通知中
问题描述:
我试图在通知中显示应用程序图标。但它显示空白图标。图标不显示在离子2中的推送通知中
我给pushoptions如下:
const options: PushOptions = {
android: {
titleKey: 'App',
sound: 'true',
icon: 'res/drawable/notification_icon',
topics: ['MyTopic']
},
ios: {
alert: 'true',
badge: false,
sound: 'true'
},
windows: {}
};
和复制的图标图像作为低于该具有40 * 40像素的分辨率。
<resource-file src="resources/notification_icon.png" target="res/drawable/notification_icon.png" />
有什么我失踪了吗?
更新:
我跟着这个链接:https://github.com/ionic-team/ionic-cli/issues/608和复制资源下的所有通知图标/安卓/通知/绘制-XYZ/ic_stat_ac_unit.png水库/可绘制-XYZ/ic_stat_ac_unit尝试过。
<resource-file src="resources/android/notification/drawable-hdpi/ic_stat_ac_unit.png" target="res/drawable-hdpi/ic_stat_ac_unit.png" />
<resource-file src="resources/android/notification/drawable-mdpi/ic_stat_ac_unit.png" target="res/drawable-mdpi/ic_stat_ac_unit.png" />
<resource-file src="resources/android/notification/drawable-xhdpi/ic_stat_ac_unit.png" target="res/drawable-xhdpi/ic_stat_ac_unit.png" />
<resource-file src="resources/android/notification/drawable-xxhdpi/ic_stat_ac_unit.png" target="res/drawable-xxhdpi/ic_stat_ac_unit.png" />
<resource-file src="resources/android/notification/drawable-xxxhdpi/ic_stat_ac_unit.png" target="res/drawable-xxxhdpi/ic_stat_ac_unit.png" />
和改性PushOptions在app.component.ts到:
android: {
titleKey: 'App',
sound: true,
vibrate:true,
icon: 'ic_stat_ac_unit',
iconColor:'#343434',
topics: ['MyTopic']
}
使用以下语句为png
即使这样也行不通 - 同样的问题。
答
我采用的离子FCM插件来解决这个问题。我刚刚替换了显示Cordova fcm插件图标的cordova push插件。我浪费了很多时间推送插件。我希望这个答案可以帮助其他人。
请参考以下链接了解更多信息:
答
它可能不是在要显示的形状中的图标上设置alpha通道。 Android 5.0+为所有小型通知图标添加了白色蒙版。您可以使用Android Asset Studio来创建图标集,因为它会告诉您它将如何在设备上显示,以确保其正确。
在Android 5.0+中,推送通知图标必须为双色: 透明背景+白色前景;否则默认应用 图标拍摄,以及任何非透明显示为白色(所以 很有可能,用户将看到一个白色的)
我试着用https://i.stack.imgur.com/Vr27p.png该图是在Android资产Studio链接,但不在设备上。仅供参考,我使用离子2 – user1188867
@ user1188867 for Ionic,请通过此[问题](https://github.com/ionic-team/ionic-cli/issues/608)它应该引导您正确的路径 – Webruster
I认为url链接被破坏。请验证并再次发布。 – user1188867