相关疑难解决方法(0)

W/FirebaseMessaging:AndroidManifest 中缺少默认通知通道元数据。将使用默认值

我们的应用程序现在有 targetSdkVersion 26 ( Android 8 ) 并且应用程序使用 FCM 推送通知。当应用程序处于前台状态时,推送通知运行良好。当应用程序不在前台状态时单击通知时会出现此问题。我刚刚在清单中添加了元数据,但仍然出现相同的错误。

AndroidManifest.xml

<meta-data
    android:name="com.google.firebase.messaging.default_notification_channel"
    android:value="@string/default_notification_channel_id"/>
Run Code Online (Sandbox Code Playgroud)

MyFirebaseMessagingService.java

/**
 * Create and show a simple notification containing the received FCM message.
 */
private void sendNotification(NotificationModel notificationModel) 
{
    Intent intent;
    if (notificationModel.getAppLink() != null) 
    {
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(notificationModel.getAppLink()));
    } else 
    {
        intent = new Intent(this, NoticeActivity.class);
    }

    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,
            PendingIntent.FLAG_ONE_SHOT);
    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);

    if (notificationModel.getAppLink() != null) …
Run Code Online (Sandbox Code Playgroud)

push-notification android-notifications firebase-cloud-messaging android-studio-3.0 android-8.0-oreo

20
推荐指数
2
解决办法
4万
查看次数

如何在Android 8中为FCM推送消息指定Android通知通道

我们的应用程序现在有targetSdkVersion 26(Android 8),该应用程序使用FCM推送通知.

由于FCM文档规定我将FCM客户端库更新为版本11.2.0:

dependencies {
     compile 'com.google.firebase:firebase-messaging:11.2.0'
}
Run Code Online (Sandbox Code Playgroud)

通过此FCM客户端库更新,FCM通知开始出现在Android设备上.很好,但是当应用程序处于后台时,它是处理FCM消息的系统,因此它使用名为"Miscellaneous"的默认Android通知通道,这不是我们想要的(我们在该列表中有其他通知通道和"其他"声音混乱) ).

正如FCM文档所述,有一种方法可以为FCM消息指定默认通知通道:

(可选)在应用程序组件中,元数据元素用于设置通知的默认图标,颜色和通知通道(Android O中的新增功能).只要传入的消息没有明确设置图标,颜色或notification_channel,Android就会使用这些值.

但是没有显示代码示例(样本仅显示图标和颜色).所以我只是通过在github上使用Firebase云消息传递快速入门中的一个示例来搜索:

<meta-data
    android:name="com.google.firebase.messaging.default_notification_channel"
    android:value="@string/default_notification_channel_id"/>
Run Code Online (Sandbox Code Playgroud)

但它不起作用 - FCM通知仍然出现在"杂项"频道中.我在日志中看到:

W/FirebaseMessaging:AndroidManifest中缺少默认通知通道元数据.将使用默认值.

当然,我试图重新安装该应用程序.还有问题.

好吧,理想情况下,应该有一些方法在发送消息时在后端指定通知通道.允许测试发送的FCM开发控制台现在在UI中有这样的选项:

在此输入图像描述

它工作正常.然而,我们的后端使用Java Amazon SNS API,我不知道该API是否允许在发送消息时指定Android通知通道(因为它是一个新的Android功能,亚马逊需要时间来采用它).因此,设置默认通知通道AndroidManifest.xml现在是一种有效的解决方法,但它不起作用.

android amazon-sns firebase-cloud-messaging notification-channel

13
推荐指数
3
解决办法
3万
查看次数

firebase_messaging onResume和onLaunch无法正常工作

我在应用程序处于前台时收到通知,但在应用程序处于后台时却未收到通知。此外,我有google-ed / StackOverflow-ed大约2个小时或更长时间,但能够解决此问题。

我的配置是:

  firebase_auth: ^0.10.0
  firebase_messaging: ^5.0.0
Run Code Online (Sandbox Code Playgroud)

清单是这样的:

表现

代码是这样的:

final notifications = new FirebaseMessaging();

class AppNotifications {
  static String fcmToken = '';

  static Future<Null> init() async {
    appLogs("AppNotifications init");

    notifications.requestNotificationPermissions(const IosNotificationSettings(sound: true, badge: true, alert: true));

    await configure();

    fcmToken = await notifications.getToken();
    appLogs("FCM TOKEN : " + fcmToken);

    notifications.onTokenRefresh.listen((newToken) {
      fcmToken = newToken;
      appLogs("FCM TOKEN onTokenRefresh: " + fcmToken);
    });

    await updateFCMToken();
  }

  static Future<Null> configure() async {
    appLogs("AppNotifications Configure");

    notifications.configure(onMessage: (msg) {
      appLogs('FCM onMessage: ' + msg.toString());
    }, …
Run Code Online (Sandbox Code Playgroud)

push-notification flutter

13
推荐指数
3
解决办法
2458
查看次数

Firebase 推送通知未在屏幕上弹出 [Flutter]

我正在尝试为 Flutter 应用程序实现 firebase 推送通知。

但它在状态栏中显示为一个图标。我怎样才能让它弹出?

在此处输入图片说明

我想在收到通知时在屏幕上弹出。

这是我的代码的样子:

 Future<bool> sendNotification(var userToken, String bodyMessage) async {
 final data = {
  "notification": {
    "body": bodyMessage,
    "title": "Leave Application",
  },
  "priority": "high",
  "data": {
    "click_action": "FLUTTER_NOTIFICATION_CLICK",
    "id": "1",
    "status": "done"
  },
  "registration_ids": userToken,
 };

 final headers = {
  'content-type': 'application/json',
  'Authorization':
  'key=<Firebase web key>',
 };

 final response = await http.post(postUrl,
    body: json.encode(data),
    encoding: Encoding.getByName('utf-8'),
    headers: headers);

 if (response.statusCode == 200) {
  print(response.statusCode.toString());
  print("Working");
  return true;
 } else {
  print(postUrl.toString());
  print(response.statusCode.toString());
  print("Not Working");
  return …
Run Code Online (Sandbox Code Playgroud)

android dart flutter

12
推荐指数
2
解决办法
4371
查看次数

如何为flutter应用程序添加android通知通道ID以在应用程序处于后台时修复通知

在我的 flutter 应用程序中,onResume 和 onLunch 函数在 android 平台上不起作用,虽然它们在 IOS 上运行良好,但我在控制台上收到以下消息,而不是在这些函数中打印字符串:

“W/FirebaseMessaging(24847):AndroidManifest 中缺少默认通知通道元数据。将使用默认值。”

onMessage 功能工作正常,问题是应用程序在后台时

我的猜测是它与应该添加到 android manifest 中的 android 通知通道 id 有关

当我通过将以下代码添加到 AndroidManifest 将其添加到清单时,消息更改为 :(我在值中添加了一个 strings.xml 文件并在那里定义了“default_notification_channel_id”。)

“应用程序尚未创建 AndroidManifest.xml 中设置的通知通道。将使用默认值。”

<meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="@string/default_notification_channel_id"/>
Run Code Online (Sandbox Code Playgroud)

在我的控制台中,我应该收到我打印的 onResume 和 onLunch 字符串,但我收到以下消息:

“W/FirebaseMessaging(24847):AndroidManifest 中缺少默认通知通道元数据。将使用默认值。”

“应用程序尚未创建 AndroidManifest.xml 中设置的通知通道。将使用默认值。”

<meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="@string/default_notification_channel_id"/>
Run Code Online (Sandbox Code Playgroud)

android-notifications flutter firebase-cloud-messaging

10
推荐指数
2
解决办法
8460
查看次数

Flutter 中 AndroidManifest 中缺少默认通知通道元数据

我正在使用firebase_messaging: ^5.0.1包来实现推送通知,在 IOS 中一切正常,而当我的移动应用程序运行后台时进入 android 我收到通知但它没有导航到相应的屏幕,它只是打开默认屏幕。如何实现导航到该特定屏幕。

PS:我实现了 click_action 功能,这就是它在 iOS 中运行良好的原因,但在 Android 中它显示以下消息

W/FirebaseMessaging( 8260): Missing Default Notification Channel metadata in AndroidManifest. Default value will be used.

这是我的 AndroidManifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.check">

    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <application
        android:name="io.flutter.app.FlutterApplication" …
Run Code Online (Sandbox Code Playgroud)

android flutter firebase-cloud-messaging

9
推荐指数
4
解决办法
2万
查看次数