I am using Firebase Cloud Messaging for my App -
I have seen many apps like Youtube, Paytm using a bell icon in their app notification Panel, and all the notifications that they push are saved inside the app notification panel.
I also want to make the same panel like this what approach should I use.
We can Create a database and whenever a notification is received just save the data in DB and retrieve it back when the notification activity is called.
Related
I'm creating an ecommerce app and I want to send promotional notifications to users from firebase cloud messaging. I want to show all the notifications in recycler view in notification screen using adapter can anyone tell how do I save all incoming notifications and display them in notification screen
If you want to show all notifications you need to save those in
local database when you receive and fetch all on required screen.
You can use Room database for the same.
You can ask the backend developer to save all notifications at
backend side and fetch those by an API.
Approach 1
See If you are sending a notification from the firebase console, Then you need to save that notification in the local DB While It receives in Mobile Firebase Messaging Service Class. (but It's not a good approach, Because user loss notification in case of clear data for app or reinstall app)
Approach 2
If you are sending notifications using some API or firebase function Then you can create one collection of Notifications and save notifications every time while sending And Fetch notifications from the same collection.
I have developed a game with unity and I have used 'Firebase Cloud Messaging' for push notification.
I have one problem. when I clear the received notification in tray, it seems like the message related to it is also deleted. so 'MessageReceived' is not called when I open the app.
I experienced this problem on android. Haven't tested it on ios yet.
I use firebase admin sdk for sending messages.(written with node js)
is there a way to clear notification tray without deleting the message?
thanks for any help in advance
There is some extra setup required to route notifications when the app is not running on Android.
See the Firebase docs for more information
Quote from documentation:
When the app is not running at all and a user taps on a notification, the message is not, by default, routed through FCM's built in callbacks. In this case, message payloads are received through an Intent used to start the application.
Messages received while the app is in the background have the content of their notification field used to populate the system tray notification, but that notification content will not be communicated to FCM. That is, FirebaseMessage.Notification will be a null.
Basically you need to use the custom launch activity bundled with Firebase Messaging instead of the default UnityPlayerActivity. This activity is called MessagingUnityPlayerActivity can can be found inside libmessaging_unity_player_activity.jar. You'll need to create a AndroidManifest.xml file to instruct the app to use this custom activity instead of the default Unity one.
Needed a suggestion/idea.
I have to send the push notification to the android app when the data is changed/updated in the server.
I have got a news app, so whenever the news is being updated in the server, the user should get the push notification and when they click the notification, the app should open the link of the news in the app.
What would be the best approach to do so?
I know a bit about FCM, and have played sometime with it, learned about sending the notification from the FCM console, to all the devices using the topic.
Just wondering how can I implement it, rather than using the console, but by just updating the data in the server, and notification should be sent to all the devices which have got the app installed.
You can use your server to send FCM messages to your app without having to use the firebase console manually.
Just a simple API call from the server will push notifications (or messages) to the required devices.
For more information read the documentation on FCM Server.
There are multiple alternatives for opening activity of your choice after clicking the notification.
IMO, a good approach would be to send 'data' field from the FCM server instead of 'notification' field so that the method onMessageReceived will always get called. Inside that method, you can build your custom notification and set the intent to activity of your choice.
Another approach would be to check for extras in the launcher activity and if there is something coming from notification, open the activity of your choice and perhaps finish the launcher activity.
I want to display a notification to my android app from this website. I want to display the blue square that says Season 2018 is closed as a notification on my android app. This quote is added by the admin of the page so I want when he adds more, to display them as notifications. Is there a way without having access to the database?
UPDATE
Or if it's any way to display the notification when the admin updates the database.I've seen firebase notifications are good but i want the admin not to go to a firebase page,instead he will continue uploading from his webpage(there are more than one admin also).
In Android, for push notification, you can use Firebase notification. It's easy way to add notification functionality in Android app.
https://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
Open this link and follow these steps to implement push notification.
My android FCM notification is perfectly working when the app is running. I am also getting data notifications through Freebase console.
But when my app is in the background, notifications are separately displayed and if the user clears the notification without a tap on the notification, we can't do anything.
Is it possible to store the notification in shared preferences when the app is in background ?
This is possible with GCM, but I have no idea about FCM.
and other thing i am sending notification with data through freebase console. perfectly data come also when user tap on notification but without tap on notification user clear notification i cant do anything.
i want to store notification when user not tap on notification and clear notification
please help me