How can an iOS app keep a TCP connection alive indefinitely while in the background?

后端 未结 4 873
名媛妹妹
名媛妹妹 2020-12-02 09:53

An iPhone app, connecting to a remote server via TCP. The use scenarios are:

  1. app (user) sends data to server and server responds data back.
  2. server mig
4条回答
  •  一向
    一向 (楼主)
    2020-12-02 10:34

    Tapbots solved this problem with Pastebot by prompting the user to run a silent background audio track at all times.

    Note that Apple frowns on using hacks like employing the background audio or VOIP APIs to keep non audio or VOIP apps running (as evidenced by the 'workaround' described in the article above) so dabbling with these techniques risks rejection at the point of submission.

    Unfortunately, though, there is no legal API to keep a connection alive in the background. Perhaps they'll introduce one in a future update to iOS, but you might consider submitting a feature request to voice your support for it.

提交回复
热议问题