Created
August 31, 2017 14:39
-
-
Save marmelroy/b8f0b65d4275e0e8f89d1ec5f1ed2403 to your computer and use it in GitHub Desktop.
SpotifyLoginSample.swift
This file contains 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 characters
// Set up your app's URL Types and URL schemes. | |
// Add the following to your AppDelegate: | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
SpotifyLogin.shared.configure(clientID: <#T##String#>, clientSecret: <#T##String#>, redirectURL: <#T##URL#>) | |
return true | |
} | |
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool { | |
let handled = SpotifyLogin.shared.applicationOpenURL(url) { (error) in } | |
return handled | |
} | |
// Add a log in button | |
let button = SpotifyLoginButton(viewController: self, scopes: [.streaming, .userLibraryRead]) | |
self.view.addSubview(button) | |
// Retrieve the access token | |
SpotifyLogin.shared.getAccessToken { (accessToken, error) in | |
if error != nil { | |
// User is not logged in, show log in flow. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment