Skip to content
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

fix: calls ui apis on main thread #124

Merged
merged 2 commits into from
Mar 22, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 12 additions & 14 deletions Source/BluemixAppID/internal/AuthorizationUIManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ public class AuthorizationUIManager {
self.authorizationUrl = authorizationUrl
self.redirectUri = redirectUri
}

public func launch() {
AuthorizationUIManager.logger.debug(message: "Launching safari view")
loginView = safariView(url: URL(string: authorizationUrl )!)
loginView?.authorizationDelegate = authorizationDelegate
let rootView = UIApplication.shared.keyWindow?.rootViewController
let currentView = rootView?.presentedViewController
let view = currentView != nil ? currentView : rootView
DispatchQueue.main.async {
let rootView = UIApplication.shared.keyWindow?.rootViewController
let currentView = rootView?.presentedViewController
let view = currentView != nil ? currentView : rootView
view?.present(self.loginView!, animated: true, completion: nil)
}
}

public func application(_ application: UIApplication, open url: URL, options :[UIApplicationOpenURLOptionsKey: Any]) -> Bool {

func tokenRequest(code: String?, errMsg:String?) {
loginView?.dismiss(animated: true, completion: { () -> Void in
guard errMsg == nil else {
Expand All @@ -53,11 +53,11 @@ public class AuthorizationUIManager {
return
}
AuthorizationUIManager.logger.debug(message: "Obtaining tokens")

self.oAuthManager.tokenManager?.obtainTokensAuthCode(code: unwrappedCode, authorizationDelegate: self.authorizationDelegate)
})
}

if let err = Utils.getParamFromQuery(url: url, paramName: "error") {
loginView?.dismiss(animated: true, completion: { () -> Void in
if err == "invalid_client" {
Expand Down Expand Up @@ -104,12 +104,10 @@ public class AuthorizationUIManager {
}
return false
}

}




}




}