1

how to create push notification in Android using GCM or either C2DM i have tried and check some sites and didn't get exact answer.i need to know how it works.Can any one provide me good tutorial on push notification

Could anybody help me. Thanks!!

  • http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/ – Dhaval Parmar Apr 22 '13 at 09:07
  • @thanks could you please explain in brief –  Apr 22 '13 at 09:10
  • Use GCM, C2DM is deprecated. You could start from the [google gcm tutorial](http://developer.android.com/google/gcm/index.html). The [gettin started](http://developer.android.com/google/gcm/gs.html) is well written. A good way to learn how it works is use the google [gcm demo application](http://developer.android.com/google/gcm/demo.html). – Atropo Apr 22 '13 at 09:07
  • thanks but i have some doubts how could i pass the sender id and authentication token –  Apr 22 '13 at 09:09

2 Answers2

8

Its Depend on your requirement what you have to do.

here is sample of C2DM: in this sample android device is registered wtih server after that server send massage to all device. so there is one way communication(server to Android device)

enter image description here

So all things are done at server side. just download this tutorial. Both Server side(PHP) and Android code are available.

Edited:

you got application key from Google services which you have to put at server side.

SENDER_ID – Google project id which you have to send when you want to register your device with server.

Ranjit
  • 5,130
  • 3
  • 30
  • 66
Dhaval Parmar
  • 18,812
  • 8
  • 82
  • 177
  • thanks but how could i pass the application id and sender id? here i don't have to register right –  Apr 22 '13 at 09:32
  • @ Dhawal Sodha lot of thanks +1 for you can you provide any example code –  Apr 22 '13 at 09:43
  • @priya2134412: for test this you need both server(you have to install WAMP in your PC) and android plateform. just download from here: http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/ – Dhaval Parmar Apr 22 '13 at 09:46
  • i want to pass the application id and sender id to websevice right, –  Apr 22 '13 at 10:28
0

You can use GCM demo app supported by Google. One needs to install GCM libs using SDK manager and then create API keys in Google APIs console. Follow instructions from the link and you can create an app that receives push notifications from GCM server. I did try this and it worked even on my Android emulators. You need to use Emulator that targets Google APIs though.

Garrett Hyde
  • 5,409
  • 8
  • 49
  • 55
Prasad
  • 349
  • 2
  • 6