【发布时间】:2018-11-08 23:55:54
【问题描述】:
我正在尝试保存纬度。并且很长。到数据库。但是数据库没有显示任何内容,也没有在 Swift 中显示任何错误。我的代码如下所示。
override func viewDidLoad() {
super.viewDidLoad()
mapView.showsUserLocation = true
if CLLocationManager.locationServicesEnabled() == true {
if CLLocationManager.authorizationStatus() == .restricted || CLLocationManager.authorizationStatus() == .denied || CLLocationManager.authorizationStatus() == .notDetermined {
locationManager.requestWhenInUseAuthorization()
}
let userLatitude = locationManager.location?.coordinate.latitude
let userLongtitude = locationManager.location?.coordinate.longitude
let userTime = locationManager.location?.timestamp
Auth.auth().createUser(withEmail: "test@gmail.com",password: "xxxx", completion: {(User, error) in
if error != nil {
self.displayMyalertMessage(userMessage: error!.localizedDescription)
} else {
print("Success")
}
guard let uid = User?.user.uid else {return}
let ref = Database.database().reference(fromURL:"")
let userReference = ref.child("Locations").child(uid)
let values = ["Latitude": userLatitude as Any, "Longtitude": userLongtitude as Any, "Time": UserTime as Any] as [String : Any]
userReference.updateChildValues(values, withCompletionBlock: { (error, reference) in
if error != nil {
print(error as Any)
return
}
})
})
}
【问题讨论】:
标签: swift firebase firebase-realtime-database core-location