I've paired an IOBluetoothDevice
in my Mac/Cocoa app and would like to "unpair" it programmatically. That is, I would like to remove the device from the left pane of the Bluetooth section of System Preferences.
I've seen [IOBluetoothDevice removeFromFavorites]
, but that just removes the heart icon next to the "Favorite" attribute of the device -- the device is still listed in the left pane.
Is this possible through Cocoa?
In the above picture, I would like to programmatically remove "Apple Mighty Mouse" from the left pane.
Paired devices are a part of System Preferences.
You can find the file with the bluetooth preferences in
/Library/Preferences
, its name iscom.apple.Bluetooth.plist
.However, you cannot edit the file directly. You should use
SCPreferences
class fromSystem Configuration
framework.Note the API for accessing/modifying system preferences is pretty low level.
EDIT: The following code works if run in superuser mode. I am not a Mac OS developer myself but it should be possible to init it with an
AuthorizationRef
and run it with user mode (the user will confirm access to system configuration).