Skip to content

Commit

Permalink
Ensure correct thread execution in test app (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
cocojoe authored Oct 9, 2018
1 parent a3e4774 commit be67d8c
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions App/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ class ViewController: UIViewController {
self.onAuth = { [weak self] in
switch $0 {
case .failure(let cause):
let alert = UIAlertController(title: "Auth Failed!", message: "\(cause)", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))
self?.present(alert, animated: true, completion: nil)
DispatchQueue.main.async {
let alert = UIAlertController(title: "Auth Failed!", message: "\(cause)", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))
self?.present(alert, animated: true, completion: nil)
}
case .success(let credentials):
let token = credentials.accessToken ?? credentials.idToken
let alert = UIAlertController(title: "Auth Success!", message: "Authorized and got a token \(String(describing: token))", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))
self?.present(alert, animated: true, completion: nil)
DispatchQueue.main.async {
let token = credentials.accessToken ?? credentials.idToken
let alert = UIAlertController(title: "Auth Success!", message: "Authorized and got a token \(String(describing: token))", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))
self?.present(alert, animated: true, completion: nil)
}
}
print($0)
}
Expand Down

0 comments on commit be67d8c

Please sign in to comment.