I am looking to create an IM app for Android. So , instead of using their GCM , I decided to use a pure XMPP client . Smack is the best for this . I would like to know how Smack will handle connection losses /drops /reconnects in Android. If there is no internet connection,etc, does smack have built-in apis to handle that, or will I need to implement it myself ?
Also, I would like to know approximately ,how much battery life smack will use ?
1.) Regarding maintaining connectivity If you use “smack-bosh” the connectivity will be maintained until you call disconnect
2.) no internet connection will not be detected by smack, you have to write your broadcast listener and accordingly call the respective functions to re establish
3.) Smack does not have build in mechanism to detect the internet availability, it will throw socket timeout and disconnect
4.) battery life as per my testing approximately 0.1% for 30 minutes
battery life as per my testing approximately 0.1% for 30 minutes
Battery life depends heavily on your usage pattern of the XMPP connection. If you just use the connection to push a message to the device once a day, the impact on battery life will be not measurable.
Also note that using XMPP over TCP is more efficient then BOSH, but keeping a TCP connection to the server established on mobile devices is not a trivial task.
How smack-bosh helps in maintaining connection losses.
I am having the similar issue with connectivity loses
for now i am having following dependencies for android:
implementation “org.igniterealtime.smack:smack-android-extensions:4.2.2”
implementation “org.igniterealtime.smack:smack-tcp:4.2.2”
it connect, authenticate and sending, recieving message works fine.
but the problem is of connection losses. Can you pls tell me smack-bosh usage.
Smacks BOSH implementation extends the AbstractXMPPConnection class, so you can see it as an alternative to smack-tcp.
Please check XEP-0206: XMPP Over BOSH for information about how BOSH works.