jigargm
jigargm

Reputation: 155

Not receiving message from GCM server

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.

Upvotes: 3

Views: 3975

Answers (2)

kamil
kamil

Reputation: 579

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.

Upvotes: 0

user1574879
user1574879

Reputation: 61

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.

Upvotes: 6

Related Questions