iphone - How can an iOS app keep a TCP connection alive indefinitely while in the background? -
an iphone app, connecting remote server via tcp. use scenarios are:
- app (user) sends data server , server responds data back.
- server might send data app while nothing.
assume if app not send data server 30 minutes, server close connection. want keep connection alive 120 minutes if user nothing.
case 1: if app in foreground, can use timer send do-nothing data server. no problem.
case 2: if user pressed home , app went background, do? don't wan show alert or interrupt user(he away or playing games). wanna keep connection alive longer period , when user comes app, found out connection still alive , happy that.
i have read documentations background execution, multitasking, , local notifications of iphone apis. i'm not sure whether if can achieve case 2.
only use legal apis, no jailbreaking.
tapbots solved problem pastebot prompting user run silent background audio track @ times.
note apple frowns on using hacks employing background audio or voip apis keep non audio or voip apps running (as evidenced 'workaround' described in article above) dabbling these techniques risks rejection @ point of submission.
unfortunately, though, there no legal api keep connection alive in background. perhaps they'll introduce 1 in future update ios, might consider submitting feature request voice support it.
Comments
Post a Comment