'THe service call "FirebaseMessaging"
#Region Service Attributes
#StartAtBoot: False
#End Region
Sub Process_Globals
Private fm As FirebaseMessaging
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("Mensage recibido")
Log($"Datos del mensaje: ${Message.GetData}"$)
Dim n26 As NB6
Dim b As Bitmap
b.Initialize(File.DirAssets,"icono64x64.png")
n26.Initialize("default", Application.LabelName, "DEFAULT").AutoCancel(True).SmallIcon(b)
n26.Build(Message.GetData.Get("title"), Message.GetData.Get("body"), "tag1", Main).Notify(4) 'It will be Main (or any other activity) instead of Me if called from a service.
End Sub
Public Sub SetApiRestToken
REST.API.FirebaseCloudMessagingToken = fm.Token
Log(fm.Token)
End Sub
Sub Service_Destroy
End Sub