Adding Google Cloud Messagin (GCM) for Android - Registration process

后端 未结 1 523
死守一世寂寞
死守一世寂寞 2020-11-29 09:44

I have been struggling with GCM implementation for some weeks now, but how I really want to get to understand how it works I decided to take \'baby steps\'.

First of

相关标签:
1条回答
  • 2020-11-29 10:37

    Is my answer with source code at your question How to implement a GCM Hello World for Android using Android Studio is not enough for you to create two simple GCM projects (server-side and client-side) yet? :)

    Of course, the sample code I used is just for a very basic case "server app sends, client app receives and displays message".

    To sum up, you need to do the following steps:

    1. Create a new project at Google Developers Console . At this step, for simplicity, you just need to take note of 2 values: Project Number, which will be used as SENDER_ID in my client project; and API server key (created at Credentials), which will be used as API_KEY in my server project.
    2. Create a new simple Android project for server side (with basic source code as my answer in your previous question).
    3. Create a new simple Android project for client side (with basic source code as my answer in your previous question, I customized from the original source at Google Cloud Messaging - GitHub).
    4. Run the client app, you will get the registration token (means that your device has successfully registered). Then, paste (hard-code) this token at CLIENT_REGISTRATION_TOKEN variable in server app.
    5. Run the server app, and check the result (client app received the message or not)

    Hope this helps!

    P/S: I don't use any appengine-web.xml file

    0 讨论(0)
提交回复
热议问题