Google Places Api iOS每日未经身份验证的使用限制超过错误 [英] Google Places Api iOS Daily Limit for Unauthenticated Use Exceeded error

查看:33
本文介绍了Google Places Api iOS每日未经身份验证的使用限制超过错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用iOS版Google Places API.我创建了一个api密钥,然后尝试调用一些方法.我已经在应用程序中输入了api密钥,但是当我拨打电话时出现此错误

I am trying to use google places api for iOS. I created an api key and then I am trying to call a few methods. I have entered the api key in the app but when I make the call I get an this error

lookup place id query error: The operation couldn’t be completed. (com.google.places.server.ErrorDomain error -1.)
Error Domain=com.google.places.server.ErrorDomain Code=-1 "(null)" UserInfo={NSUnderlyingError=0x7f8bf861ca80 {Error

Domain = com.google.GTLJSONRPCErrorDomain代码= 403(超出未经身份验证的用途.继续使用需要注册.)"UserInfo = {错误=超出未经身份验证的使用的每日限制.继续使用需要注册.NSLocalizedFailureReason =(每日限制超过未经身份验证的使用.继续使用需要注册.),GTLStructuredError = GMSx_GTLErrorObject 0x7f8bf2be6060:{消息:每日超出了未经身份验证的使用的限制.继续使用需要注册."数据:[1]代码:403}}}}

Domain=com.google.GTLJSONRPCErrorDomain Code=403 "(Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.)" UserInfo={error=Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup., NSLocalizedFailureReason=(Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.), GTLStructuredError=GMSx_GTLErrorObject 0x7f8bf2be6060: {message:"Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup." data:[1] code:403}}}}

我使用GMSServices.provideAPIKey("MY_API_KEY")在我的appdelegate中提供api密钥,并且已授予对该应用程序的位置访问权限.我当然没有超出我的使用限制(我的配额显示1000中的0),因为我无法使用api.我已经重新生成了密钥,并且我还使用其他gmail帐户创建了其他密钥,但是没有任何作用...

I provide the api key in my appdelegate using GMSServices.provideAPIKey("MY_API_KEY") and I 've given location access to the app. I certainly haven't exceed my usage limits (my quota shows 0 out of 1000) since I haven't been able to talk with the api. I 've regenerated the key some times and I also have created other keys with other gmail accounts but nothing worked...

我的猜测是ios模拟器位置不正确(我提供了一个gpx文件来传递自定义位置),或者Google方面有问题.

My guess is either something is not right with the ios simulator location (I ve provided a gpx file to pass a custom location) or something is wrong from google's side.

我的代码中有两个示例:

The two samples that I have in my code are:

                let placeID = "ChIJV4k8_9UodTERU5KXbkYpSYs"

            placesClient.lookUpPlaceID(placeID, callback: { (place: GMSPlace?, error: NSError?) -> Void in
                if let error = error {
                    print("lookup place id query error: \(error.localizedDescription)")
                    print(error)
                    return
                }

                if let place = place {
                    print("Place name \(place.name)")
                    print("Place address \(place.formattedAddress)")
                    print("Place placeID \(place.placeID)")
                    print("Place attributions \(place.attributions)")
                } else {
                    print("No place details for \(placeID)")
                }
            })

                placesClient.currentPlaceWithCallback({ (placeLikelihoods, error) -> Void in
                guard error == nil else {
                    print("Current Place error: \(error!.localizedDescription)")
                    return
                }

                if let placeLikelihoods = placeLikelihoods {
                    for likelihood in placeLikelihoods.likelihoods {
                        let place = likelihood.place
                        print("Current Place name \(place.name) at likelihood \(likelihood.likelihood)")
                        print("Current Place address \(place.formattedAddress)")
                        print("Current Place attributions \(place.attributions)")
                        print("Current PlaceID \(place.placeID)")
                    }
                }
            })

placesClient是实例化为GMSPlacesClient()的变量.我在这里想念什么吗?其余代码是典型的Xcode单个应用程序项目.

placesClient is a var instantiated as GMSPlacesClient(). Am I missing something here? The rest of the code is a typical Xcode single application project.

推荐答案

在这里回答我自己的问题!

Answering my own question here!

发现错误完全是我的错误(通常是这样).我正在像这样设置placesClient变量

Turns out the mistake was totally mine (as it usually is). I was setting the placesClient var like this

var placesClient = GMSPlacesClient()

在Google的示例中(在此处进行检查),placesClient变量被声明为可选的GMSPlacesClient,然后在viewDidLoad中将其设置为GMSPlacesClient.sharedClient().不幸的是我错过了那部分.代码就像

In google's example (check it here) the placesClient var is declared as an optional GMSPlacesClient and then in viewDidLoad is set to GMSPlacesClient.sharedClient(). Unfortunately I missed that part. The code is like

var placesClient: GMSPlacesClient?

override func viewDidLoad() {
    super.viewDidLoad()
    placesClient = GMSPlacesClient.sharedClient()
}

这篇关于Google Places Api iOS每日未经身份验证的使用限制超过错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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