3

I am working on an android app that will recieve push notifications from the GCM server. I am using php as the 3rd-party server.

I've a few questions.

  1. When I send request to gcm server from my php script it gives me the following response

     {"multicast_id":8799227316277290616,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1341388064110557%5d17b789f9fd7ecd"}]}
    

    Now the response seems fine but you can see a % sign in the message_id. Is that ok? if it's not than how am I able to recieve the correct message_ID?

  2. When I use json_decode in my php script and echo this multicastid it gives me something like this

    8.7992273162773E+18
    

    and I am sure it will give the same type of value when I'll echo message_id also. So why it is not echoing the correct value?

  3. My last question is that when I send this request which seems right and open my android application there is no notification there. Is it caused by the above errors or there is some other problem?

Bo.
  • 2,547
  • 3
  • 24
  • 36
Mj1992
  • 3,404
  • 13
  • 63
  • 102
  • I am getting the response as {"multicast_id":8544536079568251693,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1349952207538943%87d780faf9fd7ecd"}]} But the message is not published to device. What is might be the problem? – Ramaraju.d Oct 11 '12 at 10:52
  • You might not be recieveing values in the device correctly. Check your parameter names that you are sending from the server and recieveing in the device. – Mj1992 Oct 12 '12 at 11:34
  • Hi Mj, I checked the parameters , They are ok but Still same problem persisting. – Ramaraju.d Oct 13 '12 at 06:33
  • I would suggest you to post it as another question.I hope more people will be able to have a look at it and help you solve the problem more quickly. – Mj1992 Oct 13 '12 at 08:35
  • Yes i got it. Thank you so much – Ramaraju.d Oct 15 '12 at 10:05

2 Answers2

3

I had a similar issue with C2DM. The reason was that the android app name was not the same for which I requested the quota. It got fixed once the corrected the package name.

Amol Gupta
  • 704
  • 1
  • 8
  • 26
  • sorry I did not understand what you are actually suggesting.I am running the program on emulator so does it work on emulator? and I didn't got what you said about the app name matching. – Mj1992 Jul 04 '12 at 13:43
  • the emulator must have android market installed. therefore you might need to download a special AVD for that...default one might now work. Also the package name of the android app must be the same for which you had registered with google. – Amol Gupta Jul 04 '12 at 13:48
  • i dont have android market installed on my emulator do I need to buy an android marketplace account for that or google provides it for free(the special AVD)? and google didn't asked me for the application package name when I was signing up for the android gcm api. Are you talking about the market place registration? Because I've haven't registered for the marketplace yet. – Mj1992 Jul 04 '12 at 14:17
  • package name registration is no more required in GCM, it was required in C2DM. Sorry for pointing out that, my bad. No there is no official AVD with market/play installed. You need to test push on device only, else there are some hacked versions of AVD with marketplace you can find with few google searches. – Amol Gupta Jul 04 '12 at 15:34
  • ok thnx for the info.can you also help me out for the other two questions? – Mj1992 Jul 04 '12 at 16:16
  • 1
    you might want to check out android.amolgupta.in/2012/07/google-cloud-messaging-gcm-tutorial.html for complete implementation of GCM along with code. – Amol Gupta Jul 08 '12 at 08:59
  • I am sending the notification request from my php server to the gcm server which results in success:1 but still i don't get it on my emulator.One thing that you told is the marketplace installation problem? only this is affecting it or there are some other reasons also? pls help i am stuck in this from about a week. – Mj1992 Jul 08 '12 at 09:23
  • were you able to generate a valid device ID on emulator?if not, you can try installing an AVD with marketplace. check http://www.howtogeek.com/howto/21862/how-to-enable-the-android-market-in-the-google-android-emulator/ – Amol Gupta Jul 08 '12 at 09:39
0

In my case, android application was not running so the push notifications can't be received. I started the app and then I could receive messages.

ChannaB
  • 439
  • 4
  • 13