как найти аудиоустройства Bluetooth в iOS

Хорошо, я'Я работаю над забавным проектом, у которого есть препятствие, когда мне нужно включить поддержку звука Bluetooth для моего приложения iOS.

Препятствие яЯ просто могуt даже начать получать список подключенных аудиоустройств Bluetooth. Несмотря на то, что мой iPhone 5S распознает мой наушник (примерно 3-4 годаLG HBM-230, если быть точным) и воспроизводить аудио через него для телефонных звонков,И ТО И ДРУГОЕ Внешний аксессуар и CoreBluetooth не дают мне ничего полезного, когда я запрашиваю оба.

основываю свой код на вопросах и ответы, которые я нашел для обоихCoreBluetooth а такжеВнешний аксессуар рамки.

Когда мой код просто пытается ""scanForPeripheralsWithServices:nil залюбой Bluetooth-устройства, которые Настройки->Bluetooth, скажем, виден и подключен, приведенный ниже код просто НЕ подходит ни для одного удара за ""CBCentralManagerStatePoweredOn сообщение в консоли.

И эта строка в моем коде (с действительным экземпляром EAAccessoryManager)

NSArray * connectedDevices = [self.eAAccessoryManager connectedAccessories];

также возвращается с нулевым массивом.

Что я могу делать не так?

Б.Т.В., яМы сделали этот код доступным как проект GitHub.

@implementation BluetoothManager

+ (BluetoothManager *)sharedInstance
{
    static dispatch_once_t pred = 0;
    __strong static id _bluetoothMGR = nil;

    dispatch_once(&pred, ^{
        _bluetoothMGR = [[BluetoothManager alloc] init];
    });

    return _bluetoothMGR;
}

- (id)init
{
    self = [super init];
    if(self)
    {
        dispatch_queue_t centralQueue = dispatch_queue_create("com.yo.mycentral", DISPATCH_QUEUE_SERIAL);

        // whether we try this on a queue of "nil" (the main queue) or this separate thread, still not getting results
        self.cbManager = [[CBCentralManager alloc] initWithDelegate:self queue:centralQueue options:nil];
    }
    return self;
}

// this would hit.... if I instantiated this in a storyboard of XIB file
- (void)awakeFromNib
{
    if(!self.cbManager)
        self.cbManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:nil];
}

- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {

    NSLog(@"hey I found %@",[advertisementData description]);
}

- (void)centralManager:(CBCentralManager *)central didRetrieveConnectedPeripherals:(NSArray *)peripherals
{
    NSLog( @"I retrieved CONNECTED peripherals");
}

-(void)centralManager:(CBCentralManager *)central didRetrievePeripherals:(NSArray *)peripherals{
    NSLog(@"This is it!");
}

- (void)centralManagerDidUpdateState:(CBCentralManager *)central{
    NSString *messtoshow;

    switch (central.state) {
        case CBCentralManagerStateUnknown:
        {
            messtoshow=@"State unknown, update imminent.";
            break;
        }
        case CBCentralManagerStateResetting:
        {
            messtoshow=@"The connection with the system service was momentarily lost, update imminent.";
            break;
        }
        case CBCentralManagerStateUnsupported:
        {
            messtoshow=@"The platform doesn't support Bluetooth Low Energy";
            break;
        }
        case CBCentralManagerStateUnauthorized:
        {
            messtoshow=@"The app is not authorized to use Bluetooth Low Energy";
            break;
        }
        case CBCentralManagerStatePoweredOff:
        {
            messtoshow=@"Bluetooth is currently powered off.";
            break;
        }
        case CBCentralManagerStatePoweredOn:
        {
            messtoshow=@"Bluetooth is currently powered on and available to use.";
            NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], CBCentralManagerScanOptionAllowDuplicatesKey, nil];

            [_cbManager scanForPeripheralsWithServices:nil options:options];

            break;
        }   

    }
    NSLog(@"%@", messtoshow);
}

@end

Ответы на вопрос(1)

Ваш ответ на вопрос