I had the same problem. Non-character ASCII characters that were corrupted upon receipt on the Android client. I personally think this is a problem in implementing the GCM server library.
In the Android GCM library, I see a method:
com.google.android.gcm.server.Sender.sendNoRetry(Message, List<String>)
This method performs the following
HttpURLConnection conn = post(GCM_SEND_ENDPOINT, "application/json", requestBody)
They should at least specify "application / json; charset = utf-8 " either regardless of which encoding they used or even better, but forced it to use UTF-8. Isn't that a BIG problem?
Digging even deeper, I find a method:
com.google.android.gcm.server.Sender.post(String, String, String)
which does:
byte[] bytes = body.getBytes()
Why do they use the default encoding for the platform? Moreover, it is hardly compatible with the default encoding for devices.
Work around
Pass the following property as the JVM argument " -Dfile.encoding = UTF-8 ". This instructs Java to use UTF-8 as the default encoding for the platform when performing actions such as "blah",. GetBytes (). This is bad practice, but what can you do when it is some other library?
Yepher
source share