GameKit 在设备屏幕关闭或在后台时保持连接
我正在开发一个需要蓝牙连接的应用程序,我使用 GameKit 进行数据传输,但是我发现当我进入后台模式,或者我只是关闭应用程序中的屏幕时,蓝牙连接就会断开...我见过在这种情况下保持连接处于活动状态的其他应用程序,任何人都知道我是否缺少一些不会导致连接在这种情况下断开的东西?一直在环顾四周,但没有发现任何有用的东西......
谢谢
丹尼尔
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Apple 并非有意支持这一点。
如果您正在为不必通过 App Store 分发的应用程序编写此内容,则可以将应用程序设置为在后台播放无声音频文件。即使您的应用程序已进入后台或屏幕已锁定,这也将允许 GameKit 继续工作。
如果这个应用程序必须通过App Store分发,Apple要求音频是一个真正的功能,可以播放可听的音乐。
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.
如果您有两个使用 GKSession 连接的设备,然后其中之一被呼叫中断或进入后台,那么当它醒来时,连接应该仍然处于活动状态(您应该能够在设备之间发送/接收数据包)。
您可以尝试设置
UIRequiresPersistentWiFi
你的清单。
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.