Question

I agree that this question is duplicate. Please bear with me. I was also among you all to believe that is not possible to programatically turn on/off bluetooth.

But using GKPeerPickerController if bluetooth is not on user will be prompted to turn it on. Fair enough to turn on the bluetooth.

I was betting with my belief that we can not turn off the bluetooth programatically as there is no way. But this application does that so I didn't had choice to refuse.

I just want to confirm whether it is possible or not and if yes how to turn off the bluetooth using GKPeerPickerController or any other public api way ?

Was it helpful?

Solution

I know this isn't the answer you want, but no, you can't turn off bluetooth programmatically with Apple-approved APIs.

There have been a number of apps approved on the App Store this year that have done this.

But, they keep getting removed by Apple shortly after release, once they (Apple) realize what's going on. They're certainly using private APIs.

Either developers are foolish enough to think that they won't be noticed, or they are simply hoping to pull in a couple weeks of revenue before Apple pulls the app, which could be enough to pay back their cost, with some profit.

The issue is that there's a number of ways to check whether an app is using private APIs. If developers are using objective-C frameworks in the normal way, that's an easy check. In fact, Xcode does some of this automatically when you use it to upload app binaries to iTunes Connect. But, it's not a complete check. Once at Apple, the reviewers perform another check, which I've been able to deduce is more sophisticated than what Xcode does.

However, that check is still not perfect, and I'm of the opinion that it's not necessarily a matter of a lazy reviewer just forgetting to perform the check. Objective-C gives you some techniques for obfuscating method calls. Depending on how you use these techniques, you might get past the reviewers . In my experience, I have every reason (wink, wink) to believe that Apple is not running every app on a fully instrumented version of iOS, which could log all function calls, and defeat even the best attempt to hide private API usage via obfuscation techniques.

So, I can pretty much guarantee you that this explains the apps you've found on the App Store that turn off Bluetooth. Public GameKit APIs let you turn Bluetooth on, but not off.

Disclaimer: I've never worked for Apple, and no Apple insiders gave me information. But, I have gotten private APIs through the review process.

OTHER TIPS

Please try below code and I think it will also work for you.

Class BluetoothManagerClass = objc_getClass( "BluetoothManager" );
    BluetoothManager *btCont; = [BluetoothManagerClass sharedInstance];

 [btCont setPowered:NO];

You need to add BluetoothManager class/framework in your project.

Thanks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top