#Region Service Attributes
#StartAtBoot: False
#End Region
Sub Process_Globals
Private fm As FirebaseMessaging
' Dim var As String
Dim varTitle, varBody As String
Dim dbS As SQL
Dim ruta As String
End Sub
Sub Service_Create
fm.Initialize("fm")
End Sub
Public Sub SubscribeToTopics
fm.SubscribeToTopic("floor") 'you can subscribe to more topics
End Sub
Sub Service_Start (StartingIntent As Intent)
If StartingIntent.IsInitialized And fm.HandleIntent(StartingIntent) Then Return
End Sub
Sub fm_MessageArrived (Message As RemoteMessage)
Log("Message arrived")
If File.ExternalWritable Then
ruta = File.DirDefaultExternal
Else
ruta = File.DirInternal
End If
Log($"Message data: ${Message.GetData}"$)
dbS.Initialize(ruta, "FloorFitness.db", True)
dbS.ExecNonQuery2("INSERT INTO messages VALUES (?, ?, ?, ?, ?)", Array As Object(Null, DateTime.Date(DateTime.Now),Message.GetData.Get("title"),Message.GetData.Get("body"), "0"))
' Main.porukaUpisana = True
Dim n As Notification
n.Initialize
n.Icon = "icon"
n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Main)'Otvara Main activity
n.Notify(1)
Log("Poruka upisana u bazu Arrvd")
' n. Main.varTitle = Message.GetData.Get("title")
End Sub
Sub Service_Destroy
End Sub