【问题标题】:React Native Google Places API restriction issueReact Native Google Places API 限制问题
【发布时间】:2017-07-11 08:12:24
【问题描述】:

我在使用React Native Google Places autocomplete 时收到以下错误。

此 IP、站点或移动应用程序无权使用此 API 关键...

我正在使用Google Places API Web Service 密钥,它限制了 Android-App。 这个受限于包名com.xxx.xxx.debugcom.xxx.xxx.test。另一个 API 密钥仅限于 com.xxx.xxx。 我已经添加了正确的SHA-1 键。

任何人都知道我做错了什么或为什么它不起作用? 我检查了 Google 的文档并尝试了许多不同的方法,但我仍然无法在限制条件下使用它。

【问题讨论】:

    标签: react-native google-places-api android-restrictions


    【解决方案1】:

    将您的React-Native android 包ID 添加到您用于Google Places API 的密钥中。你可以在 Project(Root Folder) => android => app => build.gradle = > 应用程序 ID

    【讨论】:

    • 在 Google 控制台中还是在 react native 中的实际键?将 appId 添加到 key 会导致 Key not valid 错误。
    • 在您的Google Console 中,您必须添加包名称和您的SHA-1 密钥
    • 我做到了。 appId 是 com.xxx.xxx,我们使用后缀来调试和测试环境。所以增加了2个限制。 com.xxx.xxx.debug 和 com.xxx.xxx.test 使用正确的 SHA-1 密钥
    • 您可以取消对密钥的限制并尝试一次吗?并确保您已启用 google place api
    • 但是我需要设置限制,否则密钥可能会被滥用。
    猜你喜欢
    • 2019-09-18
    • 2017-09-20
    • 2012-04-12
    • 1970-01-01
    • 1970-01-01
    • 2018-06-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-29
    相关资源
    最近更新 更多