ios auth
v1.1.1
SpotifyLogin是一个轻巧的框架,使您的应用程序能够从Spotify应用中获取身份验证代码。请注意,此框架目前正在开发中,仅支持iOS-SDK功能的子集。如果您希望使用与身份验证有关的所有功能,请使用iOS-SDK。
iOS 11
SpotifyLogin.xcframework添加到项目中,通过将其拖放到框架,库和嵌入式内容中LSApplicationQueriesSchemes键来声明Spotify的URL方案spotify 。Configuration 。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 ,并设置一个将SessionManagerDelegate符合的对象与实例的delegate 。 let sessionManager = SessionManager ( configuration : configuration )
sessionManager . delegate = < #delegate object# >_sessionManager = [[SPTSessionManager alloc ] initWithConfiguration: configuration];
_sessionManager.delegate = <#delegate object#>;application(_:open:options:) UIApplicationDelegate application(_:open:options:) 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 ];