-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fatal error: Unexpectedly found nil while unwrapping an Optional value #62
Comments
My guess is the sessionToKeepAlive variable is beeing nil for the second time. var sessionToKeepAlive: Any? // if we do not keep the session alive, it will get closed immediately while showing the dialog
completionHandler = { (url: URL?, err: Error?) in
self.completionHandler = nil
if #available(iOS 12, *) {
(sessionToKeepAlive as! ASWebAuthenticationSession).cancel() // Error Happens this line 29 in SwiftFlutterWebAuth2Plugin
} else if #available(iOS 11, *) {
(sessionToKeepAlive as! SFAuthenticationSession).cancel()
}
sessionToKeepAlive = nil EDIT: after commenting out the last line in the code block => "sessionToKeepAlive = nil". The issue seems to be gone. @ThexXTURBOXx can you maybe give an hint why do we have to set it to nil and what would gone wrong if we dont set it to nil. |
I could fix the issue by wrapping the oauth2 call with a timer. I guess you need to wait a little untill the app is on the foreground succesfully. Timer(Duration(milliseconds: lazyLoginDelayTime), () async {
List<String> scopes = ["*****", "******"];
await account.createOAuth2Session(
provider: "*******", scopes: scopes);
await ref.read(authProvider.notifier).login();
}); Closing for now. |
Same issue, is it fixed in the 3.0.0? |
I think I have changed nothing in the Apple-specific implementations. |
Here is a stack trace, perhaps it will help: #0 (null) in Swift runtime failure: Unexpectedly found nil while unwrapping an Optional value () #1 0x000000010416d06c in closure #1 in SwiftFlutterWebAuth2Plugin.handle(_:result:) at /Users/xxx/.pub-cache/hosted/pub.dev/flutter_web_auth_2-2.2.1/ios/Classes/SwiftFlutterWebAuth2Plugin.swift:29 #2 0x000000010416cc08 in closure #1 in SwiftFlutterWebAuth2Plugin.handle(_:result:) at /Users/xxx/.pub-cache/hosted/pub.dev/flutter_web_auth_2-2.2.1/ios/Classes/SwiftFlutterWebAuth2Plugin.swift:29 #3 (null) in thunk for @escaping @callee_guaranteed (@in_guaranteed URL?, @guaranteed Error?) -> () () #4 (null) in -[ASWebAuthenticationSession _startDryRun:] () #5 0x000000010416ebb8 in specialized SwiftFlutterWebAuth2Plugin.handle(_:result:) at /Users/xxx/.pub-cache/hosted/pub.dev/flutter_web_auth_2-2.2.1/ios/Classes/SwiftFlutterWebAuth2Plugin.swift:100 #6 (null) in specialized SwiftFlutterWebAuth2Plugin.handle(_:result:) () #7 (null) in @objc SwiftFlutterWebAuth2Plugin.handle(_:result:) () |
Thanks for the stacktrace. However, it sadly does not contain any additional information. |
Will close for now until further feedback on |
Describe the bug
App crashes after second time I initialize oauth2 flow in IOS.
To Reproduce
Steps to reproduce the behavior:
Device (please complete the following information!)
flutter_web_auth_2
version: 2.2.1The text was updated successfully, but these errors were encountered: