push service change to client - java

I have a requirement:
I have to customize a push notification to the subscribers when a service changed.
I googled and found only IOS, android have the function with their platform,but that's not what I need. I'm using the play2.
how to do that?

With play2, the way to go is to push data to the client browser using either Server Sent Event or Websockets. Play supports both technologies.
WebSocket will allow you to have a two-way communication whereas SSE only have one way. For more information, I invite you to follow the documentation here for Scala or for Java

Related

Is there any way I can implement a chat on an android app that already uses a JAVA webservice with REST API?

I'm developing an Android app that consumes a java webservice with REST API and make the DB(MySQL) persistence with Hibernate. Now, I want to add a chat on the application, but I don't really know how to start, if I use GCM or other options, so far it's working with threads that check for new messages every second. However, this seems very wrong as it consumes too much of the server. Is there a better solution, maybe a tutorial or just some tips on how to proceed?
From what I understand, this will be a two-way communication because it will be a chat app (server -> client, client -> server). In the case of using GCM, you will need to communicate via an XMPP library.
On the server side, an XMPP library should be able to register a packet listener that listens for incoming messages. Look at this implementation.
On the client side, you need to register a listener as well. The sample code should suffice to explain this.

iOS - JAVA Best approach to Achieve Real-Time Data sync

We are developing an app that will have Web service in JAVA and Application in iOS.
Web-service will compute the list on a Particular Algorithm and that list has to be Shown realtime on the Device.
We were thinking of making a Routine Post Calls on every minute and get result from server but I think this would be very Costly and inappropriate way for syncing data with the Web-service's Result.
Can anyone provide Best alternative and Ideal Way for such type of requirement. Which approach should we choose to Provide such Real-time Sync for application.
You can use a WebSocket connection for this. WebSocket establish a full duplex connection between iOS and your server. This allows the server to trigger the client if new data is available.
As you mention it doing a routine post call every minute could work, but it will cost a lot of resources. It's not a good solution.
One solution could be to use websocket. So the server will send notification when data have changed. See here what is websocket http://fr.wikipedia.org/wiki/WebSocket
Use netty-socketio java realtime framework, it supports long-polling and websocket transports. javascript, ios, android client libs also available.
After googling and research, I found Socket.io better option for Our case
Socket.IO is a WebSocket API created by Guillermo Rauch, CTO of LearnBoost and lead scientist of LearnBoost Labs.
Socket.IO will use feature detection to decide if the connection will be established with WebSocket, AJAX long polling, Flash, etc., making creating realtime apps that work everywhere a snap. Socket.IO also provides an API for Node.js which looks very much like the client side API.

How can I send a notification?

I am developing an Android App that communicates with a server.
How can I send a notification from my server to my Android App without the use of C2DM?
Are Sockets a good solution? What are other alternatives?
I'd suggest you to develop a webservice preferably with JSON which is easy to handle. This server client architecture will hellp you to send and receive any kind of data (ranges from raw text to images or even video)
Check out C# webservices. That are very easy to start than the PHP services IMHO.
Depends on what you want to do.
have you thought on how does the server identifies the client to send the message ? In this case the android phone ?
With http you would need the client to "request" this notification.
The closest thing to an actual notification would be to have a socket connection, which the client would connect to the server. But then would require an existent connection between the two. If this is ok for what you are doing, then go ahead if you really want to avoid C2DM.
But, using C2DM allows your server to send notification to devices without a need for a request or direct connection from the client. The only thing you need to do is pass the identification of the device to your third-party server given when you authenticate with google's C2DM. After that, you just push notification data to C2DM and google delivers the notification for you.
I've used MQTT for providing push notifications on Android and it's proved to be a good, reliable, low power solution.
Some links to support my case / get you started:
http://mqtt.org/
Power Profiling: MQTT on Android
Basic Steps for Using MQTT in android

How to send messages from web-service to Android clients?

I have a PHP web-service, and Android client. I need to make ability to send messages from service for my Android client. How can I make this mechanism?
Unless you have implemented a push mechanism, or using an external one, such as Google C2DM, which is available for Android (I have not tested it myself, last time I checked it, it was in a beta state), the only way left is use a polling mechanism (ask every so often the web service).

How to implement XMPP to send push notifications

I would like to use XMPP so that my application will send out updates to an android phone (1.5 and higher). I pretty much want to use XMPP to send push notifications to the phone.
How would i go about achieving this. At the moment my web application is running on apache tomact with a number of servlets so the android phone can access information, but I'm finding it difficult understanding how I could implement XMPP so that I can push information from the server to the client (android phone).
I have tested the below tutorial
Example of XMPP with Google ID login
It uses Google ID logins. But i need to use my webapplication to do what google implements.
Any ideas?
That would depend on the nature of your push (is it a point to point or pub sub). In either case, you will need an XMPP server that your clients and application are connected to. This will be the means for your application to send notifications to the clients.
Not sure what you mean by "I need to use my webapplication to what google implements". Your webapplication would be a client to the xmpp server, just like your phones. You cannot use xmpp to simply talk to your webapplication, unless it happens to be a bosh enabled xmpp server itself, which I would guess is not likely.
You can use Smack for your client communications, and any one of the many available servers.
If the communication is directed at specific clients, then creating a chat between the application and client is probably the simplest means. If it is more of a broadcast, then you could use either MUC (multi user chat) or pubsub.
Generally, you would implement this as a pub-sub feature. Pub-sub is basically the publish/ subscribe paradigm: you publish something and they receive it.
Assuming you have an XMPP server setup that supports the pub-sub protocol extension (like eJabber), in your app, you would login to that server and subscribe to a node (where your update notifications would be sent), and with your subscription you would have to add a handler to handle any notification on that node.
On the server side, when you have something that all of your clients need to know about, you would publish the update to the same node that the clients subscribe to.
For more info, see http://xmpp.org/extensions/xep-0060.html

Categories