#Region Service Attributes
#StartAtBoot: False
#End Region
Sub Process_Globals
Private fm As FirebaseMessaging
Dim mano As Bitmap
' Dim value As String
End Sub
Sub Service_Create
fm.Initialize("fm")
End Sub
Public Sub SubscribeToTopics
fm.SubscribeToTopic("all") '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: ID ${Message.MessageId}, Data ${Message.GetData}"$)
Log("Message="& Message)
Dim value As String
Dim map As Map :map.Initialize
map = CreateMap("body2":value,"title1":value)
For Each key As String In map.Keys
value = map.Get(key)
Log($"${key}:${value}"$)
Next
Dim jgen As JSONGenerator
jgen.Initialize(map)
Dim n As NB6
mano = LoadBitmapResize(File.DirAssets, "mano.png", 24dip, 24dip, False)
n.Initialize("default", Application.LabelName, "DEFAULT").AutoCancel(True).SmallIcon(mano)
n.Build(Message.GetData.Get("title"), Message.GetData.Get("body"), jgen.ToString, Main).Notify(4)
End Sub