适用于iOS 7的核心蓝牙弃用

Jeg*_*gus 3 core-bluetooth ios7

在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)

Tom*_*voy 9

你怎么直接使用通用访问服务UUID?

if ( [aService.UUID isEqual:[CBUUID UUIDWithString:@"1800"]] )//0x1800 is the Generic Access Service Identifier
{
    [aPeripheral discoverCharacteristics:nil forService:aService];
}
Run Code Online (Sandbox Code Playgroud)

有关通用访问服务的详细信息,请单击此处.

  • 另外,CBUUIDDeviceNameString可以在这里找到:https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicsHome.aspx,它是0x2A00 (3认同)