In my application I want to switch on/off iPhone Bluetooth.i m using sdk 4.3..I got some idea regarding Bluetooth manager framework, but it\'s not working in 4.3..any ideas?
- (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
the above lines of code i got from here
Please note that you wouldn't be able to publish the app on the App Store because doing that must use private API.
If you still want to do that you should read this link: Is there a way to toggle bluetooth and/or wifi on and off programmatically in iOS?
Pay attention for adding GameKit framework for it to work and not using all the other thing written like adding .h files etc. unless gameKit doesn't sole all the problems.