I've tried below code but it didn't work, the program is treating the newnotif variable as a string, any ideas?
B4X:
Dim jsongen As JSONGenerator
jsongen.Initialize(CreateMap("data":SBN.Notification))
Dim jsonstr As String = jsongen.ToString
Dim jp As JSONParser
jp.Initialize(jsonstr)
Dim pmap As Map = jp.NextObject
Dim newnotif As Notification = pmap.Get("data")
Not sure what is SBN.
If you are using FirebaseNotifications library, then part of the code is as follow:
B4X:
Sub fm_MessageArrived (Message As RemoteMessage)
Log("Message arrived")
Log($"Message data: ${Message.GetData}"$)
Dim n2 As Notification
n2.Initialize2(n2.IMPORTANCE_DEFAULT)
n2.Icon = "icon"
n2.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Main)
n2.Notify(1)
End Sub
Updated tutorial: https://www.b4x.com/android/forum/threads/b4x-firebase-push-notifications-2023.148715/ Clarification: The nice thing about FCM is that your app doesn't need to run in order to receive messages. The FirebaseMessaging receiver will be started by the OS when a new message...
Hi everybody, I am playing with the NotificationListener Library and while I can get the already available keys from the SBN object (Id, PackageName and tickerText), I am trying to get all the other keys from the object: Sub Listener_NotificationPosted (SBN As StatusBarNotification)...