ios - React Native navigator.geolocation.getCurrentPosition 如何自定义 Alert Text Message

标签 ios react-native location app-store user-permissions

在 React Native 中,我们有这个函数来访问设备的位置:

navigator.geolocation.getCurrentPosition(
      (position) => {
        this.setState({
          latitude: position.coords.latitude,
          longitude: position.coords.longitude,
          error: null,
        });
      },
      (error) => this.setState({ error: error.message }),
      { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 },
    );

正如我们在此示例代码中看到的,它接收 onSuccess 和 onFail 函数,以及作为第三个参数的对象,您可以在其中自定义 enableHighAccuracy、timeout 和 maximumAge。

然后当你调用这个时,它第一次显示一个Modal,请求用户访问他的位置的权限。
所以我的问题是:

如何自定义该模态警报中显示的文本?

enter image description here

现在,Apple 引入了一些指导,要求提及所请求的权限,但我没有看到以编程方式自定义文本消息的方法。

我被卡住了,因此我的应用程序被多次拒绝。请指教。

最佳答案

  • 使用 Xcode 打开你的 react native ios 项目
  • 选择 info标签
  • 查找 Privacy - Location When In Use Usage Description key (示例隐私 - 相机使用说明)
  • 编辑值以描述您请求访问此内容的原因
    enter image description here
  • 当应用程序显示弹出请求将显示您填写的描述
    enter image description here

  • 更多信息请查看 answer

    关于ios - React Native navigator.geolocation.getCurrentPosition 如何自定义 Alert Text Message,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48758418/

    相关文章:

    react-native - 在 react-native webview 中为触摸事件创建一个洞

    ios - 为 testflight、应用程序图标存档 react native iOS 项目时出错

    java - 获取Android中的最后位置

    javascript - 未经许可的地理定位

    java - ImageView 位置错误

    ios - XCode 7 如何固定到 super View 而不是播放指南

    ios - 如何在iOS设备上的Chrome移动版上进行远程调试

    reactjs - 使用 Jest/Enzyme 的 FlatList 测试

    iphone - iOS类方法的使用

    ios - 日期更改时在 UICollectionViewController 中创建日期戳单元格