Question

I'm trying to use BluetoothManager in an app on iOS 7 but it doesn't seem to be working.

Calling setEnabled: and setPowered: on BluetoothManager doesn't have any effect, and I'm registering for notifications (BluetoothAvailabilityChangedNotification) but these are never sent.

I've imported the framework and I'm using example code as given by these questions, but these are all pre-iOS 7, which may be the problem;

iOS BluetoothManager Framwork
iOS: Can't get BluetoothManager to work
Programmatically turn on bluetooth in the iphone sdk?

Était-ce utile?

La solution

Turns out that this framework hasn't been protected in iOS 7 and is still available for use.

I believe the problem was with the location of the BluetoothManager.h and BluetoothDevice.h header files. They need to be located in the following directory: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/PrivateFrameworks/BluetoothManager.framework/Headers

And the "Framework Search Paths" build setting of your project needs to include $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks for it to use these files.

I'm not sure why this worked - having the header files in the Xcode project still returned a valid(?) object for [BluetoothManager sharedInstance] but simply didn't give any other functionality. At least now it works, yay!

Oh and I should mention how I discovered this! michaeldorner's "BeeTee" github project is pretty much a basic BluetoothManager sample project designed for iOS 7. The readme file describes the header file placement, other than that it was just the build setting in his project to enable these headers to be used.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top