Created
January 30, 2017 10:16
-
-
Save surayashivji/6dda4138d41b30f561618e1bb5c718a0 to your computer and use it in GitHub Desktop.
Revisions
-
surayashivji created this gist
Jan 30, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ class AppDelegate: UIResponder, UIApplicationDelegate, SpotifyAuthDelegate { var window: UIWindow? var navigationController: UINavigationController = UINavigationController() private var auth: SpotifyAuth { return SpotifyAuth.shared } private var rootViewController: UIViewController { return SpotifyAuth.shared.isAuthenticated ? YesViewController() : ViewController() } func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { auth.delegate = self self.window = UIWindow(frame: UIScreen.main.bounds) let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil) navigationController = storyboard.instantiateInitialViewController() as! UINavigationController navigationController.viewControllers = [rootViewController] self.window?.rootViewController = navigationController self.window?.makeKeyAndVisible() return true } func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool { auth.handle(authenticationURL: url) auth.fetchAccessToken() return true } // MARK: - SpotifyAuthDelegate func sessionUpdated(in spotifyAuth: SpotifyAuth) { navigationController.setViewControllers([rootViewController], animated: false) } }