UTF8 support on android: the notification text (on android only) is shown with "???" #461
Description
Hi,
Have you ever tested non-english notifications on android? I tried both Hebrew and Chinese, and it doesn't work.
I'm sending the same notification text to GCM and APNS, and it is shown correctly on iphone, but not android.
See the attached printscreens:
On android it is shown with "?????" :
On iOS it is shown correct:
I captured a bug report and this is what I see:
12-27 12:38:55.650 21639 21679 D PushPlugin_GCMIntentService: replace key collapse_key with collapse_key
12-27 12:38:55.650 21639 21679 D PushPlugin_GCMIntentService: background
12-27 12:38:55.650 21639 21679 D PushPlugin_GCMIntentService: message =[yoav local chrome ????? ???? ?????]
12-27 12:38:55.650 21639 21679 D PushPlugin_GCMIntentService: title =[???? ???]
12-27 12:38:55.650 21639 21679 D PushPlugin_GCMIntentService: contentAvailable =[null]
When I sent to GCM, I use AppEngine, and I logged the exact post message:
2015-12-27 12:38:58.172
com.multiplayer.PostMessage sendPost: Sending POST message to url: https://gcm-http.googleapis.com/gcm/send
Message: {"registration_ids":["fQ3Dg8_jcmM:APA91bEFChZPmKPOD9wjWzj8kxGQ75AVyfYZ0rs4EIt51fByS4yH65XcI5hCrSqjflcLzlXO7y_FAWXX3MdbNvM3acLLG3LZ6YcstTGA2VyWMnXGm6bWtmrKp3JvACYnGUfhy6H2hAUM"],"data":{"title":"משחק חדש","message":"yoav local chrome הזמין אותך למשחק","matchId":"6635885969081947891","notificationOpponentId":"5720693702393856","updatedTimestampMillis":"1451237937965","notId":"575528018","matchInfoJson":"{"gameVariant":0,"matchId":"6635885969081947891","createdTimestampMillis":"1451237937965","updatedTimestampMillis":"1451237937965","isReservedAutoMatch":false,"notificationOpponentId":"0","state":"N4IgLgrgTgdgkjAJgUwB4CFkDMD2VkCyOAbsiAFwAMANONPEmhQIy3JIECGYAxgBYBlHnmQBnCjAgAbKbQC2JZADkIcgEbIoLWlE5IccgcmSIKISgDoArABYA7ADYAHAE4bLgMyV7lOx6sgtFKcomBEpBQA2qCiyGAAKvQUoJCwCCioLAC+WdQxcckgANbIAJ5modxktMScUhBk5KAoUmCchVA4AO4UNCDCUr25IGo4nFCm5JGRIAAagSALIAC61DNLtCtri5uby8s5WasgwaECbWCNwMM80PgwYOdVhZWXhS1tHd29tANDtKNxpNpnMNotVutduDtmCVgdhqcwAA1ACWohRaikyHiOGSNzu7GRaIxWJxeKyQA\u003d\u003d","lastPlayerIndex":0,"nextPlayerIndex":1,"playersInfo":[{"playerId":"5720693702393856","displayName":"yoav local chrome","avatarImageUrl":"http://www.multiplayer-gaming.com/v1/dist/imgs/avatar38.gif"},{"playerId":"4791088564928512","displayName":"Yoav Zibin","avatarImageUrl":"http://graph.facebook.com/10152824135331125/picture?square\u003dsquare"}]}"},"notification":{"title":"משחק חדש","body":"yoav local chrome הזמין אותך למשחק"}}
I 2015-12-27 12:38:58.353
com.multiplayer.PostMessage sendPost: POST returned: {"multicast_id":5627025799402887992,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1451237938334570%224af683224af683"}]}
I'm pretty sure the problem is here:
I believe this:
Object json = extras.get(key);
should be:
String json = URLDecoder.decode(extras.get(key).toString(), "UTF-8");
See also:
http://stackoverflow.com/questions/14677821/received-gcm-message-shows-with-garbled-text
(I'm using phonegap build, so I can't really test if this solution works :))