socket connection killed after iOS app goes to background

前端 未结 2 585
眼角桃花
眼角桃花 2020-12-18 04:31

Iam using an iPhone app chat uses socket connection to communicate with the server. When the app is moved to background i can see that the server is able to communicate with

2条回答
  •  旧时难觅i
    2020-12-18 04:46

    From Apple's IOS Programming Guide

    Most applications that enter the background state are moved to the suspended state shortly thereafter. While in this state, the application does not execute any code and may be removed from memory at any time. Applications that provide specific services to the user can request background execution time in order to provide those services.

    That at least explains, why the app stops executing. Why your server is still able to communicate with your app for 5 minutes may be, because you set an extra long time out and are not closing the socket connection explicitly on your app entering the background.

提交回复
热议问题