簡體   English   中英

Flutter Firebase 消息無法點擊通知

[英]Flutter Firebase Messaging cannot click on notification

當我使用 firebase_messaging 收到通知時,無論是直接來自 firebase,還是通過帶有 FCM 令牌的 firebase 使用我的后端服務器,我都無法點擊通知來打開應用程序。

這只是當我在應用程序之外時的問題,我收到通知,但無法點擊它,同樣在調試終端中我得到:

[ +118 ms] W/FirebaseMessaging( 8761): Missing Default Notification Channel metadata in AndroidManifest. Default value will be used.
[  +24 ms] I/flutter ( 8761): Handling a background message 0:1645607606472998%5807eab55807eab5
[  +10 ms] W/FirebaseMessaging( 8761): No activity found to launch app
[        ] I/flutter ( 8761): message also contained a notification: Instance of 'RemoteNotification'

如果我在應用程序中,我會收到通知,我可以隨心所欲地處理它。 例如,我可以使用本地通知來解析推送通知並在本地創建新通知。 如果這樣做,我可以離開應用程序並單擊該通知,它會帶我回到應用程序。

當我在應用程序之外時,我只會遇到通知問題。

這是我的 android 清單文件:

    package="com.example.zira_mobile">
   <application
        android:label="@string/app_name"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            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"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
                <data android:host="ziramob.page.link" android:scheme="https"/>
                <data android:host="ziramobile.page.link" android:scheme="https"/>
            </intent-filter>
            <!-- Add below to ensure we get the payload when tapping on a notification -->
            <intent-filter>
                <action android:name="FLUTTER_NOTIFICATION_CLICK" />
                <category android:name="android.intent.category.DEFAULT" />
            </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>

我正在使用 android 口味(遵循本指南,我懷疑因此而發生沖突,但我不確定)。

我試過谷歌搜索,但大多數解決方案要么直接針對 android、Kotlin 或 Flutter 嵌入 v1,而我使用的是 v2,這應該沒有麻煩並且可以立即工作。

問題似乎出在上述清單文件的以下部分:

<data android:host="ziramob.page.link" android:scheme="https"/>
<data android:host="ziramobile.page.link" android:scheme="https"/>

出於某種原因,深層鏈接會導致通知出現問題,並使 firebase 消息服務無法識別在通知點擊時打開的應用程序。

如果有人知道發生了什么以及如何使兩者一起工作,請做,在那之前,通知很重要,然后單擊登錄。

暫無
暫無

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

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