释放双眼,带上耳机,听听看~!
一般在项目中添加权限只需要看这一篇文章:iOS info.plist 中的隐私权限就够了,但是位置权限说明有点麻烦,现总结如下,方便后期使用。
定位权限一般有四个:
NSLocationWhenInUseUsageDescription
NSLocationAlwaysAndWhenInUseUsageDescription
NSLocationUsageDescription
NSLocationAlwaysUsageDescription
NSLocationWhenInUseUsageDescription :用在 iOS app上,只能用于应用在前台时需要获取用户位置的权限说明
官方解释如下:
Use this key if your iOS app accesses location information only when running in the foreground
NSLocationAlwaysAndWhenInUseUsageDescription:用在 iOS app上, 用于应用在后台时需要获取用户位置的权限说明
官方解释如下:
Use this key if your iOS app accesses location information while running in the background
我一般会在info.plist 文件中同时添加 NSLocationWhenInUseUsageDescription 和 NSLocationAlwaysAndWhenInUseUsageDescription,只添加一种好像是不谈出权限弹框
位置弹框如下: