3

I saw that programmatically turning bluetooth on and off was a "private api" thing in previos versions of iOS that would get an app rejected from the apple itunes store.

But in iOS 5, I am aware of previously private things that are no longer private, such as programmatically changing screen brightness. Doing this will no longer get your app rejected in itunes with iOS 5, so I am wondering if this other things were available publicly, like the bluetooth adapter.

CQM
  • 42,592
  • 75
  • 224
  • 366

5 Answers5

5

CoreBluetooth is publicly available in iOS 5. Unfortunately it only works for new Bluetooth LE (Low Energy) devices.

See CoreBluetooth Documentation

Ky -
  • 30,724
  • 51
  • 192
  • 308
EricS
  • 9,650
  • 2
  • 38
  • 34
  • 1
    It didn't used to be. . Try https://developer.apple.com/library/ios/#documentation/CoreBluetooth/Reference/CoreBluetooth_Framework/_index.html – EricS Jul 03 '12 at 15:59
2

I needed to enable bluetooth programmatically. What I did was use the GKPeerPickerController, this asks you to enable bluetooth if it's not already on. Then on a call for the GKPeerPickerControllerDelegate I dismiss the picker.

Not perfect, you will see the "Searching for devices" for a short time, but It works in lack of another way of doing this (as far as I know).

GKPeerPickerController * peerpicker = [[GKPeerPickerController alloc]init];
peerpicker.delegate = self;
peerpicker.connectionTypesMask = GKPeerPickerConnectionTypeNearby;
[peerpicker show];

When the peerpicker is ready to search there's a delegate method to return a GKSession for the picker to use. This is where you dismiss it.

-(GKSession*)peerPickerController:(GKPeerPickerController *)picker sessionForConnectionType:(GKPeerPickerConnectionType)type
{
    [picker dismiss];
    [picker autorelease];
    return nil;
}

And your app won't get rejected.

Jonathan
  • 2,968
  • 3
  • 24
  • 36
2

This is not public. You will get rejected.

Lily Ballard
  • 182,031
  • 33
  • 381
  • 347
  • 1
    "Public" and "Rejected" are two different things. If there is an API for this then it is public. Apple may reject your app based on how you are using it. – whatchamacallit Jul 03 '12 at 15:18
  • 1
    @whatchamacallit: Except there is no API for the System Preferences setting that controls whether Bluetooth is enabled or disabled. EricS's PDF is about how to use Bluetooth LE in iOS 5, not how to turn Bluetooth on/off. – Lily Ballard Jul 03 '12 at 19:17
2

According to the iOS 5.0 Release Notes there is no mention of any Bluetooth functionality being publicly available.

ariopolis
  • 183
  • 5
1

No, bluetooth is still not available :(

thisisablock
  • 549
  • 3
  • 6