1

I just want to know whether is it possible to switch on bluetooth programmatically on iPhone?

Cœur
  • 37,241
  • 25
  • 195
  • 267
RAMAN RANA
  • 1,785
  • 4
  • 21
  • 40
  • That's a very general question - at this point in time, you can use Bluetooth for GameKit (multiplayer games) and wireless headsets. iPhone -> non-iPhone sending of data is not supported. You can however use GameKit to send data to other iOS devices. – Pripyat Mar 14 '11 at 13:11
  • since you've changed your question: GameKit will enable Bluetooth once the dialog for connection pops up and Bluetooth is selected. – Pripyat Mar 14 '11 at 13:12

2 Answers2

3

it is possible to switch on/off the Bluetooth by using the below lines of code , but since it access private frameworks of Apple, your App may reject in App store push

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.

#if TARGET_IPHONE_SIMULATOR
    exit( EXIT_SUCCESS ) ;
#else
    /* this works in iOS 4.2.3 */
    Class BluetoothManager = objc_getClass( "BluetoothManager" ) ;
    id btCont = [BluetoothManager sharedInstance] ;
    [self performSelector:@selector(toggle:) withObject:btCont afterDelay:1.0f] ;
#endif
    return YES ;
}

#if TARGET_IPHONE_SIMULATOR
#else
- (void)toggle:(id)btCont
{
    BOOL currentState = [btCont enabled] ;
    [btCont setEnabled:!currentState] ;
    [btCont setPowered:!currentState] ;

}
#endif
Raj
  • 5,895
  • 4
  • 27
  • 48
0

For some reason David Schiefer answered your question as two comments, so I'm just gonna repeat what he said:

That's a very general question - at this point in time, you can use Bluetooth for GameKit (multiplayer games) and wireless headsets. iPhone -> non-iPhone sending of data is not supported. You can however use GameKit to send data to other iOS devices.

since you've changed your question: GameKit will enable Bluetooth once the dialog for connection pops up and Bluetooth is selected.

Erik B
  • 40,889
  • 25
  • 119
  • 135