Hello,
When I use the code from the website to set my current users location to their current CLLocation, for some reason it updates the first user on my list rather than the user who is currently logged in. Can you help?
My code (mostly from support site with slight change to use current location)
func saveUserWithGeoAsync() {
if( CLLocationManager.authorizationStatus() == CLAuthorizationStatus.AuthorizedWhenInUse ||
CLLocationManager.authorizationStatus() == CLAuthorizationStatus.Authorized){
self.myLocation = self.locationManager.location
}
self.backendless.persistenceService.of(BackendlessUser.ofClass()).findFirst(
{ ( data : AnyObject!) -> () in
let user = data as! BackendlessUser
let geoPoint = GeoPoint.geoPoint(GEO_POINT(latitude: self.myLocation!.coordinate.latitude, longitude: self.myLocation!.coordinate.longitude)) as! GeoPoint
user.setProperty("lastLocation", object: geoPoint)
self.backendless.persistenceService.of(BackendlessUser.ofClass()).save(
user,
response: { ( data : AnyObject!) -> () in
let user = data as! BackendlessUser
print("saveUserWithGeoAsync - User has been saved: \(user)")
},
error: { ( fault : Fault!) -> () in
print("saveUserWithGeoAsync - Server reported an error: \(fault)")
}
)
},
error: { ( fault : Fault!) -> () in
print("saveUserWithGeoAsync - Server reported an error: \(fault)")
}
)
}