In iOSNativeSwiftTemplate, QR code login features are labeled by this comment: “Log in via Salesforce UI Bridge API generated QR codes.”
To enable QR code login features in iOSNativeSwiftTemplate, modify these files.
AppDelegate.swift
To configure the QR code login setup to run on app initialization, go to the init method and uncomment the call to setupQrCodeLogin.
1override init(){23 // Uncomment when enabling log in via Salesforce UI Bridge API generated QR codes.4 self.setupQrCodeLogin()56 ...78}
To customize the QR code login’s URL format, use the sample code provided in SceneDelegate.useQrCodeLoginUrl(_: ).
When using a QR code login URL generated by the UI Bridge API, you can choose between Mobile SDK’s reference format or a custom format.
1internal var isQrCodeLoginUsingReferenceUrlFormat = true
If you’re using our reference format, make sure to fill in these variables.
1internal var qrCodeLoginUrlScheme = "YOUR_QR_CODE_LOGIN_URL_SCHEME"2internal var qrCodeLoginUrlHost = "YOUR_QR_CODE_LOGIN_URL_HOST"
If you’re using a custom format, set isQrCodeLoginUsingReferenceUrlFormat to false, and then provide the URL handling logic in SceneDelegate.useQrCodeLogInUrl. To modify the QR code login URL format, you can customize the values in setupQrCodeLogin by following the comments provided in the source code.
To allow your app to receive QR code login links from external QR code readers, uncomment the calls to useQrCodeLogInUrl in the scene(_: openURLContexts:) and scene(_: willConnectTo: options:) methods.
1func scene(_ scene: UIScene,2 openURLContexts urlContexts: Set<UIOpenURLContext>)3{45 // Uncomment when enabling log in via Salesforce UI Bridge API generated QR codes.6 if let urlContext = urlContexts.first{7 useQrCodeLogInUrl(urlContext.url)8}910 ...1112}1314 ...1516 func scene(_ scene: UIScene,17 willConnectTo session: UISceneSession,18 options connectionOptions: UIScene.ConnectionOptions)19{2021 // Uncomment when enabling log in via Salesforce UI Bridge API generated QR codes.22 if let urlContext = connectionOptions.urlContexts.first{23 useQrCodeLogInUrl(urlContext.url)24}2526 ...2728}
We've Moved
Welcome to the new home of the Mobile SDK Developer Guide! For now, the Japanese guide can be found in PDF form.