ios auth
v1.1.1
SpotifyLogin
is a lightweight framework that enables your application to obtain the authentication code from the Spotify app. Please note that this framework is currently under development and only supports a subset of the ios-sdk's functionalities. If you wish to use all features related to authentication, please utilize ios-sdk.
iOS 11
SpotifyLogin.xcframework
to your project by dragging and dropping it in Frameworks, Libraries, and Embedded Content
spotify
by adding the LSApplicationQueriesSchemes
key.Configuration
with your client ID and redirect URI.import SpotifyLogin
let configuration = Configuration(clientID: "your_client_id", redirectURLString: "your_redirect_uri")
#import <SpotifyLogin/SpotifyLogin.h>
SPTConfiguration* configuration = [[SPTConfiguration alloc] initWithClientID:@"your_client_id" redirectURLString:@"your_redirect_uri"];
SessionManager
with your configuration and set an object that conforms SessionManagerDelegate
to the delegate
of the instance.let sessionManager = SessionManager(configuration: configuration)
sessionManager.delegate = <#delegate object#>
_sessionManager = [[SPTSessionManager alloc] initWithConfiguration:configuration];
_sessionManager.delegate = <#delegate object#>;
application(_:open:options:)
method to your UIApplicationDelegate
and call sessionManager's application(_:open:options:)
there.class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
return sessionManager.openURL(url)
}
}
@implementation AppDelegate
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
return [_sessionManager openURL:url];
}
@end
sessionManager.startAuthorizationCodeProcess(with: [.playlistModifyPublic, .playlistModifyPrivate])
[_sessionManager startAuthorizationCodeProcessWith:SPTScopePlaylistModifyPublic|SPTScopePlaylistModifyPublic campaign:NULL];