2017-03-26 10 views
5

私のコードでこのエラーが発生しました.Googleチュートリアルの手順を順を追って説明しました。Pick Place Error - Google Places API

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

私はのInfo.plistに関連する情報を追加していると私のコードは次のようになります -

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. 
    } 



} 

許可/拒否を持つ場所ウィンドウがあまりにも急速に消え、私は許可を押しても、何も起こりません、私はちょうどGoogleの次のように私はこれを解決する方法を考えていない。

はまた、このエラーが表示されます -

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 

答えて

0

あなたは、https://console.developers.google.com日あたり1000無料版そののみを要求制限をチェックする必要があり、私は別のプロジェクトとキープのテストのための新しいキーを作成する必要があります。