After update to Auth0.swift version 1.17.1, The app started to throw the exception:
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIViewController presentingViewController]
PID: 1180, TID: 314715, Thread name: (none), Queue name: NSOperationQueue 0x10b2210b0 (QOS: UNSPECIFIED), QoS: 0
Backtrace:
4 Auth0 0x00000001088be3dc $s5Auth013SafariWebAuthC03newB0_8callbackSo22SFSafariViewControllerC_yAA6ResultOyAA11CredentialsCGct10Foundation3URLV_yALctFyALcfU_ + 192
5 Auth0 0x000000010889e99c $s5Auth04PKCEV11credentials4from8callbackySDyS2SG_yAA6ResultOyAA11CredentialsCGctFyALcfU_ + 640
6 Auth0 0x00000001088a2f64 $s5Auth06ResultOyAA11CredentialsCGIegg_AFIegn_TR + 36
7 Auth0 0x000000010888ad9c $s5Auth020authenticationObject4from8callbackyAA8ResponseVyAA19AuthenticationErrorCG_yAA6ResultOyxGXEtAA17JSONObjectPayloadRzlFAA11CredentialsC_Tg5 + 332
8 Auth0 0x00000001088b2a70 $s5Auth07RequestV5startyyyAA6ResultOyxGcFy10Foundation4DataVSg_So13NSURLResponseCSgs5Error_pSgtcfU_AA11CredentialsC_AA014AuthenticationH0CTg5 + 280
9 Auth0 0x00000001088b5398 $s5Auth07RequestV5startyyyAA6ResultOyxGcFy10Foundation4DataVSg_So13NSURLResponseCSgs5Error_pSgtcfU_AA11CredentialsC_AA014AuthenticationH0CTg5TA + 32
10 Auth0 0x00000001088b2d6c $s10Foundation4DataVSgSo13NSURLResponseCSgs5Error_pSgIegggg_So6NSDataCSgAGSo7NSErrorCSgIeyByyy_TR + 148
11 Sonic-Inhouse 0x00000001039e7a30 __SplunkNSCFURLSessionDataTaskWithRequestCompletionHandler_block_invoke + 460
12 Dynatrace 0x0000000105e810ec __74-[DTXURLSessionInstrumentation dataTaskWithRequest_DTX:completionHandler:]_block_invoke + 792
13 CFNetwork 0x00000001be1aad7c CFNetServiceBrowserSearchForServices + 93016
14 CFNetwork 0x00000001be1bb2b0 _CFHTTPMessageSetResponseProxyURL + 9540
15 Foundation 0x00000001bb35d65c 32C04A3C-D431-351A-AE6A-1D87EE3CFFB6 + 1132124
16 Foundation 0x00000001bb267448 32C04A3C-D431-351A-AE6A-1D87EE3CFFB6 + 123976
17 Foundation 0x00000001bb35f8e4 32C04A3C-D431-351A-AE6A-1D87EE3CFFB6 + 1140964
18 Foundation 0x00000001bb2670e0 32C04A3C-D431-351A-AE6A-1D87EE3CFFB6 + 123104
19 Foundation 0x00000001bb3602dc 32C04A3C-D431-351A-AE6A-1D87EE3CFFB6 + 1143516
20 Foundation 0x00000001bb35fda8 32C04A3C-D431-351A-AE6A-1D87EE3CFFB6 + 1142184
21 libdispatch.dylib 0x000000010af11298 _dispatch_block_async_invoke2 + 104
22 libdispatch.dylib 0x000000010af02c04 _dispatch_client_callout + 16
23 libdispatch.dylib 0x000000010af05808 _dispatch_continuation_pop + 524
24 libdispatch.dylib 0x000000010af04c88 _dispatch_async_redirect_invoke + 624
25 libdispatch.dylib 0x000000010af14168 _dispatch_root_queue_drain + 376
26 libdispatch.dylib 0x000000010af14a90 _dispatch_worker_thread2 + 156
27 libsystem_pthread.dylib 0x00000001bacb5f64 _pthread_wqthread + 212
28 libsystem_pthread.dylib 0x00000001bacb8ae0 start_wqthread + 8
=================================================================
The implementation:
func login(params: [String: Any], completion: @escaping (BFFAuthenticable.AuthResult) -> Void) {
var auth = Auth0
.webAuth(
clientId: clientId,
domain: domain)
.scope("openid offline_access") //offline_access is required for refresh token...
.audience(audience)
let auth0Params: [String: String] = [
"connection": connection,
"flow": "login",
"prompt": "login"
]
auth = auth.parameters(auth0Params)
if #available(iOS 11.0, *) {
//Prevent ios 11 from showing a prompt by using `SFSafariViewController` vs. `SFAuthenticationSession`
auth = auth.useLegacyAuthentication()
}
auth.start {
result in
self.handle(result, completion: completion)
}
}