CQM
CQM

Reputation: 44228

iOS 5: programmatically turn bluetooth on and off

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.

Upvotes: 3

Views: 11575

Answers (5)

EricS
EricS

Reputation: 9768

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

See CoreBluetooth Documentation

Upvotes: 5

Jonathan
Jonathan

Reputation: 3034

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.

Upvotes: 2

ariopolis
ariopolis

Reputation: 183

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

Upvotes: 2

Lily Ballard
Lily Ballard

Reputation: 185671

This is not public. You will get rejected.

Upvotes: 2

thisisablock
thisisablock

Reputation: 559

No, bluetooth is still not available :(

Upvotes: 1

Related Questions