User
User

Reputation: 1236

Steps to receive GCM push notification message from app server

We are developing apps both in IOS and Android. GCM push notification has been enabled for IOS and its working fine now. The package name for both the platforms are going to be the same.

I was given SERVER API KEY and SENDER ID by ios developer to set up gcm for android. While looking for the steps, I came across https://developers.google.com/cloud-messaging/android/client.

I kept to myself that the steps listed in the contents need to be done to set up GCM for android (please correct me if I am wrong).

  1. Get Config file and add it to Android project
  2. Set up Google play services (I added gcm in my project dependency)
  3. Add entries to Manifest file
  4. Check for google play services APK
  5. Obtain registration token.

"An Android application needs to register with GCM connection servers before it can receive messages"

"The client app should store a boolean value indicating whether the registration token has been sent to the server." - My backend team told me I dont need to send them anything I have to just configure gcm in the app and the app will receive messages from backend.

So, My question is Do I need to have RegistrationIntentService and MyInstanceIDListenerService. Also, Do I have to define my InstanceIDListenerService in Manifest?

Our backend uses device id to send push notifications to devices so they dont need registration token to be sent to them as we send device id. So in this case, Should I register my app with GCM using RegistrationIntentService and InstanceIDListenerService? if so, should the app keep the registration token with itself. Is this registration needed?

Upvotes: 0

Views: 567

Answers (1)

Bob Snyder
Bob Snyder

Reputation: 38289

GCM supports three types of downstream (server-to-client) messaging: send to a specific device (also called "simple" or "targeted"), send to a topic, or send to a device group. Your question says, "our backend uses device id to send push notifications to devices". It is not clear what "device ID" is and which type of messaging you intend to use. Your backend team has told you that you "don't need to send them anything". If that is true, I don't know where they are getting the "device ID".

Each of the three types of messaging provided by GCM require client devices to register with GCM and obtain a registration token. To send a message to a specific device, the registration token is effectively the "device ID". So yes, you need to implement something similar to the RegistrationIntentService and InstanceIDListenerService described in the documentation.

The description in the documentation about needing to send the registration token to the App Server is misleading. That is only required for targeted messaging. The documentation for receiving topic messages states: "Note that, for topic messaging it's not required to send the registration token to your app server; however, if you do send it, your server can verify the validity of the token and get more information about the app that created it."

Upvotes: 1

Related Questions