How to check whether your push notification/GCM message receive logic on app is working or not



In this post,I am not trying to teach the basics of GCM/push notification.You can easily get started with GCM from Android GCM. This post is for those developers who have

  • Successfully registered their device to GCM server and received GCM phone registration id
  • Implemented the logic to receive notification from their server
  • and are relying on back end developers to send test notification message


Frankly speaking I am writing this post out of frustration of dealing with back end developers who simply say that app logic is not right but back end is error proof.And they constantly force us to check our code. So,in this case if any back end developer say that their process of sending push notification to app is right and you also feel that your logic is right,then simply test your logic with HTTP post request.For this purpose I am using a Chrome app named Dev Http Client,which is BTW great great tool for any app developer doing REST API.I assume you have done the following

  1. Created a Google Project on Google API console
  2. Activated Google Cloud Messaging for Android service on that project
  3. Created an API key for that project,so that Google API can be accessed using this key
  4. And all the procedures I have described in above list


Now carefully look upon the following images

01_notification_format

01_notification_msg


So,on above image you see that you have to put

  1. Google API console API key on header
  2. Phone registration id on body part
  3. On data you have to put what kind of message you want to pass
  4. Press Send button to send the push notification


You can see the message response on second picture i.e. what have been sent by Google GCM server. So,if you receive the notification using above procedure,your app logic is right otherwise you have to make some changes. Further,to simply check whether your GCM/push notification receive logic is working or not,you don’t have to rely on back end developers,you can do on your own.

If you have any questions on this,feel free to ask me on comments.Till then Happy KitKat (as KitKat along with Nexus 5 was released yesterday) 😉