因此在处理过程中,我有一些正在使用的代码。但这似乎无效,并且给了我let userDetails: Dictionary<String, Any> = ["userName" : chosenName, "user-level" : BASIC, "email-addr" : emailAddr, ACC_CREATE_DATE_STR : timeStamp, ACC_LAST_ACTIVITY_STR : timeStamp]
ref.updateChildValues(userDetails, withCompletionBlock: { (error, ref) in
if let err = error {
let createAlert = UIAlertController(title: "Error", message: "Please try again\n\(err.localizedDescription)", preferredStyle: .alert)
createAlert.addAction(UIAlertAction(title: "Got it", style: .default, handler: nil))
self.present(createAlert, animated: true, completion: nil)
} else {
// user profile created successfully
InstanceID.instanceID().instanceID(handler: { (result, error) in
if let error = error {
print("Error fetching FCM token: \(error)")
} else if let result = result {
ref.child("fcm-token").setValue(result.token)
}
self.dismiss(animated: true, completion: nil)
})
}
})
。
我已经将其拆分,并为变量指定了指向的位置。
NullPointerExceptions