The remote notifications from my server to my B4a App. always when I clicked the notification, the app open on "main", can I change this activity default in the server?
The problem is this.. I received in both, "Foreground" and "Background",.. In foreground i can set the badge number of icon of the app. but if the notification is in background... I can see the "System tray" notification, but not update the badge of the Application Icon.
Sub fm_MessageArrived (Message As RemoteMessage)
If Message.GetData.Get("action") = "upd" Then
Dim badge As ShortcutBadger
badge.Initialize
badge.applyCount(Message.GetData.Get("badge"))
End If
End Sub
Here the example code from the Tutorial. It shows how to create the notification and it uses Main. (you also can set any other activity)
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)
End Sub
The other notification you see from the system is bound to your firebase project id respectively to your Packagename.
The system uses your packagenames starting-intent to start your app from the notification. This is your Main activity per default.
If your app is started from main then you can check the startingintent and forward the user to another activity if you want.
Always start with the B4J code to send the message. Once you get it working, and you will, you can switch to other ways of sending the message and find the differences in the messages created.
Important: Only send data messages. Otherwise Android takes care which causes some side effects. Just show the .net code. I use fcm a lot via php and don't have any issues with it.