Location Error - Google Places API

I get this error with my code, and I followed the instructions for the Google training course step by step.

Pick Place error: The operation couldn't be completed. The Places API could not find the user location. This may be because the user has not allowed the application to access location information. 

I added the relevant information to info.plist and my code looks like this:

 import UIKit import GooglePlaces class ViewController: UIViewController { var placesClient: GMSPlacesClient! @IBOutlet var nameLabel: UILabel! @IBOutlet var addressLabel: UILabel! override func viewDidLoad() { super.viewDidLoad() let locationManager = CLLocationManager() locationManager.requestWhenInUseAuthorization() locationManager.startUpdatingLocation() placesClient = GMSPlacesClient.shared() } @IBAction func getCurrentPlace(_ sender: UIButton) { placesClient.currentPlace(callback: { (placeLikelihoodList, error) -> Void in if let error = error { print("Pick Place error: \(error.localizedDescription)") return } self.nameLabel.text = "No current place" self.addressLabel.text = "" if let placeLikelihoodList = placeLikelihoodList { let place = placeLikelihoodList.likelihoods.first?.place if let place = place { self.nameLabel.text = place.name self.addressLabel.text = place.formattedAddress?.components(separatedBy: ", ") .joined(separator: "\n") } } } ) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } 

The location window with permission / prohibition disappears too quickly, and even when I click so that nothing happens, I have no idea how to solve this, because I just follow the google document.

In addition, this error appears -

 2017-03-26 14:38:27.472739 Restaurant[26616:2797750] subsystem: com.apple.BackBoardServices.fence, category: Observer, enable_level: 1, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0, enable_private_data: 0 
+5
source share
1 answer

you need to check the restriction on https://console.developers.google.com , the free version is only 1000 per day, I need to create another project and a new key to continue testing.

0
source

Source: https://habr.com/ru/post/1265922/


All Articles