 import SafariServices
 
 private let loginURL = URL(string: "http://github.com/login/oauth/authorize?client_id=\(GithubAPI.clientID)&scope=user+repo+notifications")!
+private let callbackURLScheme = "freetime://"
 
 final class LoginSplashViewController: UIViewController, GithubSessionListener {
 

    @IBOutlet weak var activityIndicator: UIActivityIndicatorView!
    private weak var safariController: SFSafariViewController? = nil

    var state: State = .idle {
        didSet {
            let hideSpinner: Bool

    // MARK: Private API

    @IBAction func onSignInButton(_ sender: Any) {
        if #available(iOS 11.0, *) {
            self.authSession = SFAuthenticationSession(url: loginURL, callbackURLScheme: callbackURLScheme, completionHandler: { [weak self] (callbackUrl, error) in
                guard error == nil, let callbackUrl = callbackUrl else {
                    switch error! {
                    case SFAuthenticationError.canceledLogin: break
                    default: self?.handleError()
                    }
                    return
                }
                self?.client.sessionManager.receivedCodeRedirect(url: callbackUrl)
            })
            self.authSession?.start()
        } else {
            guard let safariController = try? SFSafariViewController.configured(with: loginURL) else { return }
            self.safariController = safariController
            present(safariController, animated: true)
        }
    }

    @IBAction func onPersonalAccessTokenButton(_ sender: Any) {
