notification , Server to Client - android

I was developing an android app and a server that serve this apps. The server was coded in cakePHP. I want the app to have a notification from the server when there is an update on whatever things. Is this notification function a Server to client connection ? For example the facebook , whatapps and other social app in smart phone that could receive notification when someone send you a message, tagged you etc.
What is the proper way of doing this? I just need an idea to start. I see someone suggesting to open a long establish connection from client to check whether there is an update, but this would drain the phone battery.
If it's a Server to client connection, how would the server know where to find the client?

Google cloud messaging would seem to be the best option here; https://developer.android.com/google/gcm/index.html
As it says on the tin; "Google Cloud Messaging for Android (GCM) is a service that allows you to send data from your server to your users' Android-powered device, and also to receive messages from devices on the same connection"
xtify seems to also support what you are asking but I've no experience with it.
Although depending on your particular requirements there are other options available.
If the client only needs to get notifications when active you could have it check the server every X number of seconds for updates when it is not asleep or even when the user does a particular action. Of course this all depends on what you want to happen.
edit: Heres a good article/tutorial with code samples https://blog.serverdensity.com/android-push-notifications-tutorial/

Related

what technology used in mobile chat apps to receive messages?

I'm some kind of backend developer and don't know how mobile applications work. But I need to provide architecture for mobile chat application server.
I know that android apps using google services to receive push notifications from firebase, so we don't need run own application in endless loop and poll for new data at server.
That is prefect for push notifications, but firebase notification body limited by 4KB and don't fit for big messages.
So I can see only one realization:
Google services polling for FCM (ex-GCM) notifications
Receive some signal-like notification
According this notification my app go to server and download new message
Update local chat data
Show generated locally notification for new message
This way is looking pretty complicated, so I don't believe that this is only possible (and correct) way.
Another way is to keep websocket session opened every time or poll server manually. But these two operations should drain battery to much.
So how modern chat apps stay in sync even if they closed and device screen off?
if you really want to make modern chat app then do some research on XMPP
These can be some best practices you can follow
setup XMPP server on backend with offline storage support
use client XMPP SDKS for apps to connect XMPP server.
use push notification in case of server connection lost to wake app
and reconnect to XMPP
try to save large files on different server and send only url with
body if you want to keep your files urls private then use any
client SDK that support implementation of uploading and downloading
private file like AWSS3

How Firebase Push Notification is send to device

I am trying to figure out how Firebase connect to specific devices and send message to it. I now how to use Firebase and send notification to registed devices from my backend server but i don't know how is it working internally. Is firebase severs using persisted connection between device and server? What kind of tehnology is it using?
For now i am mostly interested in Android devices and how firebase wake up device even with background tasks restrictions.
FCM is able to wake a device because the message is actually received by software components that come with Play services, which operates with elevated privileges. Play services can choose to wake the device and deliver the message to the target app.
The FCM software in Play services keeps a persistent socket connection open to its backend under normal circumstances. If it gets connection is dropped, it has logic to reestablish the connection without taxing the battery too much.
I tried to explain how GCM works in my answer here. The internal working principle of Firebase is similar in my opinion.
When you are installing an application which has the Firebase SDK set up in it, it gets a push registration ID from Google server. Usually, you save the push registration ID in your server as well. Hence, when there is a situation for sending a push notification, your server uses this push registration ID to generate a request to the Firebase server for sending a push notification to your device.
Now let us think of the receiver part as well (i.e. your device). In my opinion, in newer versions of Android allows a JobScheduler to check repeatedly for push messages from the Firebase server and if there is one, the device notifies the corresponding application and the application then generates the push notification.
Hope that helps!

Android - Push Notifications

I am currently building a messaging application that allows users to send and receive messages on their Android mobile phones over an internet connection to each other. I have decided that I do not want to use polling because it means that a user may not receive another user's messages as instant as possible. I have my own server available for use.
I am currently tied between using Google's Cloud Messaging for Android platform in order to send the notifications from the server to the Android device. The other option is to keep a live TCP connection between my server and the Android device via a service, and send 'keep alive' messages every 5 minutes for example.
From your best opinion, what is the best way to do this - or is there a better way? I don't want to use third parties apart from Google to do this. There are similar answers available, but they don't address this specifically.
Alex
using Google's Cloud Messaging for Android platform in order to send the notifications from the server to the Android device.
This is not a realtime notification either; the notifications may be delayed longer than you experienced with polling. Also GCM is meant for broadcasting messages to a number of users, not for targeting a message to one specific user.
The other option is to keep a live TCP connection between my server and the Android device via a service
I don't know how many users you are expecting, but this may not scale. You are limited in the number of TCP connections to one server.
No need to re-invent the wheel here, use an existing implementation such as XMPP.
Take a look at this:
https://pusher.com/docs/client_libraries
https://github.com/pusher/pusher-test-android
It may be what you're looking for

Custom push notification to mobile devices

I am searching for information about custom push notification.
I want to implement a tunnel between server and devices (Android and iOS). When it comes a time server should send information to device (App).
Also as i know push works just in one way and server don't know if it's message has reached device. Maybe i am wrong at this statement, so please correct me.
I my case i want that server could know this information. So my question would be how to create this behavior between server and device (Android, iOS). Maybe there are some libraries or even protocol name where i should look.
At this moment i am reading about push notification named MQTT
I would appreciate for any information.
Thank you.
What you're looking for is Google Cloud Messaging for Android, and Apple Push Notification Service on the iOS side. (There's also Azure in Windows Mobile, but nobody really seems to care due to the cost.
And yes, you're correct in your assertion that push notifications are one-way. However, it is relatively simple to provide an acknowledgement path back to the server, if the device is in connectivity. In response to the notification, you can simply have the device post a token to the server, confirming the receipt of the push notification.

Best way to send notifications to an Android application

I have a mobile application installed, say mail
I have a web service/web application being hosted for intimating the mobile app whenever he gets a mail.
Assume internet connection is ON in mobile.
I just want to know if the mobile app would be monitoring the server web service frequently for the mail or the server web service would take care and send/trigger the pop up to mobile once gets the mail (without the need for mobile to monitor).
Please assist and guide me to resolve this. Thanks in advance.
I would look into Android Cloud to Device Messaging.
Your application will receive an intent when a message arrives.
Link: http://code.google.com/android/c2dm/
In the specific case of mail, nearly every mail client is designed to poll (monitor) the remote server for mail.
In a more general sense, it depends what the app does. If there is an established protocol, it will dictate the mechanism for communication. If there is no guiding protocol, you need to disclose more about the situation for us to give advice on.
According to this
http://code.google.com/android/c2dm/
Android cloud to device is official deprecated , Try Google cloud Messegin (GCM)
http://developer.android.com/google/gcm/gs.html

Categories

Resources