Mobile back end push and pub/sub (GCM or not) - java

We already have a quite complex mobile backend written in Java which is deployed and works fine, so we do not have any need to use the Google mobile backend. Now we have requirements for pushing some data from the back end to the phone. Earlier I used GCM regularly. Our first requirement is only simple messaging, but it may evolve to something like a pub sub (phones subscribing to topics).
The issue I am not understanding is should I now use GCM like before, and later develop my own pub/sub overlay, or can I use the products Google has developed for that? Is this even possible, since everything I am finding on Google pages is just related to communication between Android phones via their cloud storage, so no library for communication between a custom back end and a phone?
In short, what should I use, regular GCM or is there something Google is providing which I am not understanding?

You can use regular GCM. A custom back-end can send messages to an Android app via GCM. The library for sending messages from a 3rd party server to GCM still exists (com.google.android.gcm.server package in the Google Cloud Messaging for Android Library), but you don't have to use it - you can implement the HTTP POST requests yourself.

Related

How to send push-notifications from java-server?

I have apps on Android & iOS, & I need to send push-notifications to them from Java-server.
Please tell me, where can I find guides how to do this? I'm looking GCM & APN for Android.
https://firebase.google.com/
That is what I use for project and I am satisfied with it.
You have all needed tutorials and docs to start working with it.
Overview:
firebase provides You with Admin SDK wich helps You build Data and Notification messages and send it to firebase, firebase then sends it to either iOS or Android if You send it to specific client or to both if You send it to some created topic.
It also have easy to use Android, iOS, JavaScript libs to handle it on client-side.
ofc to get this work with Your server Client must generate notification token from provided google api and send it to Your server to store in DB.
there are some restriction though with push notifications 2kb if I remember correctly and 4kb for data messages keep it in mind when you create your communication architecture :)

Android app uninstallation event for analytics

I wonder what are the ways/patterns to detect app uninstallation for any kind of analytics on android? I know the limitations of ACTION_PACKAGE_REMOVED intent - not received by application being removed. I am using flurry at the moment and have also discovered that they do not provide any kind of support for deinstallation events. This type of event is definitely something you want in your analytics but so far have not found any clear solution. Any ideas?
Here's a possible approach. In your Android app, implement support for receiving push messages from Google Cloud Messaging (GGM). Then, implement a server that sends GCM "are you there?" messages to all users at regular intervals (e.g. daily). Google's GCM service will notify your service of all targeted recipients which no longer have your app installed. To correlate uninstall data with other metrics such as app version, user demographics, date of installation, etc, collect that data in your app and supply it to your server when registering for GCM messages. Then when you get notified of an uninstall, match it with the installation data. From there, you could report it to a service like Google Analytics for additional slicing and dicing, graphical visualization, date range comparison, etc.

What is the established way to request data from an android device

I currently have an small application that I have been using to learn java/android programming. Right now I have a setup were the app on one phone sends a request (via sms) to another phone running the same app. The remote phone receives the request and sends back some info. Next I would like to try this from the web. Is there an established "best" way to to this?
I was thinking I would have a web server send requests to the device via google cloud messaging and then have the device return the data directly to the web server. (Not that I really know how to do any of that just yet).
I see that there is a google cloud messaging return path (send messages from the device to the google cloud server, but it seems very new, do I need something like that? The main thing I want is to be able to ask the phone to do something when I want, not have it poll to see if there is a request, or just periodically update some status.
UPDATE:
Thanks to the answers below for confirming to me that I was on the right track.
I now have some basic functionality.
I started out using this gcm android demo code
https://code.google.com/p/gcm/source/browse/#git%2Fgcm-client%2Fsrc%2Fcom%2Fgoogle%2Fandroid%2Fgcm%2Fdemo%2Fapp%253Fstate%253Dclosed
and this ruby gem
https://github.com/spacialdb/gcm/blob/master/README.md
between the above two I was able to send a message to my phone pretty easily.
To get the round trip working, I setup a very simple rails app on heroku.
I included a modified version of the sample code in the gcm gem in a controller and then used
HttpPatch (needed for rails 4) to send a post/patch from my phone to my web app, the controller then echoes the message back to my phone.
I guess it would be nice to get the two way gcm stuff to work, but I am not sure there are any gems that handle that, and I am not qualified to handle a task like that :)
I would say it's the right call: Google Cloud Messaging for Android
From the site Android Developer:
This could be a lightweight message telling your app there is new data
to be fetched from the server (for instance, a movie uploaded by a
friend), or it could be a message containing up to 4kb of payload data
(so apps like instant messaging can consume the message directly).
In this case you don't want to fetch data from the server but you want to send them.
You can send them in different ways. I would suggest, since you are learning, to try a RESTful solution using one of the implementation of JAX-RS.
As a short and direct answer for beginner : GCM (Google Cloud Messaging) would solve your issue. However, if your app turned out to be something bigger, other more technical and complicated solutions are present too.
see this link.

How to implement a messaging feature in android application to other android devices and to computers

I've been working on an android application and I am trying to figure out how to implement a messaging feature for the application to send messages to other phones and to my web app. I have been doing a fair amount of research and I haven't yet found any ways of going about this, or at least not any straightforward ones. Could someone point me in the right direction with this? Is there a relatively simple way to get this functionality? I have found links that show how to use google's cloud service but I am extremely unfamiliar with this so I was wondering if there were other better/simpler implementations or instructions out there. Thanks in advance for the help.
For security and privacy reasons, your phone/tablet app cannot (should not) communicate directly with other devices (unless they're on the same WiFi or similar and explicitly bound via bluetooth .etc)
So the way to do this on Android is use Cloud to Device Messaging (C2DM).
Your app will send a web request to your server, with the message and intended recipients.
Your server will look at this, find the C2DM IDs of the recipients, and send the message to Google's C2DM service, which will then be pushed down to each device.
Your app should have a C2DM receiver to receive these messages and process them.
Check here for more information on implementing C2DM
http://code.google.com/android/c2dm/

How to send messages from web-service to Android clients?

I have a PHP web-service, and Android client. I need to make ability to send messages from service for my Android client. How can I make this mechanism?
Unless you have implemented a push mechanism, or using an external one, such as Google C2DM, which is available for Android (I have not tested it myself, last time I checked it, it was in a beta state), the only way left is use a polling mechanism (ask every so often the web service).

Categories