以下是代碼片段。下面。iOS 8:區域監控,如何使其工作
// Initialize the region with the Estimote iBeacon manually generated UUID of 16 bytes size.
NSUUID *estimoteUUID = [[NSUUID alloc] initWithUUIDString:[Repository getiBeaconRegionUUID]];
_beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:estimoteUUID
identifier:@"A"];
// Launch app when display is turned on and inside region.
_beaconRegion.notifyEntryStateOnDisplay = YES;
// Create a location manager
_locationManager = [[CLLocationManager alloc] init];
// Set delegate
_locationManager.delegate = self;
if ([CLLocationManager isMonitoringAvailableForClass:[CLBeaconRegion class]])
{
[_locationManager requestAlwaysAuthorization];
[_locationManager startMonitoringForRegion:_beaconRegion];
// Get status update right away for UI
[_locationManager requestStateForRegion:_beaconRegion];
}
else
NSLog(@"This device does not support monitoring beacon regions");
有NSLocationAlwaysUsageDescription
添加到應用程序。 plist中。
從來沒有從上面的密鑰文本的對話框。
在設置=>隱私=>應用程序的位置服務。在第一個應用後關閉。跑。
委託方法
- (void)locationManager:(CLLocationManager *)manager
didDetermineState:(CLRegionState)state
forRegion:(CLRegion *)region
永遠不會被調用。
在iOS 7中是同一個應用程序。沒有授權請求工作。
分享您的經驗。
requestAlwaysAuthorization的對話框不出現。在位置服務應用程序的設置。出現2個變體:從不,總是,但總是沒有下面的描述。我期望有NSLocationAlwaysUsageDescription值。 – programmist 2014-09-30 07:54:16