从设备获取CBUUID

时间:2017-08-02 21:24:26

标签: ios xamarin.ios

如何从我的应用当前正在运行的设备上获取CBUUID?我正在使用Xamarin但是客观c或swift的回答也会很好。

1 个答案:

答案 0 :(得分:1)

使用Plugin.BLE(https://www.nuget.org/packages/Plugin.BLE/

foreach(AdvertisementRecord record in e.Device.AdvertisementRecords)
{
   if (record.Type == AdvertisementRecordType.UuidsComplete128Bit || record.Type == AdvertisementRecordType.UuidsComplete16Bit)
   {
       b.ServiceUUID = record.Data;
       break;
   }
}

然后

foreach(Beacon beacon in beaconList)
{
    cbuuidList.Add(CBUUID.FromBytes(beacon.ServiceUUID));
}                                               

CBUUID[] uuid = cbuuidList.ToArray();
BLEManager.ScanForPeripherals(uuid);

详细信息:https://forums.xamarin.com/discussion/92838/proper-way-to-retrieve-uuid-of-device