如何更改 React Native(android)应用程序的远程推送通知图标

新手上路,请多包涵
阅读 996
2 个回答

您应该首先在所有 android/app/src/main/res/mipmap-* 中添加新图标

注意在所有启动 mipmap-* 的文件夹中添加具有正确分辨率的同名新图标

然后在您发送的通知对象中添加它的名称

{
  largeIcon: "ic_launcher", // (optional) default: "ic_launcher"
  smallIcon: "ic_notification", // (optional) default:  "ic_notification" with fallback for "ic_launcher"
}

PushNotification.configure({
  largeIcon: "ic_launcher",
  smallIcon: "ic_notification",
})

原文由 Mohamed Khalil 发布,翻译遵循 CC BY-SA 4.0 许可协议

您必须遵循通知图标 链接 的一些规则

首先,生成各种大小的通知图标 链接。并输入图标名称 ic_notification

然后在 --- 文件夹的相应文件夹中移动所有尺寸 ic_notification 并在 AndroidManifest.xml android/app/main/res/mipmap 文件中添加以下行。

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

原文由 rahulworld 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题