Using Smack API for Instant Messaging in Android - java

I want to make an instant messaging app for android. I have the option of using GCM, but I do not want to use it since there may be other platforms that may communicating (web, other mobile platforms etc) with the app.
So, instead of using GCM , I want to use the Smack API (an xmpp library written in java), which uses sockets.
Now, I have a few doubts about it:
How smack handles connection drops/reconnects etc. Is it as 'simple' as GCM? in case of an internet loss, will it automatically reconnect when its available
Is it battery efficient ? Since its listening from its own socket, I would like to know if there will be a massive battery drain or not (it should be listening for messages 24/7 from a background service, and not only while the user is in the app)
Aside of these concerns, I would like to know if there are other (better) ways to have instant messaging. I cannot do sockets from scratch, and would like multiple platforms (thats my I am not a fan of GCM)

Related

Push Notifications in iOS 7> on a private server

I would like to implement a server-side push notification service for iOS.
When the application goes to the Background I need to send notifications to the client for different events and if it's necessary to wake app the application.
Currently in my system I have Apache tomcat Server and what I'm interested in to have a kind of tutorial of how that could be implemented. Is it possible to use for instance web-sockets, or what kind of alternatives such as TCP sockets from JAVA?
I have found some stand alone services such as AirNotifier, and EasyAPNs but I would prefer not make complex my configuration by including more programming languages.
Thanks

How to make Push notification server for my android application?

How i can make my own push notification server for my android & ios application?
m not wanna to use GCM.
GCM and APN are the client side part of the infrastructure. You should still set up your own messaging server. That event-based server will then push messages to the clients via the proprietary infrastructure. I think applications should be respectful of their enironment, and using the push facilities of the platform is indeed a good thing for your users. Also, it should be even easier for you to implement, thanks to the standard setup and the working documentation.
Otherwise, just pick your favourite message queue middleware (Active, Zero, you name it) and integrate it directly with the native client for the supported platforms, without using GCM (or Apple push). But be warned that this will make your application less efficient, and you may face higher development costs to set up the background notification service.
Node.JS provide a module called SOCKET.IO. I use this in my android apps for live messaging. You can configure it on AWS, Digitalocean Or you can use Heroku.
Here is the good example of Socket.io with android http://nkzawa.tumblr.com/post/46850605422/connecting-to-a-socketio-server-from-android
Android chat app wit socketio
https://github.com/nkzawa/socket.io-android-chat

Targeting Push Notifications

I have an idea for an application and am trying to first get hold of a plan to implement it. I am planning to implement a java service on Google App Engine and this would be pushing messages to subscribers, i have a concept of channels, exactly the same thing Parse has. Unfortunately Parse is not supported on GAE and it only has an Android client.
Does GCM have channel based push notifications? Like one device can be subscribed to multiple channels and I can push messages through a channel and all subscribers of that channel alone get notifications?
Or do I have another option?
GCM does not support channel based notifications.
If you use GCM directly, you'll have to implement this functionality yourself: your server will have to manage the mapping between channels and devices (Registration IDs), and push to all the devices subscribed to a channel when you wish to push to that channel.
Note 1: this is already done, APNS and GCM. Do you have any other features in mind that this two systems do not yet provide?
GAE does not support listening sockets, which prevents building any server-to-device persistent connection push system.
Note 2: there is Channels API, but it's web only as it's wrapped in an opaque javascript wrapper and it's protocol is obscured on purpose.
Alternative 1: use an existing external service like PubNub, Pusher, Amazon SNS, etc..
Alternative 2: instead of GAE use Compute Engine, which has no such limitations. However it does not (yet) have any most of the GAE goodies: it's service APIs (datastore, queues, etc..).
Note 3: your idea of persistent connections would only work while application on device is "alive", e.g. in the foreground (at least on iOS, on Android it's possible but would severely impact battery). For universal push-to-device you would need to combine your system with platform-provided async push system (e.g. APNS and GCM).

A connection between 2 applications

I would like to manage a connection between 2 applications, they will run on diffrent phones.
The purpose doesn't really matters let's say that it would be some kind of a chat.
How can I create this connection between the applications? I know how to do it on pc java programs using the socket and the serverSocket classes but I guess it's diffrent in here since the phone might change his ip when he moves between networks.
So how would you do that? how would you create a connection between 2 applications/phones
Given the scenario you described in your comment, using Push Notification i.e Google Cloud Messaging (GCM) might be sufficient.
So, when program B wants update from program A, it will ask the server to push a notification (via GCM) to program A. Note that program A will not connect to the server every x time to check for updates.
Another out-of-the-box solution is to use SMS if the communication is not so frequent and messages are short. Here I mean SMS that will be processed directly by your app (given it has certain attention word) and will not go to the inbox i.e. no SMS notification on the phone
Since the two phones will, as you note, have changing IP addresses, you'll probably need to use an intermediary.
The general design pattern here would be to have a server with a fixed IP or DNS address that relays messages between your two mobile devices. The simplest implementation would be a webserver, to which each phone would connect via HTTP(S) to transmit data or poll for updates.
There are a number of backend-as-a-service platforms that provide this type of functionality pre-built, and would likely suffice for something like a chat system. Check out Cloudmine and Parse.
If you need a low-latency or near-realtime connection, you could also consider implementing your own server that uses the Android C2DM (Cloud to Device Messaging) service.
See Android's Sample Bluetooth Chat App, It will give you an idea for how it can be achieved.

Comet library for android

Task: Send messages from server to the android client with response-time minimization.
I've been told that COMET is a good way to perform it. I found this link, but as a client side code only javascript is shown. So, it is neccesary to implement it in java, but I wonder is there any ready comet library for android of for pure java?
Or are there some other good ways to perform messaging?
I want to highlight that server-polling is not acceptable, as it requires much traffic and is very slow.
How about using cloud to device messaging (C2DM) services to get push notifications when new data is available at the server? Does this yield enough "response time minimization"?

Categories

Resources