Hello my friends,
I use this code for firebase notification but even if i click notification, it does not hide. Moreover i can not dismiss it and always pesists, till OS throws a messages that my app is running on my background.
p.s. notification persist AND on lower android versions
p.s.1 Huawei P10 with 8.0.0
I use this code for firebase notification but even if i click notification, it does not hide. Moreover i can not dismiss it and always pesists, till OS throws a messages that my app is running on my background.
B4X:
#Region Service Attributes
#StartAtBoot: False
#End Region
Sub Process_Globals
Dim fm As FirebaseMessaging
End Sub
Sub Service_Create
fm.Initialize("fm")
Service.AutomaticForegroundMode=Service.AUTOMATIC_FOREGROUND_ALWAYS
End Sub
Public Sub SubscribeToTopics
fm.SubscribeToTopic("ypiresia") 'you can subscribe to more topics
fm.SubscribeToTopic("anakoinosi")
End Sub
Sub Service_Start (StartingIntent As Intent)
If StartingIntent.IsInitialized And fm.HandleIntent(StartingIntent) Then Return
Sleep(0) 'allow the MessageReceived event to be raised.
Service.StopAutomaticForeground
StopService(Me)
End Sub
Sub fm_MessageArrived (Message As RemoteMessage)
Log("Message arrived")
Log($"Message data: ${Message.GetData}"$)
Dim n As Notification
n.Initialize2(n.IMPORTANCE_DEFAULT)
n.AutoCancel=True
n.Icon = "icon"
n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Main)
Service.StartForeground(1,n)
End Sub
Sub Service_Destroy
End Sub
p.s. notification persist AND on lower android versions
p.s.1 Huawei P10 with 8.0.0
Last edited: