ios_google_places_autocomplete
ios_google_places_autocomplete copied to clipboard
Getting Error :- GooglePlaces API Error: REQUEST_DENIED
Hi,
While searching any thing getting error :- GooglePlaces API Error: REQUEST_DENIED
We added our API key properly and follow the below :-
Manual Simply copy GooglePlacesAutocomplete.swift and GooglePlacesAutocomplete.xib to your project. Note: Don't forget to add the PoweredByGoogle image to your xcassets.
Thanks,
@watsonbox , In swift 3 and ios 10 I am also getting the same error. Previously it used to work fine
The same problem for me.
It seems that I have tracked down the problem. It was related to escaping of optional query parameters. Here is the solution (I have rewritten the origin functions):
fileprivate class func query(_ parameters: [String: AnyObject]) -> String {
var components: [(String, String)] = []
for key in Array(parameters.keys).sorted(by: <) {
if let value = parameters[key] as? String {
let escapedValue = escape(value)
components += [(escape(key), escapedValue)]
}
}
return (components.map{"\($0)=\($1)"} as [String]).joined(separator: "&")
}
fileprivate class func escape(_ string: String) -> String {
var escapedCharacters = CharacterSet.urlQueryAllowed
escapedCharacters.remove(charactersIn: ":/?&=;+!@#$()',*")
return string.addingPercentEncoding(withAllowedCharacters: escapedCharacters) ?? ""
}
fileprivate class func query(_ parameters: [String: AnyObject]) -> String {
var components: [(String, String)] = []
for key in Array(parameters.keys).sorted(by: <) {
let value: AnyObject = parameters[key]!
components += [(escape(key), escape("\(value)"))]
}
return (components.map{"\($0)=\($1)"} as [String]).joined(separator: "&")
}
Or like this works too