我正在接收通知,现在使用默认图标。 我想自定义它们,但我真的没有时间设置图标。
使用 react-native-firebase notifications .
我已经用这个在线创建了大小合适的图标 notification icons generator .
然后我在这些地方创建了目录并使用了正确的名称,如下所示 (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?> );
我已经阅读了一些文档和指南,但我真的不知道。 引用这些路径的正确方法是什么?
最佳答案
我们建议将以下行放在您的 list 中,然后将所有不同大小的图标放入 mipmap 文件夹后,它将根据设备的分辨率调用。
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@mipmap/ic_noti_icon" />
关于android - 如何根据设备分辨率在react-native中设置通知小图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50440881/