4

I have create basic chat app with XMPP Server in swift 2 (from this tutorial: http://shubhank101.github.io/iOSAndroidChaosOverFlow/2016/08/Chat-Application-Using-XMPP-Swift-Tutorial). My app is working good. but when my app went into background then my app unable to receive any message from XMPP server. i think this is because of XMPP connection break while entering the app in background.

i have tried to found the help on google for the same but nothing found related to Swift 2

Please help me. if some one put some sample code that would very helpfull for me because i m new to IOS development.

Rajinder
  • 1,131
  • 1
  • 14
  • 29

2 Answers2

0

You need to create a background thread to maintain XMPP connection. You can follow this tutorial to see how background thread works. https://thatthinginswift.com/background-threads/

0

Third-party apps on the iOS are not allowed to keep network connection in background. See Apple guidelines how to avoid background networking.

vitalyster
  • 4,980
  • 3
  • 19
  • 27
  • thanks for your comment. but we can perform some background process in ios and i m looking for that like: https://www.raywenderlich.com/143128/background-modes-tutorial-getting-started – Rajinder Mar 16 '17 at 13:30
  • Allowed background modes are for short finite tasks, all of them are not suitable for persistent network connection. – vitalyster Mar 16 '17 at 13:56