保存最近的build立到谷歌用户帐户在Swift2

这部分应用程序的目的是为用户(用Googleloginlogin)find离他们最近的地方,并自动将其保存到用户的谷歌帐户。

下面的方法工作正常,抓住用户所在的最可能的地方(placeLakelihoods数组中的第一个对象)。 现在我需要做的是将其保存到用户的Google帐户(他们login的那个)。

任何领导或想法如何做到这一点,甚至可能? 感谢你一如既往的帮助。

func getInfoViaPlacesClient() { let placesClient = GMSPlacesClient.sharedClient() placesClient.currentPlaceWithCallback { (likelihoodlist, error) -> Void in if error != nil { print("Current Place error: \(error!.localizedDescription)") return } let nearestPlace : GMSPlaceLikelihood = likelihoodlist!.likelihoods.first as! GMSPlaceLikelihood print(nearestPlace.likelihood) self.nearestPlace = nearestPlace.place self.saveNearestPlace() } } 

保存方法…我想我在正确的轨道上,但我不断收到这个错误在placesClient.addPlace块…

添加位置错误:操作无法完成。 (com.google.places.server.ErrorDomain错误-1。)

 func saveNearestPlace() { //to app(core data) let placesClient = GMSPlacesClient.sharedClient() let name = self.nearestPlace!.name let address = self.nearestPlace!.formattedAddress LocationController.sharedInstance.addLocationWithName(name!, address: address!) //to google let addedPlace = GMSUserAddedPlace() addedPlace.name = self.nearestPlace?.name addedPlace.coordinate = (self.nearestPlace?.coordinate)! addedPlace.types = self.nearestPlace?.types addedPlace.address = self.nearestPlace?.formattedAddress placesClient.addPlace(addedPlace, callback: { (place: GMSPlace?, error: NSError?) -> Void in if let error = error { print("Add Place error: \(error.localizedDescription)") return } if let place = place { self.nearestPlace = place print("Added place with placeID \(place.placeID)") print("Added Place name \(place.name)") print("Added Place address \(place.formattedAddress)") } }) }