I want to embed data directly inside of a GCM (Google Cloud Message) in order to help my application skip a round trip to my server.
Google says the total data payload needs to fit inside 4kb. Data is sent using [key,value] pairs. Assuming I did something like this:
String key = "key";
String data = "data";
Message message = new Message.Builder().addData(key, data).build();
sender.send(message, regId, 5);
How can I know if the String data
is less than 4kb? To my knowledge there's no way to really do a String.getSize()
or similar.
Link to the documentation if curious: http://developer.android.com/training/cloudsync/gcm.html#embed