2

When i tried to implement app stays unto 3 mins after socket is not running.

My requirement to develop one socket server app that should be always in background.Needs to communicate with other client apps or safari web browser client .

I need to communicate between server app and other clients apps or other browser. So, initially user opens the server app and click start server button.Then he can go to other clients apps and get communicate and share valuable information.

In this process server app needs to stay in background continuously for a long time.Untill the user terminates the app.

I saw that app need to use some UIBackgroundModes to communicates like

•   Apps that play audible content to the user while in the background, such as a music player app
•   Apps that record audio content while in the background
•   Apps that keep users informed of their location at all times, such as a navigation app
•   Apps that support Voice over Internet Protocol (VoIP)
•   Apps that need to download and process new content regularly
•   Apps that receive regular updates from external accessories

But i am using only external accessories in my app.That i am attaching some reader to iPhone/ipad device.

• Apps that receive regular updates from external accessories

I saw many links in Stackoverflow, but i dnt get proper answer.

Some links:

socket connection killed after iOS app goes to background

iOS application executing tasks in background

https://blog.newrelic.com/2016/01/13/ios9-background-execution/

Can you guys can suggest me how to keep the app in background??

Thanks in advance

Community
  • 1
  • 1
naresh d
  • 183
  • 1
  • 3
  • 8
  • You should not keep a websocket connection open, it will drain the battery. Beter is to use the same server to which you connect with websocket to send your app a push notification, this will allow the user to start your app up again. Or you use silent notification. – rckoenes Dec 16 '16 at 11:04
  • Thanks for reply....push notification is nice to use, but user gets every time an Notification in toolbar when the server app is closes.means for every 3 mins user gets an notification.This makes more irritated to user.And you said silent notification.How its work??Same as push notification?? – naresh d Dec 16 '16 at 11:52
  • As I understand your question, you want to run the websocket server *on the iOS device*, in the background; you can't do this. As you have found, apps can run in the background for up to 3 minutes and then they will be terminated. iOS is not suited to running server processes. – Paulw11 Dec 16 '16 at 12:00
  • 2
    Not true my app runs a websocket server in the background at least until it looses connection which sometimes is hours. Re-establishing the connection from the background is something I'm looking into now. – bhartsb Aug 20 '17 at 03:23
  • @bharts I'm also using a web socket connection and I'm using background modes keep my app alive, my connection last for few hours but not connection life span is random. Did you found a solution for this? – Visuddha Karunaratne Oct 17 '19 at 18:36

0 Answers0