4
votes

I want to send push notification in my app (Android) using Google Cloud Messaging. I am using firebase for backend. As firebase do not support inbuilt push notification i am using Google App Engine.

I do not have any idea on Google App Engine. Right now i am using a template provided by google for sending push notification. Google Cloud Messaging Template Github

Till now i have deployed my app in Google App Engine and i am able to send push notification to all devices that are registered (From Web) An HTML page i get when i use GCM template.

What i want to do is , to Listen for Firebase data change and send push notification to user who is not online or has closed the app.

How can i run a servlet in background so that it keeps running in background and send push to user who is not online/connected.

As i have only push notification logic in Google App Engine Should i use servlet or struts.

Thanks in Advance

1
Google "firebase app engine" and the first hint points to this tutorial in cloud.google.com. It uses Firebase + App Engine to send email notifications. So swap out the email code for your GCM code and you're good to go. - Frank van Puffelen
@FrankvanPuffelen Yes i saw that, however it makes me to use cron.xml for keep listening for data changes in Firebase, i guess its not good. - Bora
That tutorial was written by an engineer who worked on both app engine and Firebase. I'd take his opinion over my own guesses any day. - Frank van Puffelen
As of today (May 19 2016) Google just rebranded GCM to Firebase Cloud Messaging and it now offers this as a cross platform service. It also offers notifications. See this response for a complete answer. - Yair Kukielka
Now you can send push notification to all or specific devices/users using your app server and firebase. for working example visit this blog post. codingaffairs.blogspot.com/2016/06/… - Developine

1 Answers

1
votes

It is my understanding that Firebase really doesn't work very well with GAE, so you might want to reconsider your choices.

Listening for data changes, as you have mentioned, requires that your app leave a background thread running. To do this on GAE you have to disable automatic scaling which is an important feature of GAE.

You could create a separate backend GAE module with manual scaling and then have it use eg. a queue to notify your main GAE module of a data change, but this seems to me to be unnecessarily complicated and inefficient.

Hopefully Firebase will improve their product so it can notify of data changes in a more efficient and flexible manner, but in the mean-time, perhaps you should use a regular compute engine instance.