0

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.

Community
  • 1
  • 1
RJ168
  • 1,006
  • 2
  • 12
  • 22
  • Hi, I put all header files in the project and then import and add header file like "BluetoothManager.h" so that error is removed but now one warning is there : Implicitly declaring C library function 'objc_getClass' with type 'id(const char*)'. App is running now but it never makes bluetooth turn on. If you know anything the please tell me. Thank you. – RJ168 May 25 '12 at 07:08

2 Answers2

1

with finding trying various things, I found the simple way to trun on bluetooth with "GameKit" framework.

Steps to implement :

  1. Add the GameKit framework to your project.

  2. Import class to your project -- #import GameKit/GameKit.h>

  3. create object of GKPeerPickerController GKPeerPickerController *connectionPicker;

  4. 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. :)

RJ168
  • 1,006
  • 2
  • 12
  • 22
0

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.

Community
  • 1
  • 1
Amy Worrall
  • 16,250
  • 3
  • 42
  • 65
  • Hello thank you for your valuable response I modify my file like this only then its never give error but as I mention my 1st comment that warning is still there. So app is running but it never turn on the bluetooth. Any more suggestion's. Thank you. – RJ168 May 25 '12 at 09:49