简体   繁体   中英

How to handle a TCP connection in background?

I have an app to play bingo on Casino with a TCP Server . When Player Arrives to Casino and player press Play Game, the application will connect with the Bingo Server .

The Server sent the new ball number via TCP/IP Connection to the iOS Devices.

If the User press the home button the App goes to background and the TCP connection with the server keeps alive because I use this properties for the Streams made with:

[inputStream setProperty:NSStreamNetworkServiceTypeVoIP forKey:NSStreamNetworkServiceType] ;
[outputStream setProperty:NSStreamNetworkServiceTypeVoP forKey:NSStreamNetworkServiceType] ;

I need to update the game if the app goes to background, so I use NSStreamNetworkServiceTypeVoIP to make the updates in the App.

If a Player Wins, the app warns the user when there is a Winner with a Local Notification.

If the Application is more than 600 seconds in background, I close the TCP Connection with Bingo Server.

When Player leaves the Casino, the application close the TCP Connection and reset the Game.

I have read that Apple reject Apps if are not real VOIP apps.

Apple can not test the App because needs the Bingo Server in Mexico City

So I dont Know if my App can be publish to the App Store.

https://pbs.twimg.com/media/BUYzUHkCYAAwhyG.jpg

They would reject it solely on it not actually using VOIP as you suggested. Look into other ways of achieving what you want through other techniques such as background app refresh (iOS7).

I've also seen people play a silent audio file in the background to achieve an idle status while in sleep mode. Although it's discouraged there are plenty of people that use the technique in live apps. Apple even has silent audio files on iTunes you can grab. I think the main key is to let the user select the blank audio file rather than setting it as a default. ;-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM