#Region Service Attributes
'#StartAtBoot: False
#StartAtBoot: True
#ExcludeFromLibrary: True
#End Region
Sub Process_Globals
Private fm As FirebaseMessaging
'https://www.b4x.com/android/forum/threads/firebasenotifications-push-messages-firebase-cloud-messaging-fcm.67716/
End Sub
Sub Service_Create
'This is the program entry point.
'This is a good place to load resources that are not specific to a single activity.
fm.Initialize("fm")
Log("fb service create")
End Sub
Sub Service_Start (StartingIntent As Intent)
Log("fb service start")
If StartingIntent.IsInitialized And fm.HandleIntent(StartingIntent) Then Return
End Sub
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Log("app error")
Return True
End Sub
Public Sub SubscribeToTopics
Log("sub topics")
fm.SubscribeToTopic("general") 'you can subscribe to more topics
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("tel"), Message.GetData.Get("adres"), Main)
n.SetInfo("X-"&Message.GetData.Get("title"), "X-"&Message.GetData.Get("body"), Main)
'n.SetInfo("X-"&Message.GetData.Get("title"), "X-xxxx", Main)
n.Notify(1)
End Sub
Sub Service_Destroy
End Sub