Firebase FCM notifications click_action payload
If your app is in background, Firebase will not trigger onMessageReceived(). Why.....? I have no idea. In this situation, I do not see any point in implementing FirebaseMessagingService.
According to docs, if you want to process background message arrival, you have to send 'click_action' with your message.
But it is not possible if you send message from Firebase console, only via Firebase API.
It means you will have to build your own "console" in order to enable marketing people to use it. So, this makes Firebase console also quite useless!
There is really good, promising, idea behind this new tool, but executed badly.
I suppose we will have to wait for new versions and improvements/fixes!
How to specify sound and click_action in firebase cloud function
Ok, I finally managed to gather bits and pieces here and there to make it work. Don't understand why the docs do not have a clear and direct path to such a common requirement.
exports.sendComNotification = functions.firestore .document('Comunicados/{comID}') .onCreate((snap, context) => { const doc = snap.data(); const msg = doc.title; var message = { notification: { title: 'Comunicado da Diretoria!', body: msg }, data: { title: 'Comunicado', body: msg }, android: { notification: { sound: 'default', click_action: 'FLUTTER_NOTIFICATION_CLICK', }, }, apns: { payload: { aps: { badge: 1, sound: 'default' }, }, }, topic: "Comunicados" };
return admin.messaging().send(message) .then((response) => {
console.log('Successfully sent message:', response); return }) .catch((error) => { console.log('Error sending message:', error); return });
});
Related Topics
Android Manifest Restrict to Tablets
Value of a Global Variable Is Reset After It Is Initialised in Valueeventlistener
No Adapter Attached; Skipping Layout
Get Nfc Tag with Ndef Android Application Record (Aar)
Error: Failed to Resolve: Com.Android.Support:Appcompat-V7:29.0.1'
Navigation Drawer with Backword Compatibility Android
Can't Get File Uri from Intent Onactivityresult
How to Keep a Countdowntimer Running Even If the App Is Closed
Replacing Glreadpixels with Egl_Khr_Image_Base for Faster Pixel Copy
Mediaplayer.Setdatasource Causes Ioexception for Valid File
Why "This App Has Been Built with an Incorrect Configuration" Error Occured in Some Phones
Android: Volley Http Request Custom Header
Java.Lang.Noclassdeffounderror: Android.Support.V7.Appcompat.R$Styleable
Why the View Keeps Flashing When Using Jetpack Navigation with Compose
Clear Recent Apps Wipe the Apps Memory and My Receiver Stopped Working