flutter - AndroidManifest 中缺少默认通知通道元数据。Flutter 将使用默认值
问题描述
我正在使用 Firebase Messaging 版本 10.0.2 和 flutterLocalNotification 版本 6.0.0。每当我在我的应用程序处于后台时使用 firebase 消息运行通知时,我都会在控制台中不断收到此异常Missing Default Notification Channel metadata in AndroidManifest。即使我使用颤振 localNotification 插件创建了通知通道,也会使用默认值。虽然,当应用程序处于前台时,这非常有效这是我的 Manifest.xml 文件
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app">
<application
android:label="app"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="app"/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</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>
这也是我创建通知通道的代码
static final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
static void initialize() {
final InitializationSettings initializationSettings =
InitializationSettings(
android: AndroidInitializationSettings("@mipmap/ic_launcher"));
static void createChannelAndDisplay(RemoteMessage message) async {
final id = DateTime.now().millisecondsSinceEpoch ~/ 1000;
final NotificationDetails notificationDetails = NotificationDetails(
android: AndroidNotificationDetails(
"app", "app_channel", "my app channel",
importance: Importance.max, priority: Priority.high));
await flutterLocalNotificationsPlugin.show(
id,
message.notification!.title,
message.notification!.body,
notificationDetails,
);
我怎么了?
解决方案
推荐阅读
- powerbi - 在 Films 表中创建一个名为 NumberBreaks 的计算列,它显示每部电影所需的休息次数
- react-native - 将示例从 PIXIJS 转换为 Expo-PIXI
- image - 将 svg 路径转换为 Photoshop 的图像
- java - Java Stacktrace 过早中断
- gnuplot - gnuplot:如何更改超文本的字体大小?
- sql - MS Access 显示与组合框中的保存值
- artifactory - Artifactory 中的“Wharf 缓存默认布局”是什么?
- php - SQLSTATE [HY000]:一般错误:3780 外键中引用列'user_id'和引用列'id'不兼容
- django - Django 微服务认证
- java - Java 上的自动矩阵创建器