iPhone turn off bluetooth GKPeerPickerController
Asked Answered
E

2

9

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 ?

Edibles answered 19/6, 2012 at 13:40 Comment(5)
I suspect that app may get pulled soon. There was another app that did a similar thing and that only survived on the AppStore for a week or so.Filariasis
It has to do with something around it turning on bluetooth with a method that uses bluetooth and probably crashing itself with bluetooth so that ios kills it. (just a guess)Epsom
Thank you for both of your inputs. Actually from reviews we can see that application really works and helps turn on or off. With GKPeerPickerController we can ask user to turn on bluetooth but how to turn it off is mystery yet and so questions exists.Edibles
It's like in location services. The SDK can ask the user if you use a bluetooth function, but bt is disabled. There is no vice-versa method to disable bluetooth (at least no official, maybe on jailbroken ones or private API). … how about this answer? https://mcmap.net/q/622135/-is-there-a-way-to-toggle-bluetooth-and-or-wifi-on-and-off-programmatically-in-iosPolysemy
@relikd no, its not like in location services. Bluetooth is not a service, rather there are services which build on top of bluetooth. Also the software development kit won't ask the user, i guess you mean the operating system.Ky
T
2

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.

Trigraph answered 26/6, 2012 at 3:49 Comment(0)
T
-1

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

Tomasine answered 29/6, 2012 at 13:16 Comment(1)
thank you for your input. But I guess this belong to private api isn't it ? Will it go through app store ?Edibles

© 2022 - 2024 — McMap. All rights reserved.