Firebase: How to get User.uid?
You might want to use a guard, as a force unwrap might break your app if a user isn’t signed in.
guard let userID = Auth.auth().currentUser?.uid else { return }
This is how you get the user's uid:
let userID = Auth.auth().currentUser!.uid
UPDATE: Since this answer is getting upvotes, make sure you prevent your app from crashing by using guard
s:
guard let userID = Auth.auth().currentUser?.uid else { return }