Android Question firebase push notification did not go away after clicking it.

appie21

Active Member
Licensed User
Longtime User
HI

I used the standard code from the tutorial to sent a push notification (from tutorial)

When i receive the notification and i click on it it open the app but the message did not go away( only when i swipe it away

I use android 9.0 is that the problem?

B4X:
#Region  Service Attributes
    #StartAtBoot: False
   
#End Region

Sub Process_Globals
    Private fm As FirebaseMessaging
    Dim kvs As KeyValueStore
End Sub

Sub Service_Create
    fm.Initialize("fm")
    kvs.Initialize(File.DirDefaultExternal, "datastore")
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("Message arrived")
    Log($"Message data: ${Message.GetData}"$)
    Dim n As Notification
    n.Initialize
    n.Icon = "icon"
    n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Main)
    n.Notify(1)
'    Dim notie As String
'    notie = Message.GetData
'    Log (notie)
'    CallSubDelayed2(Main, "messagefromNOTI",notie)
   
End Sub
Sub Service_Destroy

End Sub
 

DonManfred

Expert
Licensed User
Longtime User
1. Try set AutoCancel to true in the Notificationobject.
2. Maybe better use the new Notificationclass.
 
Upvote 0

appie21

Active Member
Licensed User
Longtime User
option 2 looks difficult to combine with fire base (i will take a look)
for option 1
where must Iput that code?
Thanks
 
Upvote 0
Top