繁体   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