Currently, in order to push notifications to an android app on the android operating system, it appears the app needs to integrate Google Cloud Messaging (GCM) APIs. The App Server currently pushes data through GCM and GCM will push data to specific devices.
This is a silly question, but I was wondering if it is possible to replace GCM in this process? In other words, is it possible to have an alternative server as opposed to GCM? The motive is to hide the data from the GCM server.
Before: App Server ==> GCM ==> Android App
New: App Server ==> Custom Cloud Messaging ==> Android App
You can use app-directed sms/ port-directed sms.
Send sms from the server(SMS gateway) to a particular port on which your app will be listening.This sms will act as GCM message.
Using this approach you don't have to worry about long running service draining the battery. Also sms are almost real time and doesn't require internet connection.
However there are some phones don't support port directed sms.
For port directed sms you need to register a broadcast receiver something like below:
<receiver
android:name = ".SmsReceiver">
<intent-filter>
<action android:name="android.intent.action.DATA_SMS_RECEIVED" />
<data
android:scheme="sms"
android:host="*"
android:port="8095" />
</intent-filter>
The port directed sms does not appear in user's sms inbox if properly supported by phone.
Replacing GCM is actually not a trivial task. I would have to strongly advise against doing a long-polling mechanism as suggested earlier - the truth is that going down that path would be extremely expensive in terms of resources (battery life) and managing it would be a nightmare. There are going to be tons of error conditions that you're gonna need to address - from network drops to managing guaranteed delivery.
Full Disclosure: I work for Magnet Systems which has a product - Magnet Message - that provides these capabilities and more.
What we did was create a persistent socket to the server. (BTW, this is what GCM does as well as Apple's APNS). This socket is used to be able to "push" messages to the device. By understanding the connectivity on the socket, you'll understand the presence of devices and know if you can send messages to them.
Nevertheless, it's still a challenge to address things like pushing to an app that is offline or killed - and across platforms (probably don't want to forget the other 40% of iOS users) - so there are different challenges there. To address this, we send a "signal" via GCM to notify that there is a pending message and have a Broadcast Receiver that can go to our server and fetch the messages securely.
Since we allow you to deploy our server code in your environment, we don't have to see anything that you send. (Of course, we have a SaaS model as well).
At any rate, you can take a look at what we've done at http://developer.magnet.com. It's free to play with and we've got a bunch of open source stuff.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With