firebase / flutterfire

πŸ”₯ A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.68k stars 3.97k forks source link

πŸ› [firebase_messaging] Missing Default Notification Channel metadata in AndroidManifest. Default value will be used. #10020

Closed discoveruz closed 1 year ago

discoveruz commented 1 year ago

Bug report

An error occurs when a notification arrives on an Android device while exiting the program

Expected behavior

I ran the program and it works when a notification comes in the program, but after exiting the program, when it sends a back notification, the following error appears.

D/FLTFireMsgReceiver(27805): broadcast received for message
W/Bundle  (27805): Key com.google.firebase.messaging.default_notification_channel_id expected String but value was a java.lang.Integer.  The default value <null> was returned.
W/Bundle  (27805): Attempt to cast generated internal exception:
W/Bundle  (27805): java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
W/Bundle  (27805):  at android.os.BaseBundle.getString(BaseBundle.java:1208)
W/Bundle  (27805):  at com.google.firebase.messaging.CommonNotificationBuilder.getOrCreateChannel(CommonNotificationBuilder.java:478)
W/Bundle  (27805):  at com.google.firebase.messaging.CommonNotificationBuilder.createNotificationInfo(CommonNotificationBuilder.java:108)
W/Bundle  (27805):  at com.google.firebase.messaging.DisplayNotification.handleNotification(DisplayNotification.java:109)
W/Bundle  (27805):  at com.google.firebase.messaging.FirebaseMessagingService.dispatchMessage(FirebaseMessagingService.java:221)
W/Bundle  (27805):  at com.google.firebase.messaging.FirebaseMessagingService.passMessageIntentToSdk(FirebaseMessagingService.java:185)
W/Bundle  (27805):  at com.google.firebase.messaging.FirebaseMessagingService.handleMessageIntent(FirebaseMessagingService.java:172)
W/Bundle  (27805):  at com.google.firebase.messaging.FirebaseMessagingService.handleIntent(FirebaseMessagingService.java:161)
W/Bundle  (27805):  at com.google.firebase.messaging.EnhancedIntentService.lambda$processIntent$0$com-google-firebase-messaging-EnhancedIntentService(EnhancedIntentService.java:78)
W/Bundle  (27805):  at com.google.firebase.messaging.EnhancedIntentService$$ExternalSyntheticLambda1.run(Unknown Source:6)
W/Bundle  (27805):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/Bundle  (27805):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/Bundle  (27805):  at com.google.android.gms.common.util.concurrent.zza.run(com.google.android.gms:play-services-basement@@18.1.0:2)
W/Bundle  (27805):  at java.lang.Thread.run(Thread.java:923)
W/FirebaseMessaging(27805): Missing Default Notification Channel metadata in AndroidManifest. Default value will be used.

main

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  ...
  await NotificationService.init();
  await NotificationService.firebaseMessaging();
  ...
  runApp(const MyApp());
}

lib/services/notification_service.dart

import 'dart:convert';
import 'dart:developer';
import 'dart:typed_data';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';

import 'package:http/http.dart' as http;
import 'package:my_app/constants/momentous_packages.dart';

AndroidInitializationSettings initializationSettingsAndroid =
    const AndroidInitializationSettings('@drawable/notification_icon');
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
    FlutterLocalNotificationsPlugin();
late DarwinInitializationSettings initializationSettingsIOS;
late InitializationSettings initializationSettings;

class NotificationService {
  static Future<void> init() async {
    initializationSettingsIOS = const DarwinInitializationSettings(
      onDidReceiveLocalNotification: onDidReceiveLocalNotification,
    );
    initializationSettings = InitializationSettings(
      android: initializationSettingsAndroid,
      iOS: initializationSettingsIOS,
    );
    await flutterLocalNotificationsPlugin.initialize(
      initializationSettings,
      onDidReceiveNotificationResponse: selectNotification,
      onDidReceiveBackgroundNotificationResponse: selectNotificationBackground,
    );
  }

  static Future<void> firebaseMessaging() async {
    await Firebase.initializeApp();
    await FirebaseMessaging.instance.requestPermission(
      alert: true,
      badge: true,
      sound: true,
    );
    await FirebaseMessaging.instance
        .setForegroundNotificationPresentationOptions(
      alert: true,
      badge: true,
      sound: true,
    );

    if (UserInfo().token == null) {
      await FirebaseMessaging.instance.setAutoInitEnabled(false);
    } else {
      await FirebaseMessaging.instance.setAutoInitEnabled(true);
      final String? token = await FirebaseMessaging.instance.getToken();
      log('token $token');
    }

    FirebaseMessaging.onMessage.listen((RemoteMessage? message) async {
      log('onMessage listener');
      if (message != null) {
        if (message.data['priority'] == 'high') {
          await display(message);
        }
      }
    });

    FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage? message) {
      log('onMessageOpenedApp listener');

      if (message != null) {
        if (message.data["id"] != null) {
          selectNotification(NotificationResponse(
            notificationResponseType:
                NotificationResponseType.selectedNotification,
            payload: jsonEncode(message.data),
            id: int.parse(message.data["id"] ?? 0),
          ));
        } else {}
      }
    });

    FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
  }

  static Future<void> stopNotification() async {
    await FirebaseMessaging.instance.deleteToken();
    await FirebaseMessaging.instance.setAutoInitEnabled(false);
  }

  static void onDidReceiveLocalNotification(
    int id,
    String? title,
    String? body,
    String? payload,
  ) async {
    showDialog(
      context: NavigationService.context,
      builder: (BuildContext context) => CupertinoAlertDialog(
        title: Text(title ?? ''),
        content: Text(body ?? ''),
        actions: [
          CupertinoDialogAction(
            isDefaultAction: true,
            child: const Text('Ok'),
            onPressed: () async {
              Navigator.of(context, rootNavigator: true).pop();
            },
          )
        ],
      ),
    );
  }
}

Future<void> selectNotification(NotificationResponse details) async {
  log('notificationSelecter ${details.notificationResponseType}');

  if (details.payload == null) return;
  Map<String, dynamic> payload = jsonDecode(details.payload ?? '{}');

  if (details.notificationResponseType !=
      NotificationResponseType.selectedNotification) {
    if ((payload['topic']).toLowerCase() == 'survey') {
      showSurvey(int.tryParse(payload['id']));
    } else {}
  }
}

Future<void> selectNotificationBackground(NotificationResponse details) async {
  log('background notificationSelecter');
  if (details.payload == null) return;

  Map<String, dynamic> payload = jsonDecode(details.payload ?? '{}');

  if (payload['topic'].toLowerCase() == 'survey') {
    WidgetsBinding.instance.addPostFrameCallback((_) {
      showSurvey(int.tryParse(payload['id']));
    });
  }
}

Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
  log('onBackgroundMessage listener');
}

Future<void> display(RemoteMessage message) async {
  final ByteArrayAndroidBitmap? bigPicture = message
              .notification!.android!.imageUrl !=
          null
      ? ByteArrayAndroidBitmap(
          await _getByteArrayFromUrl(message.notification!.android!.imageUrl!),
        )
      : null;

  final BigPictureStyleInformation? bigPictureStyleInformation =
      message.notification?.android?.imageUrl != null
          ? BigPictureStyleInformation(
              bigPicture!,
              largeIcon: bigPicture,
            )
          : null;

  AndroidNotificationDetails androidPlatformChannelSpecifics =
      AndroidNotificationDetails(
    'my_app',
    'my_app channel',
    channelDescription: 'This is our channel',
    styleInformation: bigPictureStyleInformation,
    importance: Importance.max,
    priority: Priority.high,
    ticker: 'ticker',
    playSound: true,
    sound: const RawResourceAndroidNotificationSound('slow_spring_board'),
    icon: '@drawable/notification_icon',
    color: const Color(0xFFFFC23D1),
    largeIcon: bigPicture,
  );

  DarwinNotificationDetails iosNotificationDetails =
      const DarwinNotificationDetails(
    presentAlert: true,
    presentBadge: true,
    presentSound: true,
  );
  NotificationDetails platformChannelSpecifics = NotificationDetails(
    android: androidPlatformChannelSpecifics,
    iOS: iosNotificationDetails,
  );
  showNotification(
    platformChannelSpecifics,
    message,
  );
}

showNotification(
  NotificationDetails platformChannelSpecifics,
  RemoteMessage message,
) async {
  final int id = DateTime.now().millisecondsSinceEpoch ~/ 1000;

  if (NavigationService.currentRouteName == VocabularyActivity.routeName &&
      message.data['topic'].toLowerCase() == 'survey') {
    UserInfo userInfo = UserInfo();
    if (message.data['id'] != null) {
      userInfo.setSurveyId(int.parse(message.data['id']));
    }
  } else {
    if (NavigationService.currentRouteName != null) {
      selectNotification(
        NotificationResponse(
          notificationResponseType:
              NotificationResponseType.selectedNotificationAction,
          payload: jsonEncode(message.data),
        ),
      );
    }
    if (message.data["id"] != null) {
      await flutterLocalNotificationsPlugin.show(
        id,
        message.notification!.title,
        message.notification!.body,
        platformChannelSpecifics,
        payload: jsonEncode(message.data),
      );
    } else {
      await flutterLocalNotificationsPlugin.show(
        id,
        message.notification!.title,
        message.notification!.body,
        platformChannelSpecifics,
      );
    }
  }
}

Future<Uint8List> _getByteArrayFromUrl(String url) async {
  final http.Response response = await http.get(Uri.parse(url));
  return response.bodyBytes;
}

android/app/src/main/AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.my_app">
    <uses-permission android:name="android.permission.INTERNET"/>

    <uses-permission android:name="android.permission.RECORD_AUDIO"/>
    <uses-permission android:name="android.permission.BLUETOOTH"/>
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>

    <queries>
        <intent>
            <action android:name="android.speech.RecognitionService" />
        </intent>
    </queries>

   <application
        android:usesCleartextTraffic="true"
        android:label="Inter Nation Student"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
       <meta-data android:name="com.google.firebase.messaging.default_notification_icon"
           android:resource="@drawable/notification_icon" />
       <meta-data
           android:name="com.google.firebase.messaging.default_notification_color"
           android:resource="@color/colorPrimary" />
        <activity
            android:showWhenLocked="true"
            android:turnScreenOn="true"
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            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. -->

            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
            <intent-filter>
                <action android:name="FLUTTER_NOTIFICATION_CLICK" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data
                    android:scheme="/newNotification"
                    android:host="" />
            </intent-filter>
        </activity>
       <meta-data
           android:name="io.flutter.embedding.android.NormalTheme"
           android:resource="@style/NormalTheme"
           />
       <meta-data
           android:name="com.google.firebase.messaging.default_notification_channel_id"
           android:value="@string/default_notification_channel_id"
           android:resource="@raw/slow_spring_board"/>
       <meta-data
           android:name="flutterEmbedding"
           android:value="2" />

        <!-- 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/app/src/main/kotlin/com/example/my_app/MainActivity.kt

package com.example.my_app

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {
}

android/app/src/main/res/values/strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="default_notification_channel_id" translatable="false">my_app</string>
</resources>

Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` [βœ“] Flutter (Channel stable, 3.3.7, on macOS 12.6 21G115 darwin-arm, locale en-UZ) β€’ Flutter version 3.3.7 on channel stable at /Users/developer/flutter β€’ Upstream repository https://github.com/flutter/flutter.git β€’ Framework revision e99c9c7cd9 (4 weeks ago), 2022-11-01 16:59:00 -0700 β€’ Engine revision 857bd6b74c β€’ Dart version 2.18.4 β€’ DevTools version 2.15.0 [βœ“] Android toolchain - develop for Android devices (Android SDK version 33.0.0) β€’ Android SDK at /Users/developer/Library/Android/sdk β€’ Platform android-33, build-tools 33.0.0 β€’ Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java β€’ Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) β€’ All Android licenses accepted. [βœ“] Xcode - develop for iOS and macOS (Xcode 13.4.1) β€’ Xcode at /Applications/Xcode.app/Contents/Developer β€’ Build 13F100 β€’ CocoaPods version 1.11.3 [βœ“] Chrome - develop for the web β€’ Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [βœ“] Android Studio (version 2021.3) β€’ Android Studio at /Applications/Android Studio.app/Contents β€’ Flutter plugin can be installed from: πŸ”¨ https://plugins.jetbrains.com/plugin/9212-flutter β€’ Dart plugin can be installed from: πŸ”¨ https://plugins.jetbrains.com/plugin/6351-dart β€’ Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866) [βœ“] IntelliJ IDEA Ultimate Edition (version 2022.2.3) β€’ IntelliJ at /Applications/IntelliJ IDEA.app β€’ Flutter plugin can be installed from: πŸ”¨ https://plugins.jetbrains.com/plugin/9212-flutter β€’ Dart plugin can be installed from: πŸ”¨ https://plugins.jetbrains.com/plugin/6351-dart [βœ“] VS Code (version 1.73.1) β€’ VS Code at /Applications/Visual Studio Code.app/Contents β€’ Flutter extension version 3.52.0 [βœ“] Connected device (3 available) β€’ Redmi Note 8 Pro (mobile) β€’ onrw45lrp7o7sg8t β€’ android-arm64 β€’ Android 11 (API 30) β€’ macOS (desktop) β€’ macos β€’ darwin-arm64 β€’ macOS 12.6 21G115 darwin-arm β€’ Chrome (web) β€’ chrome β€’ web-javascript β€’ Google Chrome 107.0.5304.121 [βœ“] HTTP Host Availability β€’ All required HTTP hosts are available β€’ No issues found! ```

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Dart SDK 2.18.4
Flutter SDK 3.3.7
my_app 1.0.0+1

dependencies:
- better_player 0.0.83 [flutter cupertino_icons wakelock meta flutter_widget_from_html_core visibility_detector path_provider collection xml]
- bloc 8.1.0 [meta]
- cached_network_image 3.2.2 [flutter flutter_cache_manager octo_image cached_network_image_platform_interface cached_network_image_web]
- cupertino_icons 1.0.5
- dotted_border 2.0.0+3 [flutter path_drawing]
- equatable 2.0.5 [collection meta]
- firebase_core 2.3.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_messaging 14.1.1 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta]
- fl_chart 0.55.2 [flutter equatable]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- flutter_bloc 8.1.1 [flutter bloc provider]
- flutter_html 3.0.0-alpha.6 [html csslib collection numerus flutter]
- flutter_local_notifications 12.0.4 [clock flutter flutter_local_notifications_linux flutter_local_notifications_platform_interface timezone]
- flutter_native_splash 2.2.14 [args flutter flutter_web_plugins js html image meta path universal_io xml yaml]
- flutter_pdfview 1.2.5 [flutter]
- flutter_rating_bar 4.0.1 [flutter]
- flutter_screenutil 5.6.0 [flutter]
- flutter_svg 1.1.6 [flutter meta path_drawing vector_math xml]
- flutter_tts 3.6.1 [flutter flutter_web_plugins]
- freezed_annotation 2.2.0 [collection json_annotation meta]
- google_translator 1.0.0 [dio dio_http_cache_lts flutter]
- hive 2.2.3 [meta crypto]
- http 0.13.5 [async http_parser meta path]
- intl 0.17.0 [clock path]
- jelly_anim 0.0.7 [flutter angles bezier random_color]
- json_annotation 4.7.0 [meta]
- just_audio 0.9.30 [just_audio_platform_interface just_audio_web audio_session rxdart path path_provider async uuid crypto meta flutter]
- lottie 2.0.0 [archive flutter path vector_math]
- mask_text_input_formatter 2.4.0 [flutter]
- multi_charts 0.3.0 [flutter]
- oktoast 3.3.1 [flutter]
- package_info_plus 3.0.2 [ffi flutter flutter_web_plugins http meta path package_info_plus_platform_interface win32]
- path_provider 2.0.11 [flutter path_provider_android path_provider_ios path_provider_linux path_provider_macos path_provider_platform_interface path_provider_windows]
- percent_indicator 4.2.2 [flutter]
- pin_code_fields 7.4.0 [flutter]
- qr_flutter 4.0.0 [flutter qr]
- radar_chart 2.1.0 [flutter]
- scrollable_positioned_list 0.3.5 [flutter collection]
- sms_autofill 2.2.0 [pin_input_text_field flutter]
- soundpool 2.3.0 [flutter soundpool_platform_interface soundpool_web soundpool_macos]
- speech_to_text 6.1.0 [flutter speech_to_text_platform_interface speech_to_text_macos json_annotation clock pedantic flutter_web_plugins meta js]
- timer_count_down 2.2.1 [flutter]

dev dependencies:
- build_runner 2.3.2 [args async analyzer build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style frontend_server_client glob graphs http_multi_server io js logging meta mime package_config path pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml]
- change_app_package_name 0.1.3
- flutter_lints 2.0.1 [lints]
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters collection matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph]
- freezed 2.2.1 [analyzer build build_config collection meta source_gen freezed_annotation json_annotation]
- json_serializable 6.5.4 [analyzer async build build_config collection json_annotation meta path pub_semver pubspec_parse source_gen source_helper]

transitive dependencies:
- _fe_analyzer_shared 50.0.0 [meta]
- _flutterfire_internals 1.0.9 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta]
- analyzer 5.2.0 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml]
- angles 2.1.1 [meta]
- archive 3.3.4 [crypto path pointycastle]
- args 2.3.1
- async 2.9.0 [collection meta]
- audio_session 0.1.11 [flutter flutter_web_plugins rxdart meta]
- bezier 1.2.0 [vector_math]
- boolean_selector 2.1.0 [source_span string_scanner]
- build 2.3.1 [analyzer async convert crypto glob logging meta path]
- build_config 1.1.1 [checked_yaml json_annotation path pubspec_parse yaml]
- build_daemon 3.1.0 [built_collection built_value http_multi_server logging path pool shelf shelf_web_socket stream_transform watcher web_socket_channel]
- build_resolvers 2.1.0 [analyzer async build crypto graphs logging path package_config pool pub_semver stream_transform yaml]
- build_runner_core 7.2.7 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta path package_config pool timing watcher yaml]
- built_collection 5.1.1
- built_value 8.4.2 [built_collection collection fixnum meta]
- cached_network_image_platform_interface 2.0.0 [flutter flutter_cache_manager]
- cached_network_image_web 1.0.2 [flutter flutter_cache_manager cached_network_image_platform_interface]
- characters 1.2.1
- checked_yaml 2.0.1 [json_annotation source_span yaml]
- clock 1.1.1
- cloud_firestore_platform_interface 5.9.0 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- cloud_firestore_web 3.1.0 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js]
- code_builder 4.3.0 [built_collection built_value collection matcher meta]
- collection 1.16.0
- convert 3.1.1 [typed_data]
- crypto 3.0.2 [typed_data]
- csslib 0.17.2 [source_span]
- dart_style 2.2.4 [analyzer args path pub_semver source_span]
- dbus 0.7.8 [args ffi meta xml]
- dio 4.0.6 [http_parser path]
- dio_http_cache_lts 0.4.1 [crypto dio flutter json_serializable path quiver sqflite json_annotation]
- fake_async 1.3.1 [clock collection]
- ffi 2.0.1
- file 6.1.4 [meta path]
- firebase_core_platform_interface 4.5.2 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 2.0.1 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- firebase_messaging_platform_interface 4.2.7 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_web 3.2.7 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta]
- fixnum 1.0.1
- flutter_blurhash 0.7.0 [flutter]
- flutter_cache_manager 3.3.0 [clock collection file flutter http path path_provider pedantic rxdart sqflite uuid]
- flutter_local_notifications_linux 2.0.0 [flutter flutter_local_notifications_platform_interface dbus path xdg_directories]
- flutter_local_notifications_platform_interface 6.0.0 [flutter plugin_platform_interface]
- flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math]
- flutter_widget_from_html_core 0.8.5+3 [csslib flutter fwfh_text_style html]
- frontend_server_client 3.1.0 [async path]
- fwfh_text_style 2.22.08+1 [flutter]
- glob 2.1.1 [async collection file path string_scanner]
- graphs 2.2.0 [collection]
- html 0.15.1 [csslib source_span]
- http_multi_server 3.2.1 [async]
- http_parser 4.0.2 [collection source_span string_scanner typed_data]
- image 3.2.2 [archive meta xml]
- io 1.0.3 [meta path string_scanner]
- js 0.6.4
- just_audio_platform_interface 4.2.0 [flutter plugin_platform_interface]
- just_audio_web 0.4.7 [just_audio_platform_interface flutter flutter_web_plugins]
- lints 2.0.1
- logging 1.1.0
- matcher 0.12.12 [stack_trace]
- material_color_utilities 0.1.5
- meta 1.8.0
- mime 1.0.2
- nested 1.0.0 [flutter]
- numerus 2.0.0 [characters]
- octo_image 1.0.2 [flutter flutter_blurhash]
- package_config 2.1.0 [path]
- package_info_plus_platform_interface 2.0.1 [flutter meta plugin_platform_interface]
- path 1.8.2
- path_drawing 1.0.1 [vector_math meta path_parsing flutter]
- path_parsing 1.0.1 [vector_math meta]
- path_provider_android 2.0.21 [flutter path_provider_platform_interface]
- path_provider_ios 2.0.11 [flutter path_provider_platform_interface]
- path_provider_linux 2.1.7 [ffi flutter path path_provider_platform_interface xdg_directories]
- path_provider_macos 2.0.6 [flutter path_provider_platform_interface]
- path_provider_platform_interface 2.0.5 [flutter platform plugin_platform_interface]
- path_provider_windows 2.1.3 [ffi flutter path path_provider_platform_interface win32]
- pedantic 1.11.1
- petitparser 5.1.0 [meta]
- pin_input_text_field 4.2.0 [flutter]
- platform 3.1.0
- plugin_platform_interface 2.1.3 [meta]
- pointycastle 3.6.2 [collection convert js]
- pool 1.5.1 [async stack_trace]
- process 4.2.4 [file path platform]
- provider 6.0.4 [collection flutter nested]
- pub_semver 2.1.3 [collection meta]
- pubspec_parse 1.2.1 [checked_yaml collection json_annotation pub_semver yaml]
- qr 2.1.0 [meta]
- quiver 3.1.0 [matcher]
- random_color 1.0.6-nullsafety [flutter]
- rxdart 0.27.7
- shelf 1.4.0 [async collection http_parser path stack_trace stream_channel]
- shelf_web_socket 1.0.3 [shelf stream_channel web_socket_channel]
- sky_engine 0.0.99
- soundpool_macos 2.2.0 [flutter soundpool_platform_interface]
- soundpool_platform_interface 2.1.0 [flutter meta plugin_platform_interface]
- soundpool_web 2.2.0 [flutter flutter_web_plugins soundpool_platform_interface http]
- source_gen 1.2.6 [analyzer async build dart_style glob meta path source_span yaml]
- source_helper 1.3.3 [analyzer collection source_gen]
- source_span 1.9.0 [collection path term_glyph]
- speech_to_text_macos 1.0.2 [flutter plugin_platform_interface speech_to_text_platform_interface]
- speech_to_text_platform_interface 2.0.1 [flutter meta plugin_platform_interface]
- sqflite 2.2.0+3 [flutter sqflite_common path]
- sqflite_common 2.4.0+2 [synchronized path meta]
- stack_trace 1.10.0 [path]
- stream_channel 2.1.0 [async]
- stream_transform 2.1.0
- string_scanner 1.1.1 [source_span]
- synchronized 3.0.0+3
- term_glyph 1.2.1
- test_api 0.4.12 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher]
- timezone 0.9.0 [path]
- timing 1.0.0 [json_annotation]
- typed_data 1.3.1 [collection]
- universal_io 2.0.4 [collection crypto meta typed_data]
- uuid 3.0.7 [crypto]
- vector_math 2.1.2
- visibility_detector 0.3.3 [flutter]
- wakelock 0.6.2 [flutter meta wakelock_macos wakelock_platform_interface wakelock_web wakelock_windows]
- wakelock_macos 0.4.0 [flutter flutter_web_plugins wakelock_platform_interface]
- wakelock_platform_interface 0.3.0 [flutter meta]
- wakelock_web 0.4.0 [flutter flutter_web_plugins js wakelock_platform_interface]
- wakelock_windows 0.2.1 [flutter wakelock_platform_interface win32]
- watcher 1.0.2 [async path]
- web_socket_channel 2.2.0 [async crypto stream_channel]
- win32 3.1.1 [ffi]
- xdg_directories 0.2.0+2 [meta path process]
- xml 6.1.0 [collection meta petitparser]
- yaml 3.1.1 [collection source_span string_scanner]


darshankawar commented 1 year ago

Thanks for the report @discoveruz When you say, error occurs while exiting the program, do you mean, when the app has been terminated and then notification arrives which throws the said error ? What's the OS version of your Android device ? Can you also try the plugin example on same device and see if using it, you get same error as reported ?

fabiansanchez18 commented 1 year ago

From Firebase documentation. https://github.com/firebase/quickstart-android/blob/214da24d38a2af723f6953c4f1c18a7ad3d68d08/messaging/app/src/main/AndroidManifest.xml#L24-L26

Add that tag inside the application tag on AndroidManifest.xml

    <meta-data
        android:name="com.google.firebase.messaging.default_notification_channel_id"
        android:value="@string/default_notification_channel_id" />

you can substitute the value on android:value="@string/default_notification_channel_id" /> for android:value="" />

google-oss-bot commented 1 year ago

Hey @discoveruz. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 1 year ago

Since there haven't been any recent updates here, I am going to close this issue.

@discoveruz if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

maotm commented 1 year ago

Hi, I think this is related to [Firebase_messaging] duplication bug and two threads launched by background handler #9912, as described also here: https://stackoverflow.com/questions/74430484/firebase-background-message-handler-in-flutter-spawns-duplicate-isolate-and-runs Anyway, you should create a notification channel to be used with FirebaseMessaging.onBackgroundMessage (when the app is terminated or suspended). It is when the main() is called twice... and that's why it will not find the default notification channel...