Google Places API + ReactNative [英] Google Places API + ReactNative

查看:94
本文介绍了Google Places API + ReactNative的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Android应用中使用Google Places API. 我正在使用React Native和以下软件包: https://github.com/FaridSafi/react-native-google-places-自动完成

I'm trying to utilize Google Places API in Android app. I'm using React Native and the following package: https://github.com/FaridSafi/react-native-google-places-autocomplete

  1. 在Google控制台中创建了API密钥
  2. 设置为Android应用的限制(SHA1指纹+软件包名称)
  3. SHA1指纹和软件包名称值使用以下方法检查:
    • aapt转储标记app-release.apk
    • 解压缩-p app-release.apk META-INF/CERT.RSA | keytool -printcert
  1. API key in Google console created
  2. Restriction set to Android app (SHA1 fingerprint + package name)
  3. SHA1 fingerprint and package name values checked with:
    • aapt dump badging app-release.apk
    • unzip -p app-release.apk META-INF/CERT.RSA | keytool -printcert

A)设置了Android应用限制(第2点).我遇到错误:

A) When Android app restriction is set (point 2). I'm getting error:

"Google放置自动完成:未授权此IP,站点或移动应用程序使用此API密钥.收到来自IP地址xxx.xxx.xxx.xxx的请求,引用者为:undefined"

"google places autocomplete: This IP, site or mobile application is not authorized to use this API key. Request received from IP address xxx.xxx.xxx.xxx, with referrer: undefined"

B)取消Android应用限制(限制设置为无")后,一切正常.

B) When Android app restriction removed (restriction set to None) everything works fine.

有什么想法吗?

推荐答案

要使用此React本机项目,您的Google Place API应该不受限制.由于这既不是Android SDK,也不是带有Javascript的网站,因此剩下的唯一选择就是取消其版权.

To use this React native project, your Google Place API should be unrestricted. As this is not a Android SDK as well Website with Javascript, so only option left is to unrestirct it.

更好的方法是限制Places API的API使用率,以避免滥用.

Better way would be to restrict the API Usage for Places API to avoid misuse.

请参见下面的屏幕截图以检查How to restrict Google Places API for React Native Autocomplete?

Please see below screenshot to check How to restrict Google Places API for React Native Autocomplete?

这篇关于Google Places API + ReactNative的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆