簡體   English   中英

Android & iOS 使用 flutter_launcher_icons 0.9.2 時的通知圖標(灰色)

[英]Android & iOS notification icons (grey) while using flutter_launcher_icons 0.9.2

我相信這個問題已經在 GitHub、Stackoverflow、Reddit 和其他論壇等不同地方被問到。

使用 flutter 和 firebase 通知時,某些設備在收到通知時會生成“灰色區域”圖標。

例如:我使用了 flutter_launcher_icons 0.9.2 插件,它為 iOS 和 Android 生成圖標,還為 android 更新 AndroidManifest.xml 文件。代碼如下:

    package="xxxxxxDeletedxxxxx">
   <application
        android:label="xxxxxxDeletedxxxxx"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name="xxxxxx"
            android:exported="true"
            android:launchMode="singleTask"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <!-- Set custom default icon. This is used when no icon is set for incoming notification messages. -->
            <meta-data
                android:name="com.google.firebase.messaging.default_notification_icon"
                android:resource="@drawable/ic_launcher" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data
                    android:scheme="https"
                    android:host="xxxx" />
            </intent-filter>
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
   </manifest>

AndroidManifest.xml 文件表明,已設置 Icon 的路徑並生成圖標。

排除故障:

我在 drawable 和 mipmap 中添加了相同的圖標(在 github 上找到,這可能有幫助)。 [https://i.stack.imgur.com/OGGtj.png]

最終結果->

三星 s10 收到帶有預期圖標的通知。 Pixel 6 手機(實體)或帶有 Android 27lvl API 的隨機模擬器顯示灰色區域圖標

有多個答案/解決方案,但沒有一個指向實際導致主要問題的原因。

我知道這是一個反復出現的問題,但沒有針對此案例的適當解決方案/文檔。 我相信其他人會從中受益。

問候

有些手機需要具有透明背景的單色通知圖標。 因此,如果您沒有透明背景,所有顏色都將轉換為一種顏色,您將只能看到單色圓圈/正方形。 活動中的元數據也對我不起作用,因此您可以嘗試將其移到外面,如下所示:

<application>
<activity>
   ...
</activity>

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

暫無
暫無

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

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