0

I am trying to build a simple chat messaging app with Android.

I have an Android Studio project with a Cloud Endpoints module. I use this Cloud Endpoints API which is published on my Google App Engine project to communicate with my Cloud SQL database. I can do things like insert rows or delete them. The Cloud SQL database has a table in it called "message" and it is very simple with

message
-------
id
sender
receiver
datetime

Now I want to integrate push notifications using Google Cloud Messaging.

I saw some tutorials such as this one and it explained sort of how it works.

What I do not get is how I can I should set things up with my Cloud Endpoints and my Cloud SQL database so that whenever I write a new row to "message", a push notification is now sent to whatever user it is being sent to.

I know you can use Parse.com for this but how would I do it/set it up using Android Studio + Cloud Endpoints + Google Cloud Messaging, all of which are published on Google App Engine. i.e. how does Snapchat do it (who use Google App Engine)?

1

there are a several ways you could implement this, of the top of my head:

  1. you can include a call after you insert messages on your DB to dispatch a message via GCM
  2. You can add a "dispatched" field to messages on your DB and have a GAE cron task to pick up un dispatched tasks and send them on a regular basis, marking them as dispatched when the push message goes out.

It really depends on your app context and requirements.

  • Thanks for the reply. I think option (1) is the way I want to go. Just wondering if this is the correct way to do it. I really don't want to set up cron tasks, I would like this system to work with the API, but just unsure how people usually do this. – Micro Jul 15 '15 at 14:25
  • 1
    Both implementations are completely valid, if you are looking for real time notices you should use option 1. – jirungaray Jul 15 '15 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.