在一个 React Native iOS 应用中,你可以请求位置授权超过一次吗?

huangapple go评论60阅读模式
英文:

In a react-native iOS app, can you request location authorization more than once?

问题

React Native应用(iOS版本)需要位置授权以实现其核心功能。如果我调用"Geolocation.requestAuthorization"并且用户拒绝授权,我可以告诉他们这是必需的并再次请求吗?如果可以,如何操作?我尝试过这样做,但iOS位置权限弹窗没有出现。

英文:

The react-native app (iOS version) that I am building requires location authorization for its central functionality. If I call "Geolocation.requestAuthorization" and the user denies authorization, can I tell them that it is required and ask again? If so, how? I have tried to do this and the iOS location permission popup does not appear.

答案1

得分: 1

在一个React Native iOS应用中,您只有一次机会来请求位置授权。仅此一次。如果用户决定不同意,他们需要在设备的设置中手动启用您的应用的位置服务。苹果的iOS允许您只向用户请求特定权限一次。如果用户拒绝了,您的应用以后再尝试请求同样的权限都将立即失败。然后,您的应用权限回调将获取用户当前的授权状态。

鉴于这些规则,通常在提问之前告知用户为什么需要他们的位置是一个明智的做法。如果他们之前拒绝了但您需要再次请求其他功能的权限,您可以解释为什么这是必要的,并向他们展示如何在设备设置中启用位置服务。

英文:

In a React Native iOS app, you get one shot to ask for location authorization. Just one. If your user decides to pass on that, they'll need to manually turn on location services for your app in the settings of their device. Apple's IOS lets you ask the user for a particular permission just once. If the user says no, any future attempts by your app to request that same permission will be shot down instantly. Your app's permission callback will then get the lowdown on the user's current authorization status.

Given these rules, it's usually a good move to let users know why you need their location before popping the question. If they said no before but you need to ask again for another feature, you can explain why it's necessary and show them how to turn on location services in their device settings.

huangapple
  • 本文由 发表于 2023年6月9日 00:14:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76433856.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定