位置访问 - 应用程序不要求用户访问位置的权限 - iOS 11 [英] Location access - App is not asking for user permission to access location - iOS 11

查看:224
本文介绍了位置访问 - 应用程序不要求用户访问位置的权限 - iOS 11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说明



应用不要求用户访问位置权限并获取状态notDetermined



完美地工作到iOS-10

  var locationManager:CLLocationManager! 

func getLocationDetails()
{
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestAlwaysAuthorization()
locationManager。 allowsBackgroundLocationUpdates = true
locationManager.startUpdatingLocation()

}

func locationManager(_ manager:CLLocationManager,didChangeAuthorization status:CLAuthorizationStatus)
{
如果status == CLAuthorizationStatus.authorizedAlways || status == CLAuthorizationStatus.authorizedWhenInUse
{
locationManager.startUpdatingLocation()
}
}

func locationManager(_ manager:CLLocationManager,didUpdateLocations locations:[ CLLocation])
{


}

Plist截图



背景模式



解决方案

我已经浏览了Apple文档并找到了解决方案问题。



Apple已经改变了一些指导方针来获取用户位置。



以下是视频链接:
和身份验证消息屏幕将如下所示:





位置访问的完整代码


Description

App is not asking for user permission to access location and getting state notDetermined

Working perfectly till iOS-10

var locationManager : CLLocationManager!

func getLocationDetails()
    {
        locationManager.delegate = self
        locationManager.desiredAccuracy = kCLLocationAccuracyBest
        locationManager.requestAlwaysAuthorization()
        locationManager.allowsBackgroundLocationUpdates = true
        locationManager.startUpdatingLocation()

    }

func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus)
    {
        if status == CLAuthorizationStatus.authorizedAlways || status == CLAuthorizationStatus.authorizedWhenInUse
        {
            locationManager.startUpdatingLocation()
        }
    }

    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
    {


    }

Plist screenshot

Background Modes

解决方案

I have gone through the Apple documentation and found the solution for this question.

Apple has changed few guidelines to get user location.

Here is the Video Link: Apple- What's New in Location Technologies

Full code for location access in Swift & Objective-C both

Solution:

Now we need to add three Authentication Key into Plist:

  1. NSLocationAlwaysAndWhenInUseUsageDescription
  2. NSLocationWhenInUseUsageDescription
  3. NSLocationAlwaysUsageDescription

Plist will look like : And Authentication message screen will look like:

Full code for location access

这篇关于位置访问 - 应用程序不要求用户访问位置的权限 - iOS 11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆