Reputation: 1046
I want to switch on bluetooth grammatically in iPhone. This is my code for that --
Class BluetoothManager = objc_getClass("BluetoothManager");
id btCont = [BluetoothManager sharedInstance];
[btCont setPowered:YES];
I put the .header files under Header flolder under following path :
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/System/Library/PrivateFrameworks/BluetoothManager.framework/Headers
But the problem is that its giving me an error i.e. : 'BluetoothManager/BluetoothManager.h' file not found
So please let me know if I done something wrong here.
I found this all stuff from following link :
Programmatically turn on bluetooth in the iphone sdk?
Thank you very much In advance.
Upvotes: 0
Views: 2907
Reputation: 1046
with finding trying various things, I found the simple way to trun on bluetooth with "GameKit" framework.
Steps to implement :
Add the GameKit framework to your project.
Import class to your project -- #import GameKit/GameKit.h>
create object of GKPeerPickerController GKPeerPickerController *connectionPicker;
Paste this code in viewDidLoad
connectionPicker = [[GKPeerPickerController alloc] init]; connectionPicker.delegate = self; [connectionPicker show];
It showing you the alert popup to turn on bluetooth and clicking on yes you will get the bluetooth on.
But I dont know about the customizing that popup so if anyone knows please let me know.
Thank you in advance. :)
Upvotes: 1
Reputation: 16337
Firstly, just to be sure, you know you can't use that in a shipping app, right?
Take a look at this answer, which explains how to generate the header file you need.
Upvotes: 0