#Region Service Attributes
#StartAtBoot: False
#End Region
Sub Process_Globals
Private fm As FirebaseMessaging
Dim kvs As KeyValueStore
End Sub
Sub Service_Create
fm.Initialize("fm")
kvs.Initialize(File.DirDefaultExternal, "datastore")
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.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Main)
n.Notify(1)
' Dim notie As String
' notie = Message.GetData
' Log (notie)
' CallSubDelayed2(Main, "messagefromNOTI",notie)
End Sub
Sub Service_Destroy
End Sub