Sub Process_Globals
Private fm As FirebaseMessaging
Private notification As NB6
Private tmpTopic As String
End Sub
Sub Service_Create
fm.Initialize("fm")
End Sub
Public Sub SubscribeToTopics
' fm.SubscribeToTopic("SPN") 'you can subscribe to more topics
'
fm.UnsubscribeFromTopic("ios_SPN_TEST")
fm.UnsubscribeFromTopic("ios_SPN")
fm.UnsubscribeFromTopic("SPN_TEST")
fm.UnsubscribeFromTopic("SPN")
'
Dim r As ResultSet = Starter.FileManager1.SQL1.ExecQuery("SELECT NomeClasse FROM classi")
Do While r.NextRow
tmpTopic = r.GetString("NomeClasse").Replace("°","").Replace(" ", "").Replace(".","").Replace("(","").Replace(")","").Replace("'","").Trim
fm.UnsubscribeFromTopic(tmpTopic)
Loop
tmpTopic = Starter.FileManager1.LeggiValore("Classe")
If tmpTopic <> "" Then
tmpTopic = tmpTopic.Replace("°","").Replace(" ", "").Replace(".","").Replace("(","").Replace(")","").Replace("'","").Trim
Log("SottoScritto a: " & tmpTopic)
fm.SubscribeToTopic(tmpTopic)
End If
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")
If Not(IsPaused(Home)) Then
CallSub(Home, "SincronizzaDBInterno")
End If
notification.Initialize("default", Application.LabelName, "HIGH").AutoCancel(True).SmallIcon(Application.Icon)
notification.BigTextStyle(Message.GetData.Get("titolo"), Message.GetData.Get("summary"), Message.GetData.Get("corpo"))
Dim n As Int = Starter.FileManager1.LeggiValore("IdNotifica")
n = n + 1
notification.Build(Message.GetData.Get("titolo"), Message.GetData.Get("corpo"), "", Home).Notify(n)
Starter.FileManager1.AggiornaFile("IdNotifica", n)
End Sub
Sub Service_Destroy
End Sub