检测新的Apple Pencil 2是否已连接到iPad Pro第三代

时间:2018-10-31 15:52:38

标签: xcode ipad stylus ios12 peripherals

第三代iPad Pro和Apple Pencil2即将面世,我将为绘图应用程序准备更新。但是我不打算购买新设备,问题是,如何修改新设备的Apple Pencil检测代码?

当前代码如下,

if ([central state] == CBManagerStatePoweredOn)
{
    // Device information UUID
    NSArray* myArray = [NSArray arrayWithObject:[CBUUID UUIDWithString:@"180A"]];

    NSArray* peripherals = [m_centralManager retrieveConnectedPeripheralsWithServices:myArray];

    for (CBPeripheral* peripheral in peripherals)
    {
        if ([[peripheral name] containSubstring:@"Apple Pencil"])
        {
            // The Apple pencil is connected
            self.stylusType = Stylus_ApplePencil;
            [self.delegate didConnectStylus:Stylus_ApplePencil];
        }
    }
}

第一代Apple Pencil的uuid是“ 180A”,那么新的uuid和外设名称是什么?

0 个答案:

没有答案