Standalone push notification server implementation - android

I want to implement my own push notification server, more than a need for the product I want to know How it can be implemented.
I read documents for XMPP servers like tigase, ejabberd and openfire. I know that XMPP servers can handle online messages really straight forward, just like sending notifications as chat messages. Here is what I think is true:
Hypothesis: Having an OTT (i.e. Telegram), you can send notifications or chat messages by the XMPP client (the mobile app) and an XMPP server (i.e. ejabberd), or think of a pub/sub app that gets server status changes on a mobile device is using ejabberd as XMPP server and another XMPP client as an app on mobile.
My question is, if the hypothesis that I mentioned above is right, a push notification server would be a message queuing server to queue Pub/Sub messages for offline users and an XMPP server to send notifications/messages to online users.
Is it right? I can have my own GCM-like server by having a message broker to handle the queues and an XMPP server to handle message sending?

You can definitely use an XMPP server like ejabberd to implement your own push notification service on Android. You need to have an application that stays constantly connected and will use the local Android API to display notification on the mobile when receiving a message.
On Android, receiving a notification is clearly separated from displaying it. It means you can receive it by any mean you like, but still display it as a standard notifications, even if it did not come to your device through GCM

Related

Can I Customize Openfire to use as MBaaS for mobile push notification? How?

I decide to build an infrastructure to send push notification using XMPP Protocol.
I don't want to use 3rd party services like GCM or FCM [because Google restricts FCM service based on IP Address, Is there any other free Android push notification provider? ]. i don't want to use Ejabberd either because it has some cost. i have a plan to configure Openfire on my server with SQL Server so that when a message body with particular recipient(s), added to database somehow, Openfire sends those to proper client(s) [push notification to android devices].
I am developing an XMPP client on Android to connect with this server. i think it doesn't matter what platform i'm working on, anyway it's Android.
can i send message (push notification) from server to client(s) with Openfire? How?
If not, how about Prosody or other XMPP servers?
I appriciate any help

Do XMPP Servers (Openfire) require implementations?

Do XMPP Servers such as Openfire require implementation of their own in order to handle messages. Do I need a web language such as PHP in order to handle messages with Openfire?
Because according to posts such as this How to make Chat Application in Android Using XMPP and GCM, I do not need to write PHP scripts in order to handle messages, Openfire (it being a XMPP server) will do all the heavy lifting. So when creating a messaging program is the only thing I need to worry about the client side code?
I've also run into contradictory information that I hope someone can clarify on. It was to my knowledge that one needed to use a XMPP server along side GCM; as GCM is not reliable in delivering messages by itself and requires an XMPP server to fully be reliable. Is this true, the above link suggests that it isn't, but according to this it is https://www.youtube.com/watch?v=5wXGcu9H91s
Some clarification would be great, thanks.
GCM allows you to use both HTTP and XMPP to send messages down from your application server through GCM to your devices.
Only with XMPP though can you send messages from your device through GCM to your server. This allows your device to send acknowledgment messages back up to your server. This does not necessarily make GCM more reliable but it does allow you to have a better audit of what messages were actually received by devices.
Openfire is a server that supports XMPP so you will still have to implement the protocol maybe using Smack.
Note that you could skip GCM and have a connection directly between your app and your XMPP server, however this is not recommended since your app would have to be constantly connected to your server which would be very hard on the battery of the device. This is where GCM comes in, allowing your app to receive messages even when it is in the background but still being kind to the battery of the device.

Android: Developing a Chat app

I am developing an one-to-one chat app. The problem is how should I keep all clients and server in sync? There can be multiple cases when the message fails to send from the client, or it is not received by the client.
Right now, I am using a pub sub service and GCM. Whenever user is using the app, I subscribe to a unique channel to receive messages and use api to send message. Also, through pubsub I am maintaining user online status.
Whenever app goes into background, pubsub disconnects and user goes offline. In this case GCM is used to deliver messages to the client.
This systems is working fine. But rarely there are messages that are not delivered to the client.
Can this be improved to assure message delivery ?
Here is a good tutorial.
with client side and server side codes...

Flowchart of messages in GCM using the upstream messaging

I am trying to understand the concept of gcm upstream messaging.
Well what I came to know till now after browsing for hours is this :
1)My client app sends upstream message to gcm server.2)GCM server then sends it to my 3rd party app server.3rd party app server responds to it my sending ACK to GCM server.3)Then GCM server echoes the message to the recipient device(recipient Id is included in the upstream message sent from the app).
I don't if its what actually happens.
Now that I am sure that in some step GCM server sends mesaage to my server, how actually GCM server
sends message to my app server. How does it come to know about my app server as there is nowhere where we put my server's address
I have searched the whole Internet but couldn't find anything about this.I have gone through several SO questions but I couldnot find my answer.
I want to know the entire series of steps what happens during this entire process. I am very confused.I want to know the entire concept and what's going on behind all this.
Any detailed explanation with all steps will be appreciated.
To inform I have read the Google docs.
You have much of the flow correct but I think another read of the Docs will clear things up.
Your application server must act as an XMPP client, and connect to CCS (GCM's XMPP server). Your server connecting to CCS is how GCM knows the "address" of your server.
Cleaning up the flow you suggested:
Your app server connects to GCM's CCS.
Your client app (android app) gets a registration token.
Your client app (android app) sends that token to your app server.
Your client app send upstream message to GCM.
GCM fwds that message to your application server.
Your application server send Ack to CCS.
Your application server handles the received message.
Note the above flow is a possible one, there are many others, also downstream messages are not part of the flow. Again refer to the docs for more details.

push notification to get device location

Hi i want to use push notification on android device and get device location for more information
I want to write application for android that when server want to get android device location push a notification timely to the device and the application on the device send device location to server timely.
I can't use Cloud to device messaging service because this service need that user first online and after user is online send server notification with C2DM service!.But i want to send notification to device and get device location any time server wants.
For any sort of push notification to be made possible, your client will need to be online. An offline client cant accept push notifications until it is online.
A C2DM push can be initiated by the server. No need for client to start it. The server just needs to send a message to the C2DM server and notification will be sent.
What you basically need to do is, on receiving the notification from C2DM server, make your C2DM base receiver call a function, which retrieves the clients location data using LocationManager and send it to the server.
EDIT for MQTT:
i havent done this much myself but it can be used for push service
You need:
an MQTT broker which runs on the server side, like the mosquitto broker which is Open Source.
an MQTT client library which you include in your Android app, enabling your app to connect, subscribe, and publish messages. refer this http://mqtt.org/software
to come up with a way of uniquely identifying users or devices, and then use that as a topic so that you can individually publish a message to one device.

Categories

Resources