iOS 11 位置权限,从一开始就有三个选项 [英] iOS 11 Location permission with three options from the beginning

查看:44
本文介绍了iOS 11 位置权限,从一开始就有三个选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 React Native 在 iOS 11 上请求位置许可.苹果在 iOS 11 中有一个变化,我们有第三个选项,仅在使用应用程序时使用位置权限.我们的应用程序是基于位置的,即使应用程序在后台也需要用户的坐标,所以我希望用户可以选择在第一次弹出窗口时单击始终".问题是唯一显示的弹出窗口没有三个选项(下面的第一张图片).iOS 11 的第二张图片显示了我试图实现的三个选项.我已将新的隐私设置添加到 Info.plist,如第三张图片所示.

I am trying to ask for location permission on iOS 11 with React Native. There is a change from Apple coming with iOS 11 where we have a third option for using the location permission only when using the app. Our app is location based and need the user's coordinates even when the app is in the background so I would like the user to have the option to click 'Always' the first time the popup shows up. The problem is that the only popup which shows up is not having the three options (the first image below). The second image for iOS 11 is showing the three options which I am trying to achieve. I have added the new Privacy settings to the Info.plist as shown in the third image.

推荐答案

在 iOS 10 中,要询问位置的始终权限,请使用密钥作为 NSLocationAlwaysUsageDescription

With iOS 10, to ask a always permission of location, use the key as NSLocationAlwaysUsageDescription

=> 您使用错误的键作为 NSLocationUsageDescription

=> You use the wrong key as NSLocationUsageDescription

在 iOS 11 中,要请求始终获得位置权限,您需要 2 个密钥作为NSLocationWhenInUseUsageDescription 和 NSLocationAlwaysAndWhenInUseUsageDescription

With iOS 11, to ask a always permission of location, you need 2 keys as NSLocationWhenInUseUsageDescription and NSLocationAlwaysAndWhenInUseUsageDescription

=> 你已经完成了这部分.

=> You have done this part.

这篇关于iOS 11 位置权限,从一开始就有三个选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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