Android Question Firebase notifications see the last message

gregorio_adrian_gimenez

Active Member
Licensed User
Longtime User
I wanted to check how I can do when I send several notifications, when I receive them, it shows me only the last one, and I need to see them all. Thank you
 

KMatle

Expert
Licensed User
Longtime User
First you need to know what kind of message you send (receive). I first thought that there is just a message, but there are two different types (or three if you want to be more precise): https://www.b4x.com/android/forum/t...oreground-background-data-notification.73356/ and in what state you app is.

If you send a notification message (see my thread what I mean here) Android pushes the notification automatically and you don't have much control over it. It's just "shoot & forget" (from the view of Google).

Generally it's better to send/receive data messages. You recive just the data, store the message and throw a notification when you want. Often you have a "system message" to control your app to do something (like download new data or so). With this you can create your own message system (some for the users, some internal only).
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Use a different id for each notification in the n.Notify line:
B4X:
Sub fm_MessageArrived (Message As RemoteMessage)
   Log("Message arrived")
   Log($"Message data: ${Message.GetData}"$)
   Dim n As Notification
   n.Initialize
   n.Icon = "icon"
   n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Main)
   n.Notify(1)
   Log(Message.SentTime)
End Sub
 
Upvote 0
Top