Firebase data message in flutter - firebase

Hi guys I'm looking for some help about Data message in firebase which we can handle from app side how i can listen them on foreground background and terminate state and also how i can save on local storage not notification message.
The message were received on foreground but not on background and terminate state and can't store on local storage

Related

retreive fcm message body when the app is in the background xamarin.android

i am trying to make a messaging app using xamarin.forms. i was capable of retrieving the message when the app is in the foreground using onMessageReceived. but i am having a hard time retrieving the message when the app is in the background without clicking on the notification received. for example, i receive a message when my app is in the background, then i decide to open the app, i want the new message to appear in the list of messages. i searched a lot, but all i could find is about onMessageReceieved which occurs when the app is in the foreground, and Intent.Extras that appears to happen when the notification is clicked when the app is in the background. how should i deal with it? thanks in advance

How to get push notification custom data from Firebase when app is terminated

Currently, my app gets all the push notifications when in the background and terminated state (currently implementing local notification).
When I send custom data in the Firebase console, all the data is correctly passed to the app when it is run foreground and background. However, when the app is terminated, the push message comes but the data is not retrieved successfully(only null data).
Is there any way to solve this? I don't understand why the push comes but then data does not.
It would be really nice if you help out!
If you app startup from FCM message click when your app terminated, you need to custom this
FirebaseMessaging.instance.getInitialMessage().then((message) { //do something })
For FCM push you will get data when app was in killed stae and push notification come and user tap on notification then you will get data in launcher screen.

Open Flutter app based on notification data?

How can I open the flutter app based on notification data using FirebaseMessaging?
So, when I tap on a notification (received through Firebase Messaging), the message handler should evaluate the data and based on them open the app. At the moment it is asynchronous, meaning the app starts and the notification handler continues the work.
It is important to know, that Navigator.push can't be used, as there is an important app setup screen, which checks the auth state and so on at app start. How to solve this issue?
When you tap a notification from the device's notification centre the operating system will launch the app, provided of course you have set up Firebase messaging correctly as per instructions the onLaunch or onMessage functions will get called.
Now since firebase messaging configured pretty much as early as possible, typically inside the main entry of the flutter app you will need to store the notification somewhere first. This can be a global state object created before anything that uses it.
final notifications = <NotificationData>[]; // globally accessible (i.e. via Provider)
Then in the handler of the messages...
NotificationData onMessage(Map<String, dynamic> data) {
notifications.add(NotificationData.fromJson(data));
}
The flutter app will start and the MaterialApp will get built. At this point you can have a loading screen to check if the user is authenticated or any new messages in the notifications global state. If there are you can route to a page to display the notification, or get the user to sign in then route to the notification page.

Firebase Cloud Functions - Send Notification user when they are online again?

I'm using fcm to send user notification and its triggedred by writing data to firebase database. But when user is offline notification send but never received and user cannot see it after they back online. How to send notification in all conditions.
Example: If user online send message normally but if user offline wait until user online and send them. How can I do this?
According to documents firebase cloud messaging already support what i want.
If the device is not connected to FCM, the message is stored until a
connection is established (again respecting the collapse key rules).
When a connection is established, FCM delivers all pending messages to
the device. If the device never gets connected again (for instance, if
it was factory reset), the message eventually times out and is
discarded from FCM storage. The default timeout is four weeks, unless
the time_to_live flag is set.
So FCM service wait until client device connected again.And sen notification when cliend connected. But if user hasnt connected for four weeks message deletes itself and never sent.
https://firebase.google.com/docs/cloud-messaging/concept-options#ttl

UWP Background task not able to send Push Notification

I have a foreground app sending a raw push notification to a background task in another device. When background task receives the notification, it will reply by sending a raw push notification to original foreground app. My problem is the foreground app never receives any notifications from the background task.
To debug, I made the foreground and background channel ID the same and run both the foreground app and background task on the same windows desktop PC but still the foreground app never receives the push notification from the background task. The foreground app actually can receive the original message from itself but didn't process it so the background task handled it so I know the foreground app is receiving notifications without issues. The push notification routine is common in both so I know the code works and the status codes were all successful. So it seems the raw push notification initiated by the background tasks seems to get lost somewhere.
What could be the problems?
Are you sure the task is registered correctly?
And did you check project rome? that can maybe solve this in an easier way?
https://learn.microsoft.com/en-us/windows/uwp/launch-resume/connected-apps-and-devices

Resources