push notification for my android chat application - android

iam developing a chat application and now am on it's push notification part.. And now am in a big confusion.. because in my previous application iam using Google's GCM like, whenever i get a notification from the GCM server i pull data from my server.But in this case i think it's not the right way for a chat because if i try to do like this i have to connect the socket again and user will become in online status.And also am using raw socket for my application.
is there a better way for accomplishing this?
thank you

I am using web socket for push notifications. In my android application (client side) I use Autobahn web socket client. It works fine, but if you want reliable solution then I think you can go for Azure Push Notification Service. But I think you can only send/receive few push notifications using their free service. To scale further you need to pay.
But using web socket you can send as many number of notifications as you want. Further, you can keep the connection always on, so that you don't need to reconnect the socket connection every time. But to ensure the active web socket connection you need implement PingPong. And that PingPong might use some the bandwidth.

Related

How to messengers receive notification messages from servers?

Currently I am working on an alert app, which receives push notifications from a server. Reading a lot about that topic on the internet lead me to firebase which can be used to achieve that.
Now I was wondering: Are Whatsapp, Signal and other messengers using firebase or do they have any other solution to receive messages from servers even if the app is not active opened?
They use push messaging. It might be firebase, it might be another provider. MQTT is popular. All any of those things do is open up a persistent socket connection to a server and listen for messages. The trick is that whatever process is doing that needs to be whitelisted from power management restrictions, because you don't want to delay your message notifications for 15 minutes.
Now if you're writing something that's supposed to be robust queueing on the server side and deduping on the client side would be a good idea. But the basics is open socket connection and block on it on a thread.

From server how to call an Android app without any request?

In my app I have functionality like server-side some updates is done. When every updates is happen in server-side I need send those data to app without using push notifications.
Take example of Ola Cabs. Whenever user open the app it will show all cabs information nearby user. At the same time it will send data to the cab drivers telling that a customer needs cab like that. How to implement this functionality with out push notifications?
By using this things we can do that
1) push notifications
2) explicitly calling the server from client with given time (its bad process)
Is there any solution other than these things?
How could client get response without request? Please read OSI Model and TCP/IP protocol. Because server cannot send response without request. So client have to initialize request first and wait for response from server.
If you want to do same thing without GCM then i will suggest you to use socket programming. In that you can be open client port continuously to receive messages (response) without any request initiated by client.
But again, continuously opening socket port, drains device batteries, and this is bad process. In case of GCM it only open port for while when client send request to server and close after response. So I suggest you to use GCM but still you have problem with GCM then use socket programming like chat applications (e.g WhatsApp)

Server on Android phone

I want to have an active service on my android phone.
This server will be available from clients in my local network.
Communication can be any (for example a rest api service on android)
In other words I want my service to handle external push notification but from local network not GCM.
What are know approaches to achieve this?

Web socket and push notifications android

I have a web socket that I need to receive information from in my android app. Would keeping a single web socket open at all times drain the battery on my android device? I expect that this web socket will only send notifications once every 24-hours, which is why I would like to close the connection, and somehow convert the web socket into a push notification. But, then I also need to be able to send from the android app to subscribe to the web socket and receive push notifications. How can I go about doing this?
I recommend using push notifications, which consume less battery of your phone and even more if you only send data once every 24 hours.
What technologies you plan to use?

Two way communication between android and Server

i want a two communication between server and Android. From Android want to send my current location coordinates to server after each 10 minutes. i can send message or images to server at any time. Similarly from server i want to send data to Android whenever needed.
What should be the architecture of my application.
Communication from Android to server and Server to Android is independent of each other i should not ask it as a two way communication but infact i want communication from both sides to each other any time.
Should i use a Web service of any kind or just network sockets or Something else.
You can use websockets or...
Simply send data from phone to the server using normal request. When you want send something from server to telephone you can use push notifications (C2DM) and if you receive such push message you know that server has data for you and telephone can download it using normal request;-). It depends what data you want to send. Sometimes this approach will be good, sometimes it's better to use websockets, TCP sockets or even XMPP protocol ;-)
You can Use Acknowledge for the same. You need to Implement ACK/NACK Logic in your code. When you are sending Data just wait for ACK for a particular time period. If ACK is not received the you need to send NACK for the same. Here you need to use a session-id ( a kind of id for communication at both side, which can be any random number ).
You can use this Logic at both the side.

Categories

Resources