3

I am working on a project that notifies an android application using push notifications using Google Cloud Messaging. I have implemented the application server in PHP. When i run the android application, the device gets the registration id from the GCM server and it sends the registration id to the PHP server(application server). But i get the following httpresponse from the server :

{
    "multicast_id": 7015234441922271670,
    "success": 1,
    "failure": 0,
    "canonical_ids": 0,
    "results": [{
        "message_id": "0:1344007383866721%2adac3a0ad8b3148"
    }]
}

So, the message is getting delivered since the success flag is 1, but when i display the message in the android app, it displays nothing(null). I am not able to figure out what happens with the message.

WarrenFaith
  • 57,492
  • 25
  • 134
  • 150
jigargm
  • 155
  • 3
  • 15

2 Answers2

6

I have the exact same question ... this is what i'm trying this weekend: http://developer.android.com/guide/google/gcm/gcm.html

excerpt:

Note: If your organization has a firewall that restricts the traffic to or from the Internet, you'll need to configure it to allow connectivity with GCM. The ports to open are: 5228, 5229, and 5230. GCM typically only uses 5228, but it sometimes uses 5229 and 5230. GCM doesn't provide specific IPs. It changes IPs frequently. We recommend against using ACLs but if you must use them, take a broad approach such as the method suggested in this support link.

  • Thank you so much, my wifi was blocking these ports and I was debugging and rebuilding for hours. This finally helped me! Thanks so much. I was using **PushPlugin and Phonegap** Build and normal Phonegap CLI to rebuild many times, till I **switched to using my mobile data connection, which didnt have these ports blocked - and it worked!** :D – AmpT Jan 28 '14 at 21:32
  • Excellent || I was trying to figure out this problem for almost 6 hours and now i am able to get notification from GCM. Thank you so much. It really Really works. My organization was using "Cyberoam" as a firewall which was restricting port for For The GCM push notification. I Used mobile hot spot from other device and Now it is working great. – Jigar Sep 05 '14 at 10:14
0

Add this in your php code

$data = array(
'registration_ids' => array($reg),
'data' => array(
'type' => 'New',
'title' => 'App Name',
'flag' => '1',
'msg' => 'New Message')

Hope this will help.

kamil
  • 579
  • 4
  • 15