[firebase_messaging] set notification channel id (notification in background Not working)
Describe the bug the function onResume and onLunch not working on android platform, while they work fine on IOS, i receive the following message on console instead of printed strings in those functions:
"W/FirebaseMessaging(24847): Missing Default Notification Channel metadata in AndroidManifest. Default value will be used."
onMessage function works fine, the problem is when the app is in background
To Reproduce try to print something in onResume and onLunch functions
Expected behavior the functions be called on work fine as they do on IOS
Additional context my guess is that it has something to do with android notification channel id which should be added in android manifest
when i add that to manifest the message change to :
"Notification Channel set in AndroidManifest.xml has not been created by the app. Default value will be used."
@MahmoodBakhshayesh Thanks for flagging this, looks like we don't currently have support for message channels. We should add this.
Feel free to submit a PR if you have a solution.
https://github.com/FirebaseExtended/flutterfire/issues/47 https://github.com/FirebaseExtended/flutterfire/pull/53 https://github.com/FirebaseExtended/flutterfire/issues/116 https://github.com/FirebaseExtended/flutterfire/issues/125
Any clear documents to setup firebase messaging? I follow 5.1.6 instruction. Facing the above issue
Any updates?
Any update for this issue..? or it will be fix when stable version updated???
Any update for this issue..?
Any updates for this?
Is there any update for this issue?
any update?
Did someone find a workaround for this issue? Thanks
Does anyone have a solution?
I had the problem that the method registered with "onBackgroundMessage" was not called. Here I found that if the message sent from my Nodejs backend had a "notification" entity, the "onBackgroundMessage" was not called. Only the "data" entity may be contained here.
Wrong way:
const message = {
token: 'myToken',
notification:{
title: 'My Title',
body: 'The body data',
},
data: {
time: 'My data',
value: '2',
}
}
Right way:
const message = {
token: 'myToken',
data: {
time: 'My data',
value: '2',
}
}
If I send the "right way" message, background function will be called.
It could be the solution for #1269
adding this to my sent data worked for me 'click_action': 'FLUTTER_NOTIFICATION_CLICK'
Hi @MahmoodBakhshayesh did @ajnaf solution worked for you? Thank you
Hey, I am also facing the same issue. I can confirm that:
adding this to my sent data worked for me 'click_action': 'FLUTTER_NOTIFICATION_CLICK'
does not solve this issue.
Hello, just to give some insight on this.
That message is a information message only. If no channel is specified via your Android manifest then FCM creates & uses it's own notification channel (since they're required in later Android versions). The channel is only used to impact how the notification is shown - from memory this is a default priority notification with sound enabled.
If you created a custom channel (via https://pub.dev/packages/flutter_local_notifications for example), you could specify that channel ID in the manifest and the notification would use your custom one.
If you provide a channel ID to the notification and it doesn't exist on the device, FCM falls back to it's own channel (and you see that message).
Our plan is to make this more user-friendly to work with, however for now you can safely ignore this message. I'll leave open to track though.
@Ehesp As you mentioned if no channel is specified then FCM should create and use its own notification channel, hence while sending the notification to the app, if we do not include an Android Notification Channel param then the it should be attributed to the default channel that FCM has created, but that that is not the case. When I do not specify any custom notification channel in my project and send a notification without the Android Notification Channel param even then I get this error when the app is not in foreground.
@ayush221b it's not an error, it's just a message from FCM telling you it's using it's own channel. You can get around this for now by creating your own channel and assigning the channel ID to the message body when you send it from the server.
I had the problem that the method registered with "onBackgroundMessage" was not called. Here I found that if the message sent from my Nodejs backend had a "notification" entity, the "onBackgroundMessage" was not called. Only the "data" entity may be contained here.
Wrong way:
const message = { token: 'myToken', notification:{ title: 'My Title', body: 'The body data', }, data: { time: 'My data', value: '2', } }Right way:
const message = { token: 'myToken', data: { time: 'My data', value: '2', } }If I send the "right way" message, background function will be called.
It could be the solution for #1269
hello, i've deleted the the notification and it still doesnt read my onbackgroundmessagehandler, what do i do
Hello,
I've reading a lot of comments since 6 months and still cannot figure out how to make onBackgroundMessage working. OnLaunch, OnResume and OnMessage works perfectly. If onBackgroundMessage still not working I will have to change framework :(
Someone successed to deal with it ? A sample app ?
Thanks you