Is "Upstream Google Cloud Messaging and User Notifications Sign-up" compulsory? - android

Is signup for "Upstream Google Cloud Messaging and User Notifications Sign-up" at link "https://services.google.com/fb/forms/gcm/" compulsory to get notification from server app to device?
I have created sample app and sending the sample notification from server. i m getting "OK" response along with message_id, i assume that means my message has been accepted by GCm bit the message is not getting delivered to registered Device? I read somewhere with GCM, registration to the link above is required. I tried that too but i didnt get any response back from google. am i missing anything?
Harshil.

Yes, it is compulsory. When sending a message through GCM, you need to specify a SENDER_ID which is given to you when you create a Project inside, and for this, you have to sign up. So even if you got an OK response, I doubt you specified a correct SENDER_ID so this message probably got discarded.
Maybe this might help:
How to send location of the device on server when needed

As of June 2014, sign-up is no longer required for GCM upstream user notifications (among other features).
There's a post on the Android Developer Blog with more info. Specifically:
At Google I/O we announced the general availability of several GCM
capabilities, including the GCM Cloud Connection Server, User
Notifications, and a new API called Delivery Receipt. This post
highlights the new features and how you can use them in your apps. You
can watch these and other GCM announcements at our I/O
presentation.

Related

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).
Get Config file and add it to Android project
Set up Google play services (I added gcm in my project dependency)
Add entries to Manifest file
Check for google play services APK
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?
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."

how to get SNS working in Android?

how to get SNS working in Android?
We have an app that sends SNS messages to iOs apps already (I personally am only working with the App side). And have extended it to send Android messages. It works fine for iOS and thinks it is sending to Android correctly but no message ever actually shows up on the Android device.
I am registering with the backend by getting the Settings.Secure.ANDROID_ID and sending that to the web service that registers it with Amazon SNS.
I have turned on all the permissions that I can (I don't need to specifically ask for permission do I?, how would I do that).
Basically the setup we have is I hand our web service a device id and it registers with Amazon and the web service sends the notifications out (but I am never seeing them).
Is there anything else I need to do or check on the client side?
Amazon SNS for push messaging on android instructions is the same as normal GCM on android.
You must follow the directions here:
GCM Getting Started - covers the google console set up and will provide you with the :
SenderId, for use in the android app code. (This is the Google Console's Project #)
the api key, for use in SNS server setup
Implementing GCM Client - covers client library, getting the registration ID, setting up a wakeful service and broadcast receiver for creating notifications or whatever you'd like you app to do when it receives a push.
You should also read thru amazon's documentation Getting Started with Google Cloud Messaging for Android which summarizes the the previous two links.
I am registering with the backend by getting the Settings.Secure.ANDROID_ID and sending that to the web service that registers it with Amazon SNS.
This is not correct. By using the GCM client library, call the following methods to get the real registration ID (sns likes to call them an endpoint) that you can send to the web service that registers it with Amazon SNS. There should be no need to use Settings.Secure.ANDROID_ID at all for push on android.
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(someContext);
String registrationId = gcm.register(senderId);
I have turned on all the permissions that I can (I don't need to specifically ask for permission do I?, how would I do that).
see Implementing GCM Client for the required permissions that you must include in your AndroidManifest.xml. And no, you don't need to specifically ask for permission since it would be in the AndroidManifest.xml but you could ask the user on first app start with a dialog or some other UI. You may also choose to let the user disable push for you app via a settings screen if your app has one.
Is there anything else I need to do or check on the client side?
You should confirm that you are able to get registration ids (perhaps some logging)?
And then with those ids, test your implementation. Here is a question that was asked a while ago that will help you use a rest client to send pushes with your registration ids and api_key (SNS login not needed).
How to push notification from rest client for testing purpose

Can I depend on GCM service to create a big instant messaging application ?

If I want to create an instant messaging application using android, is it a good and efficient to use the Google Cloud Messaging API ?
There are a lot of mentions in GCM documentation and tutorial saying that is no guarantee of order and success receive of messages. Like here:
Note that since there is no guarantee of the order in which messages
get sent, the "last" message may not actually be the last message sent
by the application server.
I suggest you use this as a call to update user chat e.g. when your app get a GCM you request your server-side to get the new messages but not transfer messages by GCM itself also because you have some dayly limits as well.
See more here: http://developer.android.com/google/gcm/index.html
I found the mention above here: http://developer.android.com/google/gcm/server.html. At description of collapse_key here: http://developer.android.com/google/gcm/server.html#params
Yes, it works for Google and you won't have to maintain servers. If your message is short, in can be included in the GCM message. Otherwise the GCM could be a payload to notify your app to check for a new message.

How to confirm successfull communication between my server and GCM server

I am following Google official tutorial for demo Google Cloud Messaging from http://developer.android.com/google/gcm/demo.html . I set up the gcm-demo-client and gcm-demo-server.
Now, when I run applicaiton, its works well. The device is registered to my server. Then when I click sent message in my server to invoke, its says the message is sent. I assume the process sent message correctly to GCM since its their official sample server for tutorial.
However, my message is not delivered to client applications.
When I see report status about my project in GOOGLE API CONSOLE, the request per day info are 0. Should not it be changed if my server sent message to GCM to deliver to registered device?
Is there anyway to confirm that my server message has been successfully delivered to GCM first? If i confirm this, then can confirm that message is being late.
I tried with both server and browser API key. DO it take time to deliver?
Thanks in advance for your support and any help.
The demo in the tutorial works well. Finally, I was able to get the push message. However, the message was delivered late then expected in about 15 min. Why is it happening so? I don't think its reliable to use.

Android GCM delivery monitoring

I am developing mobile client for emailing service. One of the key features is notifications about new messages in the mailbox. As recommended by GCM architecture guidelines we are using a "Pusher" that is responsible for sending messages to the Google servers once we received a new message. The issue is that testing process has reported about serious problems with push notification delivery to devices.
So the question: is there an approaches for monitoring average statistics about push notification delivery percentage, time etc? Or maybe somebody have experience in how to set up test environment for efficient monitoring of how much notifications are getting lost during the application work?
All the "tips&tricks" related to the improving Android GCM experience are welcome.
Google claims that the processing at their GCM server takes less than a millisecond. Link below for a great video on GCM from Google's developer. And it's believable coz I could get push notifications almost instantaneously using my company's server to my device now.
http://www.youtube.com/watch?v=YoaP6hcDctM
They don't guarantee delivery, but they try for a max of 4 weeks to deliver the message depending on the duration you set in the message you send to Google's GCM servers and if you wish to let Google keep the data for eventual delivery of message to the device in case the device was offline when the message was to be delivered.
However, there are certain conditions under which the GCM messages are not delivered.
Background data is unchecked under Account and Sync settings.
Prior to 4.0.4.(ICS), a Google account on the device is a pre-requisite for GCM. Maybe, Users are not logged into their Google account.
The only way to do so is to report back to your server with the timestamp of the received push.
You can either
Report back to the server once you receive the notification in your GCM service. To implement, you will have to add a push id for your push notifications and send the id along with the push data. The client will have to get the timestamp once it receive the message and send it back along with the notification id. A simple php script can be done (when you send a push notification, you set the time of the send-notification and once it receives the device's timestamp it sets the receive-notification. This boils down to two fields in your database (marked in bold). In this approach you will probably not so much care about errors since it is very probable that the device will have a connection when it receives the notification and as such its request to your server will go through.
Keep a list of notifications received in your app and their timestamps. And when the sync is done, send the this data in your sync operation. This is ultimately the same approach but your server's data won't be as realtime as the first approach. However, the extra request is not required from the client's side but saving the received notifications and their timestamps is.
All in all, you will have to keep track of the notifications sent using a notification-id and their sending time (send-notification) and their receive time (receive-notification). A simple query will help you analyze this data.
Google has added support so that you can receive delivery receipts from Cloud Connection Server (CCS):
You can use upstream messaging to get delivery receipts (sent from CCS to your 3rd party app server) when a device confirms that it received a message sent by CCS.
To enable this feature, the message your 3rd-party app server sends to CCS must include a field called "delivery_receipt_requested". When this field is set to true, CCS sends a delivery receipt when a device confirms that it received a particular message.
https://developer.android.com/google/gcm/ccs.html#receipts
Google does not make these statistics available to you. There are some statistics available on the android developer console. This only shows the number of messages and registrations.
You would have to implement your own data collection, which could be done fairly easily. You could record the time & id of each message sent and have your android client report back to your server with the time of message receipt. You could then store the data on your server and query as needed.
Since that time Google has provided developers with advanced monitoring tool.
The Gcm Diagnostic Tool is available in Google Play developer console. Additional information is here https://support.google.com/googleplay/android-developer/answer/2663268
So you can easily track the particular message status via registration token.

Categories

Resources