【问题标题】:React Native navigator.geolocation.getCurrentPosition how to customize the Alert Text MessageReact Native navigator.geolocation.getCurrentPosition 如何自定义 Alert Text Message
【发布时间】:2018-07-23 07:52:20
【问题描述】:

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

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

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

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

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

【问题讨论】:

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


    【解决方案1】:
    1. 使用Xcode 打开你的 react native ios 项目
    2. 选择info标签
    3. 查找Privacy - Location When In Use Usage Description 密钥(示例隐私 - 相机使用说明)
    4. 编辑值以描述您请求访问此内容的原因
    5. 当应用程序显示弹出请求将显示您填写的描述

    更多信息请查看answer

    【讨论】:

    • 标记为正确答案。非常感谢伙计。你保存了我的应用程序。 :-)
    猜你喜欢
    • 2022-12-12
    • 2016-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多