Reputation: 35
I am using GCM server library to send the messages from my server.
message = new Message.Builder()
.timeToLive(10)
.delayWhileIdle(false)
.addData("json", sendMsgData)
.build();
As GCM supports 4kb message size, I would like to know what is the actual size a sendMsgData can be of?
Is 4kb allowed on sendMsgData or are there other factors that I need to count and reduce my actual sendMsgData size?
Please refer following from the google documentation below, if the json below is subject to the limit of 4kb, then the actual message of the user which is "data" below will be less than 4kb...
Here is the example of a JSON-formatted request that includes TTL on google gcm doc site:
{
"collapse_key" : "demo",
"delay_while_idle" : true,
"registration_ids" : ["xyz"],
"data" : {
"key1" : "value1",
"key2" : "value2",
},
"time_to_live" : 3
},
Upvotes: 2
Views: 997
Reputation: 393801
Only the lengths of the keys and values inside the "data" element count toward the 4096 bytes limit. The predefined keys (such as "collapse_key", "registration_ids", etc...) and their values don't count.
The last time I tested this limit (which was a couple of years ago), it seemed that it wasn't even a 4096 bytes limit, but 4096 character limit, which is a higher limit (since you can use, for example, 4096 characters of a non-English language that take more than one byte each).
I have to admit, though, that I didn't test this limit with a JSON content type. I tested it with a URL encoded content.
Upvotes: 1