I have an iOS app using the latest Salesforce iOS SDK. It authenticates users through a webview using oAuth2.0 on the Salesforce site so I do not capture the username in my app
SalesforceMobileSDK-iOS 7.0
Swift Version
import SalesforceSDKCore
guard let userId = UserAccountManager.shared.currentUserAccountIdentity?.userId else {return}
Depends on what you need, this maybe helpful as well:
guard let userId = UserAccountManager.shared.currentUserAccount?.idData?.userId else {return}