Android Question Firebase Messages With Parameter

taylorw

Active Member
Licensed User
As my testing firebase messages is working well.
And i have a question is can i pass any parameter at background?
 

DonManfred

Expert
Licensed User
Longtime User
no But you can use Notificationbuilder to generate more complex Notifications....
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
can i pass any parameter at background?

Messages are limited to 4 KB. You can pass data like you want as long as it is as string.

B4X:
Private Sub SendMessageDevice(Devtoken As String, MessageContent As String)
   
    Dim Job As HttpJob
    Job.Initialize("SendMessage", Me)
    Dim m As Map = CreateMap("to": $"${Devtoken}"$)
    Dim data As Map = CreateMap("mc": MessageContent)
    m.Put("data", data)
    Dim jg As JSONGenerator
    jg.Initialize(m)
    Job.Tag=jg
    Job.PostString("https://fcm.googleapis.com/fcm/send", jg.ToString)
    Job.GetRequest.SetContentType("application/json;charset=UTF-8")
    Job.GetRequest.SetHeader("Authorization", "key=" & API_KEY)
  
End Sub

MessageContent (as String) -> put what you need here (and extract it in Message_Received). Take care that you send STRINGS (e.g encode it as Base64 string, JSON string, etc.) and decode it when received.
 
Upvote 0
Top