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

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

Related

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.

How to make sound alert when new notification came and app is in foreground using RN firebase push notification

I am trying to get notification sound in foreground but it not works, to achieve that i have added default sound property at server side and its working fine in kill mode and background mode of app but not working in foreground mode. expecting quick response from community. Thanks

Push notification to iOS not working when message received

I have a Worklight app doing push notifications. Sending the push causes the notification to appear in the notification bar on both Android and iOS as expected. If the push is received while the app is running, it calls the message handler function as it is supposed to.
The issue I'm having is that if you launch the app by tapping on the notification on iOS, the message handler never gets called if another push is sent while the app is running. I have to exit the app and kill it completely, then relaunch the app from the launcher. Then if the push is received while the app is running, it will call the message handler.
This only occurs on iOS. The app will respond to a received message on Android while the app is running, even if the app has been launched by tapping on the notification.
EDIT:
I did struggle to verbalize the scenario, couldn't find the right words that made sense, but the steps you have done Idan are largely correct for what I'm trying to do. We are doing tag based notifications, so that is different that what you have done. We are also using PersistentCookieAuthentication as they wanted push notifications to be sent without the user having to explicitly logging in.
We are currently using WL build 6.2.0.01-20141216-0427
We've tried it on a couple of different models, an iPhone 4s running 8.0.2, and an iPhone 5 running 8.1.2.
Edit based on the edited question:
Tag-based notifications do not require any login, as it is the device that is to be subscribed to any tags that you define in application-descriptor.xml; it is not login-based, so any type of login that you are doing it irrelevant. The push will be sent to any device (app...) that was subscribed to your tag using the subscribeTag API.
I did another test in iOS using a broadcast-based notification (it's basically like tag-based notifications). I kept the app in the background and sent a notification. Tapping on the incoming notification in the notification bar brought the app to the foreground, which then displayed the alerts of the incoming notification.
You can try it with this application: https://www.dropbox.com/s/l2yk2pbvykrzfoh/broadcastNotificationsTest.zip?dl=0
Make sure to place your own .p12 certificate and pushSender password.
I've been trying to understand your scenario... I suspect you've left out something or need to better word the problem description.
Here's what I've tried using MobileFirst Platform 6.3 (no drastic push changes in iOS between 6.2 and 6.3) and iPhone 6 running iOS 8.1.2.
Launched sample push notifications app (which uses event source-based notifications) on device
Logged-in > Subscribed
Quit application
I then sent a notification by invoking the adapter in the Studio
The notification arrived and displayed in the notification bar
Tapping the notification launched application
Logged-in
The notification alerts were then displayed.
I then moved the application to the background.
Sent another notification, which was displayed in the notification bar upon arrival
Tapping this second notification brought the application to the background, displaying the alerts
I then kept the application in the background.
Sent a third notification
In this case, because the application is in the foreground, the notification did not display in the notification bar -- as expected -- and instead the alerts were displayed right away.
If your scenario is different than the above, such as: you're not even using event source-based notifications but rather broadcast- or tag-based notifications, or your application flow differs, etc then please edit the question with a more precise description.
When you edit the question, also mention the following:
Worklight version and build number
Device model
Used iOS version
I am aware of one possible issue (APAR #PI31988) that is currently under investigation, where the underlying native code dispatches the message before the JavaScript framework is ready to handle it, thus no message is displayed. This was found to happen in slower devices such as iPhone 4.

How to display a notification in worklight when returning to the foreground?

I am using push notification in worklight 6.2 in one of my apps.
I have a issue regarding receiving of notification. i receive notification when i am in the application .
When i close my app or made my app go background, i receive notification in the status bar and when i click on that,its taking me to the app ask for the authentication which is provided in the app and then goes to the inbox where all the messages are listed the new message is displayed .
But when i receive the notification when my apps is in background and see the notification in status bar and without clicking that notification if i opened the application and see the inbox page ,the message is not displayed because the function which will be executed when receiving notification is not called.
I need to give solution to avoid this. Is there any way or option to display the notification which is received when the app is in background and when the app is opened without opening the notification in status bar.
Thanks in advance
Perhaps you could use a the Cordova resume event, from which you will call the pushNotificationReceived() function as the callback function.
document.addEventListener("resume", pushNotificationReceived, false);
The basic premise is that if a notification was received while you were in the background, then once returning to the foreground the above should executed and the notification will be displayed.
Again, this is just the basic premise and you'll probably need to modify the pushNotificationReceived() implementation to account for what happens when you get back to the foreground but there are no notification (you could implement some logic to check that...) and various other scenarios, as you encounter them.

Handle unread or untapped notifications in flutter app

My Flutter app receives notifications well. I need however a solution for the following two problems:
Problem 1: My app is in background, I receive a notification, the user brings the app to foreground without tapping on the notification. I want the app to handle the untapped notification. The data from the notification needs to be read and the notification needs to disappear.
Problem 2: Very similarly, but this time the app is closed. Again the user opens the app without tapping on the notification. I want the app to handle the untapped notification. The data from the notification needs to be read and the notification needs to disappear.
How should I best fix this problem?
Thanks!

Resources