Detect Siri Remote from iPhone via Bluetooth

1k Views Asked by At

Is it possible to detect the Apple TV 4 Siri Remote from an iOS application using CoreBluetooth? I'm able to detect the Apple TV, but I'm not having any luck detecting the Siri Remote. The Siri Remote uses Bluetooth 4.0 so I'm assuming it is detectable. Ideally, I'd like to detect the Siri Remote even if it's already paired with the Apple TV.

Simply being able to detect any signal from the Siri Remote/know it's in the vicinity of the users iPhone is what I'm after.

#import "ViewController.h"
@import CoreBluetooth;

@interface ViewController () <CBPeripheralDelegate, CBCentralManagerDelegate>

@end

@implementation ViewController {
    CBCentralManager *btManager;
}

-(void)viewDidLoad {
    [super viewDidLoad];
    btManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
}

#pragma mark - CBCentralManagerDelegate Methods

-(void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary<NSString *, id> *)advertisementData RSSI:(NSNumber *)RSSI {
    NSLog(@"peripheral name: %@", peripheral.name);
    NSLog(@"peripheral services: %@", peripheral.services);
    NSLog(@"peripheral identifier: %@", peripheral.identifier);
    NSLog(@"peripheral state: %ld", (long)peripheral.state);
    NSLog(@"RSSI: %@ \n\n", RSSI);
}

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

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

            NSDictionary *scanningOptions = @{CBCentralManagerScanOptionAllowDuplicatesKey: @YES};
            [btManager scanForPeripheralsWithServices:nil options:scanningOptions];
            break;
        }
    }
    NSLog(@"%@", nsLogMessage);
}
0

There are 0 best solutions below