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:
[project]/android/build.gradle file. and apply plugin to [project]/android/app/build.gradle.android\app\src\main\java\com\example\appdev\MainActivity.javaandroidmanifest.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>
_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,
);
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.
Hi @jayvasantjv
could you please provide your updated flutter doctor -v
and your flutter run --verbose?
Thank you
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.
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
Any update for this issue..?
or it will be fix when stable version updated???
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
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 HackAdd Same Above in firebase_messaging plugins .. AndroidManifest.xml
also define value in string.xmlThat 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
@ankii9600 onResume and onLoad works on your android device?
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 trucoAgregue lo mismo arriba en plugins firebase_messaging. AndroidManifest.xml
tambi茅n define el valor en string.xmlEso funcion贸 para m铆.
Necesitas hacer un poco de trabajo
Que debo agregar en el String?
Most helpful comment
this is a bug in firebase messging plugin .. as they dont provide default notification channel id ..
for fix :
Next Add this to AndroidManifest file
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