Sub Process_Globals
Private fm As FirebaseMessaging
Dim NotifyCount As Int
End Sub
Sub Service_Create
fm.Initialize("fm")
End Sub
Public Sub SubscribeToTopics
fm.SubscribeToTopic("general") 'you can subscribe to more topics
End Sub
Sub Service_Start (StartingIntent As Intent)
If StartingIntent.IsInitialized Then fm.HandleIntent(StartingIntent)
Sleep(0)
Service.StopAutomaticForeground 'remove if not using B4A v8+.
End Sub
Sub fm_MessageArrived (Message As RemoteMessage)
Log("Message arrived")
Log($"Message data: ${Message.GetData}"$)
Dim n As Notification
n.Initialize
n.Icon = "icon"
n.Sound = True
NotifyCount=NotifyCount+1
Dim Tag As String = NotifyCount & " | " & Message.GetData.Get("title") & "|" & Message.GetData.Get("body")
Main.Tag = Tag
n.SetInfo2(Message.GetData.Get("title"), Message.GetData.Get("body"), Tag, Main)
n.Notify(NotifyCount)
End Sub