簡體   English   中英

如何更改 React Native(android) 應用程序的遠程推送通知圖標

[英]How to change remote push notification icon for React Native(android) application

我已在我的應用程序https://github.com/zo0r/react-native-push-notification/tree/a359e5c00954aa324136eaa9808333d6ca246171中點擊此鏈接實現推送通知

目前顯示默認的應用程序啟動器圖標。 我想改變它。 有什么辦法嗎?

您必須遵循通知圖標鏈接的一些規則

首先,生成各種大小的通知圖標鏈接 並輸入圖標名稱ic_notification

然后在android/app/main/res/mipmap文件夾中的相應文件夾中移動所有大小的ic_notification並在AndroidManifest.xml文件中添加以下行。

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

您應該首先在所有 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",
}) 

在 AndroidManifest.xml 中添加以下行

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

創建自定義圖標 ic_notification 並將它們添加到 mipmap 和 drawable 文件夾

我通過在應用程序結束標記之前在 AndroidManifest.xml 中添加以下代碼找到了解決方案:

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

在生成圖標之前,請記住徽標應具有transparent background

生成所有大小的通知圖標鏈接,並把圖標名稱notification_icon 和提取res 文件夾中的所有drawable-density/ 文件夾

我通過在 AndroidManifest.xml 中添加以下代碼找到了解決方案:

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

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM