英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论