Android Question filebase cloud message limit

peacemaker

Expert
Licensed User
Longtime User
Hi, All

Who already used Google Firebase cloud messaging ?
If the each message is limited by some digit around 4K bytes - how to control it ? If message prepared is longer ? Will it be some sending error or what ?
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Did you tried to send 16kb?
It should raise an error cause it is more than the allowed size
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Not tried, and asking. So, we must check the JSON generated text to be sent before sending...
How to be sure if data is variable....
OK, thanks, DonManfred
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
And the answer is:
B4X:
Sub AppStart (Args() As String)
   Dim sb As StringBuilder
   sb.Initialize
   For i = 1 To 16000
     sb.Append("a")
   Next
   SendMessage("general", "title", sb.ToString)
   StartMessageLoop
End Sub

Output:
{"error":"MessageTooBig"}
[jobname=fcm, success=false, username=
, password=, errormessage=Bad Request, target=class b4j.example.main
, taskid=1, req=anywheresoftware.b4h.okhttp.OkHttpClientWrapper$OkHttpRequest@2d98a335, tag=java.lang.Object@16b98e56
, httputils2service=null]
 
Upvote 0
Top