我试图强制我的应用程序以编程方式自动进入"暂停"状态,因此我可以对Core Bluetooth恢复进行测试.我试过打电话
[[UIApplication sharedApplication] performSelector:@selector(suspend)];
Run Code Online (Sandbox Code Playgroud)
但这只是将它发送到后台.我做错了吗?有没有更好的办法?还是不可能?
我想提醒大家确切地说暂停应用程序意味着什么,因为术语总是存在混淆:
如果系统需要内存,后台的应用程序将无限期暂停,但Core Bluetooth的恢复可以暂时将应用程序发送回后台状态.
在iOS 7中,一些核心蓝牙的东西现在已被弃用,如CBUUIDGenericAccessProfileString和CBUUIDDeviceNameString.在苹果文档状态
"(Deprecated. There are no replacements for these constants.)"
Run Code Online (Sandbox Code Playgroud)
我想知道我们应该做些什么来取代这些GAP的东西,因为苹果文档和例子没有任何帮助.整个互联网似乎也对此保持沉默.我的代码就像心率监测器示例一样,它仍然有不推荐的代码
/* GAP (Generic Access Profile) for Device Name */
if ( [aService.UUID isEqual:[CBUUID UUIDWithString:CBUUIDGenericAccessProfileString]] )
{
[aPeripheral discoverCharacteristics:nil forService:aService];
}
Run Code Online (Sandbox Code Playgroud)