2012-12-07 27 views
1

問題有關iOS6的外圍藍牙連接。如何獲得在iOS6的藍牙隱私設置狀態

在info.plist中如果我添加UIBackgroundModes藍牙外設,在應用程序啓動,它要求第一時間許可。

"appname" would like to make data available to nearby bluetooth devices even when you're not using the app 「APPNAME」想提供給附近的藍牙設備上的數據,即使你不使用的應用程序

如果我否認(不容許)的要求,設置 - 隱私 - 藍牙共享 - 「Appname」轉爲「OFF」;

我設置爲監聽CBPeripheralManagerDelegate,看看我是否可以,但它總是返回「ON」即使我拒絕請求。 (這也是有道理的,因爲它是「開」之前被切換到後臺)

- (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); 

} 

我看到CBPeripheralManagerStateUnauthorized看起來顯示否認的狀態,但即使我拒絕請求我不能讓這種狀況。

的問題是: 「有什麼辦法,我可以找出用戶拒絕後臺接入的要求嗎?」

回答

2

CBPeripheralManagerauthorizationStatus財產報告這些信息反饋。 (Apple documentation link)。

+ (CBPeripheralAuthorizationStatus)authorizationStatus

「返回的數據共享應用程序的授權狀態,同時在後臺狀態指示應用程序是否有權分享在後臺使用藍牙服務,而數據的值。有關可能的值的列表見「外設Manager授權狀態。」」

+0

謝謝。我一直在尋找iOS 6時代,但它終於在iOS 7上實現了。 –