Core Bluetooth deprecations for iOS 7

别来无恙 提交于 2019-12-01 07:20:57

问题


In iOS 7, some Core Bluetooth things are now deprecated like CBUUIDGenericAccessProfileString and CBUUIDDeviceNameString. The apple docs state

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

I am wondering what we are supposed to do to replace these GAP things, as the apple docs and examples are of no help. The entire internet also seems to be silent about this. My code is pretty much just like the Heart Rate Monitor example which still has the deprecated code

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

回答1:


How about you just use the Generic Access service UUID directly?

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

Check here for details on the Generic Access Service.



来源:https://stackoverflow.com/questions/19984314/core-bluetooth-deprecations-for-ios-7

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