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
Related
I am building my first Android app and need to know how I could use push notification.
My project is a home alarm system and also I have built my own local web server. Now I want to push a notification from my server to my Android app when an alarm appears in my server.
Currently my garage doors use the MyQ app and when the garage door opens or closes I get a notification on my phone, I want to implement the same thing in my app.
I've been reading about the Google Firebase Cloud Messaging but it seems exceeding my need.
If you need push notification on your cell phone then you definitely need to integrate your app with Google Firebase. (or at least that's the right way of doing it).
Alternatively, there is something called as local notifications & background process in Android you could do long polling to check if the garage door is open (probably every 2 mins or something). However, I don't recommend that as it can drain your mobile battery.
Also I recommend using Flutter as oppose to using Native Android. As there are some pre-built libraries for android and Google Firebase integration.
Take a look at this Youtube video - https://www.youtube.com/watch?v=2TSm2YGBT1s
Ouh, maybe thats a little bit too much for starting with android - nevertheless I want to help you.
You need a communication protocol between your server and your phone (i.e. Firebase as you mentioned or Websockets).
If your server sends a message to you client (your phone) you have to create a notification. (Android Developer Guide). That's the theoretical part. You will also stumble across a lot of
challenges with
asynchronous programming.
Firebase might actually be the simplest option. You could build your own web socket service too, but that would probably be more than you need. See this previous question for more options: Android push notification without firebase
Android has some services that communicate with firebase to receive notifications.
You'll need to implement a service on top of your web server (using backend languages such as Python, Node.js, PHP,...) so it can send notifications when an event happened (like the door closed) witch isn't a simple way for a beginner.
then your web server sends a message to firebase and tells it to send a notification to my client.
so I highly recommend using firebase because of the simplicity of usage. otherwise, you should implement a separate service on your android phone to get the notification (if you want to run it locally) also as explained do the backend side.
I have an Android App development for story Maker.
The very first time Registered user logged in our app and create the story and download an apk .
He now uploaded the apk file in play store
The end user download the story now.
When the Registered user logged again updating his App with one more story.
This time he will not upload the app into play store Google.
I want how to update the new contents to the end user from registered user without uploading the App?
If we are going to save the content in server and serve to the end user then what is the process to do this and what are the possible way to do this ?
What you need is a combination of real time messaging, and notifications. Create a server(node or php) that maintains a state listener ,this state listener as hook to any connected device(android or ios). Whenever user performs a subscribed action such as (When the Registered user logged again updating his App) use real time communication to relay this to the server that watches your changes.(Use socket.io or lightStreamer even crossbar.io is perfect). Then intercept those changes with static notifications for every update received, Use fcm(fire-base cloud messaging) this way every data will be always be delivered and synced between clients accordingly.
This is light Streamer.
Optimized data streaming for web and mobile.
Lightstreamer enables several forms of real-time messaging. It is flexible enough to be used in any scenario, including mission critical applications.
► Real-time Data Push and WebSockets
► In-App Messaging and Push Notifications
► Pub-sub with fan-out broadcasting and one-to-one messaging
► Firewall and proxy friendly
► Adaptive bandwidth throttling
This is socket.io
Socket.IO enables real-time bidirectional event-based communication. It works on every platform, browser or device, focusing equally on reliability and speed. Socket.IO is built on top of the WebSockets API(Client side) and Node.js.
This is crossbar.io
Crossbar.io is a networking platform for distributed and microservice applications, implementing the open Web Application Messaging Protocol (WAMP). It is feature rich, scalable, robust and secure. Let Crossbar.io take care of the hard parts of messaging so you can focus on your app's features.
This is firebase cloud Messaging.
Using FCM, you can notify a client app that new email or other data is available to sync. You can send notification messages to drive user reengagement and retention. For use cases such as instant messaging.
All the aforementioned is primarily based on javascript.For php consider this library instead.
This PHP Ratchet.
Ratchet is a loosely coupled PHP library providing developers with tools to create real time, bi-directional applications between clients and servers over WebSockets.
In gerneral, WebSockets is an advanced technology that makes it possible to open an interactive communication session between client and a server. With this API, you can send messages to a server and receive event-driven responses without having to poll the server for a reply.
Happy Coding #.
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
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Group,
I am planning to implement my own Server push notification server to Android/IOS apps. So My application server (which may be implemented through NodeJs) will contact that Notification Server to push messages to devices. So i surfed through internet and found the below existing solutions.
Google cloud messaging
Apple push notification service
Firefox os push notifications
Microsoft push notification service
Q1)
On their respective sites; they were informing only about how to use their notification Server. However i need info on how they implemented their server push.
Please tell me; are they following any of this below?
Polling
Long polling
Streaming
Server Sent Events
TLS, SSL or TCP socket connections with Client
XMPP
Q2)
Below two methods are claiming that though my app is not running; they can still be able to sent notification to APP? How is that possible?
Apple push notification service
Firefox os push notifications
Q3)
In Firefox os push notifications; they have informed that they were avoiding keep-Alive to save battery life. My question is without keep-alive how to determine the connection is still alive or not ?
Q4)
Is this all these (GCM/APNS/FireFox OS) implementation is only Server side pushing, and won't accept requests from Client. Am i correct?
So still my server has to handle millions of device requests other than push messages, right?
If i use websocket between my own notification server and client devices, do i need to maintain one more websocket connection between my application server and clients to receive requests from devices ?
There are good articles available over internet, you can go through you will get answers. However I am trying to answer your question:
Answers are mostly true for android and google servers.
Ans1)
They have their listeners which has to be used by you by using their library classes in your code. You need not to bother about pushing. You have to send the message to server server will push the message to the device. They use OAuth.
Regarding Protocols, there are two methods using CCS and XMPP. CCS just uses XMPP as an authenticated transport layer, so you can use most XMPP libraries to manage the connection. To send notifications to device you can write code in android app to send as well as your server code. the message sending will be done only by your code. Rest will be taken care by Google Server in GCM case.
You can check detail at this link
http://developer.android.com/google/gcm/server.html
Also, for security issues
google cloud messaging security
https://groups.google.com/forum/#!topic/android-gcm/M-EevBitbhQ
Ans 2)
Yes in case your app is not running then also devices vcan recieve notification because you have to write code for broadcast listeners. In background it will be listening to server and whenever any message packet will be there it will recieve the message as notification. Android has service you need to not to bother about it. You have only to use those resources using the library class that makes your work easier and let them write if your app is not running then also it recieve notification. Obviously, there would be some listener whick make the app to recieve.Check "Recieve the message" section in this link
http://developer.android.com/google/gcm/client.html
Ans 3)-
Firefox OS Push Notifications are designed for one thing – waking up apps. They do not deal with data. Check this link
https://hacks.mozilla.org/2013/07/dont-miss-out-on-the-real-time-fun-use-firefox-os-push-notifications/
Ans 4)-
No it will acccept request from users also.
I am not sure for others, but for GCM it will do.
Please check "Send a message"
http://developer.android.com/google/gcm/client.html
Hope this helped you with your question.
Apple push notification is controlled by iOS not your app. Thus this is available even if the app is not running. To send a notification you open an ssl connection to the apple server and send the push notification payload. There is no polling or anything since iOS will handling everything.
If you intend to write your own server you can not user push notification and will drain the battery since you will be needing to pull message from your own server. Apple APNS is controlled by iOS, it connects to Apples server once is a while and collect all push notifications for all apps on the device.
Technical details aside, there are various third party solutions such Amazon SNS. Per million notifications should be about $0.50. Comparing this tiny cost than implementing your own servers/services (time, costs, reliability), I feel you should spend the time on other aspects of your project.
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/