@@ -54,28 +54,30 @@ import Foundation
54
54
///
55
55
/// See more details
56
56
/// [here](https://developer.apple.com/documentation/authenticationservices/securing_logins_with_icloud_keychain_verification_codes)
57
- @MainActor @ objc ( openInOTPAppWithQRCodeURL: )
57
+ @objc ( openInOTPAppWithQRCodeURL: )
58
58
open func openInOTPApp( withQRCodeURL qrCodeURL: String ) {
59
- if GULAppEnvironmentUtil . isAppExtension ( ) {
60
- // iOS App extensions should not call [UIApplication sharedApplication], even if
61
- // UIApplication responds to it.
62
- return
63
- }
59
+ DispatchQueue . main. async {
60
+ if GULAppEnvironmentUtil . isAppExtension ( ) {
61
+ // iOS App extensions should not call [UIApplication sharedApplication], even if
62
+ // UIApplication responds to it.
63
+ return
64
+ }
64
65
65
- // Using reflection here to avoid build errors in extensions.
66
- // The `UIApplication.sharedApplication` requires main actor
67
- // synchronization.
68
- let sel = NSSelectorFromString ( " sharedApplication " )
69
- guard UIApplication . responds ( to: sel) ,
70
- let rawApplication = UIApplication . perform ( sel) ,
71
- let application = rawApplication. takeUnretainedValue ( ) as? UIApplication else {
72
- return
73
- }
74
- if let url = URL ( string: qrCodeURL) , application. canOpenURL ( url) {
75
- application. open ( url, options: [ : ] , completionHandler: nil )
76
- } else {
77
- AuthLog . logError ( code: " I-AUT000019 " ,
78
- message: " URL: \( qrCodeURL) cannot be opened " )
66
+ // Using reflection here to avoid build errors in extensions.
67
+ // The `UIApplication.sharedApplication` requires main actor
68
+ // synchronization.
69
+ let sel = NSSelectorFromString ( " sharedApplication " )
70
+ guard UIApplication . responds ( to: sel) ,
71
+ let rawApplication = UIApplication . perform ( sel) ,
72
+ let application = rawApplication. takeUnretainedValue ( ) as? UIApplication else {
73
+ return
74
+ }
75
+ if let url = URL ( string: qrCodeURL) , application. canOpenURL ( url) {
76
+ application. open ( url, options: [ : ] , completionHandler: nil )
77
+ } else {
78
+ AuthLog . logError ( code: " I-AUT000019 " ,
79
+ message: " URL: \( qrCodeURL) cannot be opened " )
80
+ }
79
81
}
80
82
}
81
83
0 commit comments