【问题标题】:iOS 8: Region Monitoring, how to make it workiOS 8:区域监控,如何使其工作
【发布时间】:2014-11-23 15:49:52
【问题描述】:

这是代码 sn-p。下面。

// 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 添加到应用程序中。列表。

上面的键中的文本从未出现过对话框。

在设置 => 隐私 => 应用程序的位置服务。在第一个应用程序后关闭。运行。

委托方法

- (void)locationManager:(CLLocationManager *)manager
      didDetermineState:(CLRegionState)state
              forRegion:(CLRegion *)region 

永远不会被调用。

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

分享你的经验。

【问题讨论】:

    标签: ios objective-c ios7 core-location


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      当我从 ios7 迁移到 ios8 时,我遇到了同样的问题。我已经按照苹果文档的方式完成了我的解释。

      检查苹果在这里说了什么:

      APPLE DOC

      从 iOS 8 开始,NSLocationWhenInUseUsageDescriptionInfo.plist 文件中的 NSLocationAlwaysUsageDescription 键值是必需的。但您还需要在注册位置更新之前请求用户的许可,方法是调用 [_locationManager requestWhenInUseAuthorization] 或 @ 987654326@根据您的要求选择以上任何一个。

      请注意此信息,它将在 ios 8 中有所帮助。

      【讨论】:

      • requestAlwaysAuthorization 对话框不出现。在应用程序的位置服务设置中。出现 2 个变体:Never 和 Always,但对于 Always,下面没有描述。我希望有 NSLocationAlwaysUsageDescription 值。
      猜你喜欢
      • 1970-01-01
      • 2015-12-09
      • 2011-07-17
      • 1970-01-01
      • 2013-11-20
      • 2018-05-21
      • 2014-05-23
      • 2017-11-29
      • 2011-09-09
      相关资源
      最近更新 更多