GameKit keeping connection going while device screen off or in background

萝らか妹 提交于 2019-12-18 07:22:38

问题


I am working on an appliction that requires bluetooth connectivity, which i use GameKit for data transfer, however im seeing that when i go in background mode, or I just turn off the screen in app, the bluetooth connection is dropped... Ive seen other apps that keep the connection alive in such situations, anyone have any idea if I am missing something that wont cause the connection to drop on such cases? Have been looking around but havent found anything useful...

Thanks

Daniel


回答1:


This is not intentionally supported by Apple.

If you are writing this for an application that doesn't have to be distributed through the App Store, you can set the application up to play a silent audio file in the background. This will allow GameKit to continue to work even when your application has been put into the background or if the screen has locked.

If this application has to be distributed through the App Store, Apple require the audio to be a real feature, with audible music playing.




回答2:


If you have two devices connected using GKSession and then one of them is interrupted by call or goes into background, when it wakes up connection should be still alive (you should be able to send/receive packets between devices).

You may try setting

UIRequiresPersistentWiFi

in your plist.



来源:https://stackoverflow.com/questions/8003951/gamekit-keeping-connection-going-while-device-screen-off-or-in-background

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!