首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iOS 8:区域监控,如何使其工作

iOS 8:区域监控,如何使其工作
EN

Stack Overflow用户
提问于 2014-09-29 09:34:18
回答 2查看 717关注 0票数 0

这是代码片段。如下所示。

代码语言:javascript
复制
// 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。夹板。

从上面的键中从没有文本的对话框。

在设置=>隐私=>定位服务的应用程序。在第一个应用程序之后就被关闭了。跑。

委托方法

代码语言:javascript
复制
- (void)locationManager:(CLLocationManager *)manager
      didDetermineState:(CLRegionState)state
              forRegion:(CLRegion *)region 

从来没有被召唤过。

在iOS 7中,同一个应用程序。在没有授权请求的情况下工作。

分享你的经验。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-09-30 15:41:30

在我将NSLocationAlwaysUsageDescription键值对添加到InfoPlist.strings之后,它显示了对话框并开始工作。

票数 0
EN

Stack Overflow用户

发布于 2014-09-29 09:54:47

当我从ios7迁移到ios8时,我也面临着同样的问题,我已经完成了对苹果文档的解释。

看看苹果在这里说了些什么:

苹果DOC

在iOS 8中,NSLocationWhenInUseUsageDescriptionInfo.plist文件中的NSLocationAlwaysUsageDescription键值是required.but,您还需要在注册位置更新之前请求用户的权限,方法是根据需要调用[_locationManager requestWhenInUseAuthorization][_locationManager requestAlwaysAuthorization]

请注意这一信息,它将有助于通过ios 8。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26096742

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档