iOS 7的核心蓝牙已被弃用

3

iOS 7中,一些Core Bluetooth事物现已过时,例如CBUUIDGenericAccessProfileString和CBUUIDDeviceNameString。 苹果文档指出

"(Deprecated. There are no replacements for these constants.)"

我想知道我们应该做什么来替换这些GAP东西,因为苹果的文档和示例没有帮助。整个互联网似乎也对此保持沉默。我的代码基本上就像心率监测器示例一样,还是使用了已被弃用的代码。

/* GAP (Generic Access Profile) for Device Name */
if ( [aService.UUID isEqual:[CBUUID UUIDWithString:CBUUIDGenericAccessProfileString]] )
{
    [aPeripheral discoverCharacteristics:nil forService:aService];
}
1个回答

9
你为什么不直接使用通用访问服务UUID呢?
if ( [aService.UUID isEqual:[CBUUID UUIDWithString:@"1800"]] )//0x1800 is the Generic Access Service Identifier
{
    [aPeripheral discoverCharacteristics:nil forService:aService];
}

点击此处查看有关通用访问服务的详细信息。


1
嗯,这确实解决了弃用警告的问题...但它并没有真正解释为什么他们要弃用常量,如果我们只是手动重新制作常量!我认为苹果公司只是讨厌我们。 - Jegus
3
CBUUIDDeviceNameString可以在此处找到:https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicsHome.aspx,其值为0x2A00。 - Dan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接