Create push notification in android

2019-01-25 00:39发布

问题:

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!!

回答1:

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)

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.



回答2:

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.