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

React Native navigator.geolocation.getCurrentPosition how to customize the Alert Text Message

在 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 函数,还有一个对象作为第三个参数,您可以在其中自定义 enableHighAccuracytimeout maximumAge.

然后当你调用它时,它第一次显示一个模式,请求用户允许访问他的位置。 所以我的问题是:

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

现在 Apple 引入了一些指导,要求说明请求的权限是什么,但我看不到以编程方式自定义文本消息的方法。

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

  1. Xcode
  2. 打开你的 React Native ios 项目
  3. Select info 选项卡
  4. 找到 Privacy - Location When In Use Usage Description 密钥(示例隐私 - 相机使用说明)
  5. 编辑值以描述您请求访问此内容的原因
  6. 当应用显示弹出请求时,将显示您填写的描述

查看更多信息