标签:android push-notification ionic-framework ionic2 cordova-plugins
我正在尝试在通知中显示应用程序图标.但它显示空白图标.
我给出了如下推送选项:
const options: PushOptions = {
android: {
titleKey: 'App',
sound: 'true',
icon: 'res/drawable/notification_icon',
topics: ['MyTopic']
},
ios: {
alert: 'true',
badge: false,
sound: 'true'
},
windows: {}
};
并复制下面的图标图像,分辨率为40 * 40px.
<resource-file src="resources/notification_icon.png" target="res/drawable/notification_icon.png" />
有什么我想念的吗?
更新:
我按照这个链接:https://github.com/ionic-team/ionic-cli/issues/608并通过使用以下语句将resources / android / notification / drawable-XYZ / ic_stat_ac_unit.png下的所有通知图标复制到res / drawable-XYZ / ic_stat_ac_unit.png来尝试它:
<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" />
并将app.component.ts中的PushOptions修改为:
android: {
titleKey: 'App',
sound: true,
vibrate:true,
icon: 'ic_stat_ac_unit',
iconColor:'#343434',
topics: ['MyTopic']
}
即使这样也行不通 – 同样的问题.
解决方法:
可能没有在要显示的形状的图标上设置alpha通道. Android 5.0为所有小通知图标添加了白色遮罩.你可以使用Android Asset Studio来创建图标集,因为它会告诉你它在设备上的外观,以确保你的设置正确.
In Android 5.0+, push notification icon has to be two-color:
transparent background + white foreground; otherwise the default app
icon is taken, and anything non-transparent is displayed as white (so
very likely, the user will see a white)
标签:android,push-notification,ionic-framework,ionic2,cordova-plugins 来源: https://codeday.me/bug/20190622/1263936.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。