Can I detect Apple TV 4 Siri Remote from an iOS app using CoreBluetooth ? I can detect Apple TV, but I was not lucky to find Siri Remote. Siri Remote uses Bluetooth 4.0, so I guess it shows up. Ideally, I would like to find Siri Remote, even if it is already connected to Apple TV.
Just the ability to detect any signal from Siri Remote / recognize it in the immediate vicinity of iPhone users is what I need.
#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); }
source share