Hi I am a bit new to iOS development. I want to create a variable that store the UID = user.id from the firebase authentication check. Then I want to use that UID to put it in the url so that I can use that to call our backend. However, I couldn't figure out how to do it...
Xcode 11.6 swift 5
here is my swift code:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
var UID = ""
Auth.auth().addStateDidChangeListener { (auth, user) in
if let user = user {
self.userName.text = user.displayName
//print(user.uid)
UID = user.uid
} else {
self.userName.text = "error"
}
}
self.navigationItem.setHidesBackButton(true, animated: true)
//let url = vehicleManager.dataURL
let url = rewardManager.dataURL
print("UID is: \(UID)")
rewardManager.performRequest(dataURL: url)
claimWebKitView.load(URLRequest(url: URL(string: "https://camo.githubusercontent.com/6b254aa699df7f9464967009129c3017de721b77/68747470733a2f2f7261772e6769746875622e636f6d2f5068696c4a61792f4d50416e64726f696443686172742f6d61737465722f73637265656e73686f74732f7363617474657263686172742e706e67")!))
premiumWebKitView.load(URLRequest(url: URL(string: "https://camo.githubusercontent.com/e29d8d3316203700965cc6cc56e67b779f2845bb/68747470733a2f2f7261772e6769746875622e636f6d2f5068696c4a61792f4d5043686172742f6d61737465722f73637265656e73686f74732f636f6d62696e65645f63686172742e706e67")!))
}
how can I pass the user.uid to my url? thanks