Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
Avatar
Stei #1
Member since Oct 2016 · 31 posts
Group memberships: Members
Show profile · Link to this post
Subject: iOS - Keeping XMPP connection alive in background
After the user presses the home button, is there any way to keep the app's XMPP connection alive? If not, what is a good solution for this issue, to allow the user to continue to be notified they have received a message? I know that you can do this by stating the app uses VOIP or location services, but our app doesn't at this time, so it would be rejected by the app store if we tried to submit it.

The only thing I can think of is to disconnect the XMPP session when the user presses the home button, and then reconnect when the app is resumed. Our server already sends push notifications to users whose presence is set to offline, so this can work. But I just feel that disconnecting/reconnecting to the XMPP server each time the app is opened/closed is a bad idea. Thanks
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by Stei:
The only thing I can think of is to disconnect the XMPP session when the user presses the home button, and then reconnect when the app is resumed. Our server already sends push notifications to users whose presence is set to offline, so this can work. But I just feel that disconnecting/reconnecting to the XMPP server each time the app is opened/closed is a bad idea. Thanks
This is what the iOS and Windows Phone forces you to do. The main reason is battery life. Connection in the background on mobile networks can drain the battery like hell when several apps are doing this and run in the background.
This is why they introduced the push notifications which are optimized for battery consumption. So what you are doing right now is the correct solution.
On reconnect you don't need to request the roster, you can use roster versioning. or you can use stream management for faster reconnects.

Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters: