kaiesh/GCM_PHP

Message NULL from GCM if we send a push notification with special characters

Opened this issue · 1 comments

Hi! I setup all the push notification process using your PHP server implementation.
It works correctly except when I push a message that contains special characters like è é ì @ etc.
I see my web server log and I have a 200 OK from Google GCM.

ipaddress - - [01/Oct/2013:14:06:12 +0200] "GET /gcm/push.php?pushmsg=prova+con+caratteri+speciali+%26%21%3F%2C.-%E8%E9%F9%E0%E7%40&action=push HTTP/1.1" 200 467 "http://www.mysite.it/gcm/push.php?pushmsg=%E8&action=push" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36"

But when the message arrive on my app and I take it in my Bundle extras, if I see

String messageReceived = extras.getString("message");

it is null. In other cases, it works correctly. Could depend on server implementation?
Thanks a lot.

Guido

I had same problem ...
In your php file from server set that your message is encoded to utf8 ...
array( "message" => utf8_encode($message));
and in your Android application access your message like this:
message = Html.fromHtml(new String(data.getString("message").getBytes("UTF-8"))).toString();