【发布时间】:2017-07-12 04:20:48
【问题描述】:
在我们的应用中,我们要求在一个用于显示地图的视图上获得位置许可 (WhenInUse)。
如果用户选择禁用设备定位服务(即在设备设置中全局禁用)然后在应用中打开我们的视图,将显示定位权限弹出窗口。重复冲洗几次(重新打开服务、继续应用、离开应用、关闭服务等),几次后位置权限警报将停止显示。
有人知道这是否是 iOS 中的错误(发生在 iOS 10 上)?
我们可以使用自己的警报来显示何时
CLLocationManager locationServicesEnabled = NO
但由于我们无法控制是否/何时弹出 iOS 位置警报,因此有时它们会同时显示,这是不好的用户体验。
该问题的任何已知解决方案?如果这是 iOS 中的错误,我必须向我们的 QA 和经理解释。
编辑:
- (BOOL)negotiateLocationServicePermission:(UIViewController *)context
{
/* Device location service is enabled. */
if ([CLLocationManager locationServicesEnabled])
{
/* App location service is already authorized. */
if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedWhenInUse
|| [CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedAlways)
{
/* App location service is authorized. Start location updates ... */
[self startUpdatingLocation];
return YES;
}
else
{
/* App location service not yet authorized and status is not determined (aka: first time asking for permission). */
if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined)
{
/* Request the location permission from the user. */
if ([self respondsToSelector:@selector(requestWhenInUseAuthorization)])
[self requestWhenInUseAuthorization]; /* iOS 8+ */
else
[self startUpdatingLocation]; /* iOS 7 */
return YES;
}
/* App location service not authorized and previously denied. */
else
{
/* App location service permission was denied before. */
// Show custom alert!
return NO;
}
}
}
/* Device location service is disabled. */
else
{
// Show custom alert!
return NO;
}
}
【问题讨论】:
标签: ios cocoa-touch permissions geolocation alert