@@ -11,6 +11,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1111 TradeItSDK . configure (
1212 apiKey: AppDelegate . API_KEY,
1313 oAuthCallbackUrl: URL ( string: " tradeItExampleScheme://completeOAuth " ) !,
14+ verify1FACallbackUrl: URL ( string: " tradeItExampleScheme://complete1FA " ) !,
1415 environment: AppDelegate . ENVIRONMENT,
1516 userCountryCode: " US "
1617 )
@@ -45,16 +46,20 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
4546 print ( " =====> Received OAuth callback URL: \( url. absoluteString) " )
4647
4748 let MANUAL_HOST = " manualCompleteOAuth "
49+ let VERIFY_1FA = " complete1FA "
4850
4951 // Check for the intended url.scheme, url.host, and url.path before proceeding
5052 if let urlComponents = URLComponents ( url: url, resolvingAgainstBaseURL: false ) ,
5153 urlComponents. scheme == " tradeitexamplescheme " ,
5254 let host = urlComponents. host,
53- let queryItems = urlComponents. queryItems,
54- let oAuthVerifier = queryItems. filter ( { $0. name == " oAuthVerifier " } ) . first? . value {
55+ let queryItems = urlComponents. queryItems {
5556
5657 if host == MANUAL_HOST {
57- self . completeManualOAuth ( oAuthVerifier: oAuthVerifier)
58+ if let oAuthVerifier = queryItems. filter ( { $0. name == " oAuthVerifier " } ) . first? . value {
59+ self . completeManualOAuth ( oAuthVerifier: oAuthVerifier)
60+ }
61+ } else if host == VERIFY_1FA {
62+ self . handleExampleVerify1FA ( verify1FACallbackUrl: url, host: host)
5863 } else {
5964 self . handleExampleOAuth ( oAuthCallbackUrl: url, host: host)
6065 }
@@ -211,6 +216,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
211216 }
212217 }
213218 }
219+
220+ private func handleExampleVerify1FA( verify1FACallbackUrl: URL , host: String ) {
221+ let VERIFY_1FA = " complete1FA "
222+ if var topViewController = UIApplication . shared. keyWindow? . rootViewController {
223+ while let presentedViewController = topViewController. presentedViewController {
224+ topViewController = presentedViewController
225+ }
226+
227+ if let navController = topViewController as? UINavigationController ,
228+ let navTopViewController = navController. topViewController {
229+ topViewController = navTopViewController
230+ }
231+
232+ switch host {
233+ case VERIFY_1FA:
234+ TradeItSDK . launcher. handleVerify1FACallback (
235+ onTopmostViewController: topViewController,
236+ verify1FACallbackUrl: verify1FACallbackUrl
237+ )
238+ default :
239+ print ( " =====> ERROR: Received unknown verify 1 FA callback URL host: \( host) " )
240+ }
241+ }
242+ }
214243}
215244
216245// Only implement this protocol if you need to inject your own market data
0 commit comments