android - 如何根据设备分辨率在 react-native 中设置小通知图标
问题描述
我正在接收通知,现在使用默认图标。我想自定义它们,但我真的迷失了设置图标的时间。
我已经用这个在线通知图标生成器创建了大小合适的图标。
然后我在这些地方创建了目录并使用正确的名称,如下所示(Android):
android/app/src/main/res/drawable-mdpi/ (24x24)
android/app/src/main/res/drawable-hdpi/ (36x36)
android/app/src/main/res/drawable-xhdpi/ (48x48)
android/app/src/main/res/drawable-xxhdpi/ (72x72)
android/app/src/main/res/drawable-xxxhdpi/ (96x96)
现在,我想获得正确尺寸的图像并在这里解决它。
var notification = new firebase.notifications.Notification({
sound: 'default',
show_in_foreground: true,
})
.android.setPriority(firebase.notifications.Android.Priority.High)
.android.setChannelId("channel")
.android.setSmallIcon( <How do I put icon paths here?> );
我已经阅读了一些文档和指南,但我真的不知道。引用这些路径的正确方法是什么?
解决方案
我们建议将以下行放入您的清单中,然后将所有不同大小的图标放入 mipmap 文件夹中,它将根据设备的分辨率调用。
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@mipmap/ic_noti_icon" />
推荐阅读
- c# - 使用渲染器(世界空间)在游戏对象周围绘制边界矩形(屏幕空间)(Unity)
- php - 我想将活动的获胜日设置为工作日,但是否可以解决错误?
- mysql - 使用带有临时变量的 MySQL CASE 语句,CASE 结果不正确?
- javascript - 如何获取 youtube iframe 的当前时间但不是十进制?
- azure - Azure SQL 托管实例 - SSMS 连接
- debugging - 如何在 Visual Studio 的 ios 模拟器中打开本地 Web 项目?
- python - R安装找不到anaconda包
- r - 使用带reduce的分组汇总时保留标题列
- json - what(): 没有这样的节点 json boost
- python - 使用多处理读取多个视频流?