Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[firebase_messaging 6.0.1] W/FirebaseMessaging(11255): Missing Default Notification Channel metadata in AndroidManifest. Default value will be used. #1478

Closed
alter123 opened this issue Nov 22, 2019 · 8 comments
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. type: bug Something isn't working

Comments

@alter123
Copy link

alter123 commented Nov 22, 2019

Describe the bug
During onLaunch & onMessage background messages the following error has been thrown: W/FirebaseMessaging(11255): Missing Default Notification Channel metadata in AndroidManifest. Default value will be used.

To Reproduce
Steps to reproduce the behavior:

  1. Add firebase_messaging to pubspec.yaml.
  2. Add class path to [project]/android/build.gradle file. and apply plugin to [project]/android/app/build.gradle.
  3. Add .Application class as mentioned here to android\app\src\main\java\com\example\appdev\MainActivity.java
  4. Configure androidmanifest.xml as follows:
     <application
        android:name=".Application"
        android:label="appdev"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize"
            android:screenOrientation="portrait"> 
            <meta-data
                android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
                android:value="true" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <intent-filter>
                <action android:name="FLUTTER_NOTIFICATION_CLICK" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <meta-data
                android:name="com.google.firebase.ml.vision.DEPENDENCIES"
                android:value="ocr" />
        </activity>
    </application>
  1. Configure firebase in main as follows:
    _firebaseMessaging.configure(
      onMessage: (Map<String, dynamic> message) async {
        // Notification while the app is open

        print('onMessage: $message');
        _handlePushNotification(message);
      },
      onLaunch: (Map<String, dynamic> message) async {
        // Clicked on notification

        print('onlaunch: $message');
        _handlePushNotification(message);
      },
      onResume: (Map<String, dynamic> message) async {
        // App running in background

        print('onResume: $message');
        _handlePushNotification(message);
      },
      onBackgroundMessage: myBackgroundMessageHandler,
    );
  1. Send message using curl as mentioned here

Expected behavior
The messages for onMessage is recieved but, the onResume and onLaunch should be called upon receiving notification. Although the error has been thrown.

Additional Context
I've referenced for the same from #1478 #88 #343 #1357 , but none seemed to work.

@alter123 alter123 added the type: bug Something isn't working label Nov 22, 2019
@iapicca
Copy link

iapicca commented Nov 22, 2019

Hi @jayvasantjv
could you please provide your updated flutter doctor -v
and your flutter run --verbose?
Thank you

@iapicca iapicca added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Nov 22, 2019
@alter123
Copy link
Author

alter123 commented Nov 22, 2019

logs from flutter doctor
logs from flutter run --verbose

Sorry for limited data in --verbose output since my shell can list only that much data. I hope all the requried details are captured.

@digarahayu17
Copy link

I got same issue even i add meta data in manifest and create strings.xml that contain default channel id still get same error. I use flutter sdk stable version....
Anybody how to make it work in android Oreo 8.0 up to...
In android lower 8.0 all is work fine

@digarahayu
Copy link

Any update for this issue..?
or it will be fix when stable version updated???

@ankii9600
Copy link

this is a bug in firebase messging plugin .. as they dont provide default notification channel id ..
for fix :

class MyApplication : FlutterApplication(), PluginRegistrantCallback {
    override fun onCreate() {
        super.onCreate()
        this.registerChannel();
        FlutterFirebaseMessagingService.setPluginRegistrant(this)
    }

    override fun registerWith(registry: PluginRegistry) {
        GeneratedPluginRegistrant.registerWith(registry)
    }


    @TargetApi(Build.VERSION_CODES.O)
    private fun registerChannel(){
        val channel: NotificationChannel = NotificationChannel(
                getString(R.string.default_notification_channel_id),
                "CiggyGhar Delivery",
                NotificationManager.IMPORTANCE_HIGH
        ).also {

            it.setSound(Uri.parse("android.resource://${packageName}/${R.raw.deduction}"), it.audioAttributes)
        }
        val manager:NotificationManager = getSystemService(NotificationManager::class.java) as NotificationManager
        manager.createNotificationChannel(channel)
    }
}

Next Add this to AndroidManifest file

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

also define value in string.xml

but this did'nt work...
A little Hack


Add Same Above in firebase_messaging plugins .. AndroidManifest.xml
also define value in string.xml

That worked for me ..
You need to do a little work around

@digarahayu
Copy link

digarahayu commented Nov 27, 2019

this is a bug in firebase messging plugin .. as they dont provide default notification channel id ..
for fix :

class MyApplication : FlutterApplication(), PluginRegistrantCallback {
    override fun onCreate() {
        super.onCreate()
        this.registerChannel();
        FlutterFirebaseMessagingService.setPluginRegistrant(this)
    }

    override fun registerWith(registry: PluginRegistry) {
        GeneratedPluginRegistrant.registerWith(registry)
    }


    @TargetApi(Build.VERSION_CODES.O)
    private fun registerChannel(){
        val channel: NotificationChannel = NotificationChannel(
                getString(R.string.default_notification_channel_id),
                "CiggyGhar Delivery",
                NotificationManager.IMPORTANCE_HIGH
        ).also {

            it.setSound(Uri.parse("android.resource://${packageName}/${R.raw.deduction}"), it.audioAttributes)
        }
        val manager:NotificationManager = getSystemService(NotificationManager::class.java) as NotificationManager
        manager.createNotificationChannel(channel)
    }
}

Next Add this to AndroidManifest file

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

also define value in string.xml

but this did'nt work...
A little Hack

Add Same Above in firebase_messaging plugins .. AndroidManifest.xml
also define value in string.xml

That worked for me ..
You need to do a little work around

i already try Missing Default Notification Channell was not appears...
but notification not working onResume and onLaunch even i send channel id on payload...
i try to send wrong channel_id there is log missing channel id, but when i send payload with correct channel id not log anymore and onResume , onLaunch not fire
FYI i use
flutter sdk stable version

@marinat
Copy link

marinat commented Dec 5, 2019

@ankii9600 onResume and onLoad works on your android device?

@br-programmer
Copy link

este es un error en el complemento de mensajería firebase ... ya que no proporcionan la identificación del canal de notificación predeterminada ...
para solucionarlo:

class MyApplication : FlutterApplication(), PluginRegistrantCallback {
    override fun onCreate() {
        super.onCreate()
        this.registerChannel();
        FlutterFirebaseMessagingService.setPluginRegistrant(this)
    }

    override fun registerWith(registry: PluginRegistry) {
        GeneratedPluginRegistrant.registerWith(registry)
    }


    @TargetApi(Build.VERSION_CODES.O)
    private fun registerChannel(){
        val channel: NotificationChannel = NotificationChannel(
                getString(R.string.default_notification_channel_id),
                "CiggyGhar Delivery",
                NotificationManager.IMPORTANCE_HIGH
        ).also {

            it.setSound(Uri.parse("android.resource://${packageName}/${R.raw.deduction}"), it.audioAttributes)
        }
        val manager:NotificationManager = getSystemService(NotificationManager::class.java) as NotificationManager
        manager.createNotificationChannel(channel)
    }
}

Siguiente Agregar esto al archivo AndroidManifest

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

También defina el valor en string.xml

pero esto no funcionó ...
Un pequeño truco

Agregue lo mismo arriba en plugins firebase_messaging. AndroidManifest.xml
también define el valor en string.xml

Eso funcionó para mí.
Necesitas hacer un poco de trabajo

Que debo agregar en el String?

@firebase firebase locked and limited conversation to collaborators Aug 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants