Reputation: 885
Question about iOS6 peripheral bluetooth connection.
in info.plist if I add UIBackgroundModes bluetooth-peripheral, at app launch it asks permission for first time.
"appname" would like to make data available to nearby bluetooth devices even when you're not using the app
if I deny (don't allow) the request, setting - privacy - Bluetooth Sharing - "Appname" turned to "OFF";
I set to listen CBPeripheralManagerDelegate to see if I can, but it always return "ON" even I deny the request. (that's also make sense because it is "on" before it goes to background)
- (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral{
NSLog(@"%s",__func__);
NSLog(@"%@",[peripheral description]);
NSString *state = nil;
switch (peripheral.state) {
case CBPeripheralManagerStateResetting:
state = @"resetting"; break;
case CBPeripheralManagerStateUnsupported:
state = @"unsupported"; break;
case CBPeripheralManagerStateUnauthorized:
state = @"unauthorized"; break;
case CBPeripheralManagerStatePoweredOff:
state = @"off"; break;
case CBPeripheralManagerStatePoweredOn:
state = @"on"; break;
default:
state = @"unknown"; break;
}
NSLog(@"peripheralManagerDidUpdateState:%@ to %@ (%d)", peripheral, state, peripheral.state);
}
I see the CBPeripheralManagerStateUnauthorized looks like it shows denied status but I can't get this status even I denied request.
Question is: "Is there any way I can find out user denied background access request?"
Upvotes: 1
Views: 1212
Reputation: 6375
CBPeripheralManager
has an authorizationStatus
property which reports this information back. (Apple documentation link).
+ (CBPeripheralAuthorizationStatus)authorizationStatus
"Returns the app’s authorization status for sharing data while in the background state. A value indicating whether the app is authorized to share data using Bluetooth services while in the background. For a list of the possible values, see “Peripheral Manager Authorization Status.”"
Upvotes: 2