2

I want to get all the notifications of the BluetoothManager private framework. I've been searching but i only have found two (BluetoothAvailabilityChangedNotification and BluetoothDeviceDiscoveredNotification). I'm interesting in a notification that reports if iphone connected/disconnected to a device. If anyone could get me a list of all notifications i will be appreciated.

  • 3
    Do you have a bluetooth device at hand that would result into such events being signaled? if so, why not checking it out yourself -> http://stackoverflow.com/questions/3725234/nsnotificationcenter-trapping-and-tracing-all-nsnotifications (note that last UPDATE of the answer). – Till May 20 '12 at 15:25
  • a very good resource, thank you. – radhoo Jul 16 '12 at 11:47

2 Answers2

2

I don't have a full list, but these are the ones you were interested in:

BluetoothDeviceConnectFailedNotification
BluetoothDeviceConnectSuccessNotification
BluetoothDeviceDisconnectFailedNotification // haven't confirmed this one
BluetoothDeviceDisconnectSuccessNotification

Here are some others:

BluetoothConnectabilityChangedNotification // fires when bluetooth is turned on/off
BluetoothAvailabilityChangedNotification // seems to fire once at app start)
BluetoothPowerChangedNotification
BluetoothDeviceDiscoveredNotification
BluetoothDeviceRemovedNotification
BluetoothPairingUserNumericComparisionNotification
BluetoothPairingPINResultSuccessNotification
Michael Dorner
  • 17,587
  • 13
  • 87
  • 117
Bushrod
  • 417
  • 3
  • 7
1

Add before you call [BluetoothManager sharedInstance]:

CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(),
                                    NULL,
                                    bluetoothCallback,
                                    NULL,
                                    NULL,
                                    CFNotificationSuspensionBehaviorDeliverImmediately);

and somewhere in this implementation the method void bluetoothCallback:

void bluetoothCallback (CFNotificationCenterRef center,
                 void *observer,
                 CFStringRef name,
                 const void *object,
                 CFDictionaryRef userInfo)
{
    if (CFStringGetCharacterAtIndex(name, 0) == 'B') { // stupid way to filter for only 'B'luetooth notifications
        NSLog(@"%@", name);
    }
}

Your console log shows you all bluetooth notifications now.

Michael Dorner
  • 17,587
  • 13
  • 87
  • 117