以下是代码片段。下面。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