NFSpotifyAuth
示例
要运行示例项目,请克隆仓库,并从 Example 目录先运行 pod install
。
特点
- 使用 WebOAuth 进行 Spotify 身份验证
要求
- iOS 13.0+
- Xcode 11.0+
安装
CocoaPods
NFSpotifyAuth 可以通过 CocoaPods 获得。要安装 NFSpotifyAuth
,只需将以下行添加到您的 Podfile
pod 'NFSpotifyAuth'
手动
- 下载并将
/Pod/Classes
文件夹拖入您的项目中。 - 恭喜!
使用方法
NFSpotifyOAuth.shared.set(clientId: SpotifyClientID, clientSecret: SpotifyClientSecret, redirectURI: SpotifyCallbackURI)
let rectFrame = CGRect(x: 30, y: 80, width: view.frame.width - 60, height: 400)
let loginView = NFSpotifyLoginView(frame: rectFrame, scopes: NFSpotifyAvailableScopes, delegate: self)
view.addSubview(loginView)
loginView.show()
// mini player
let miniPlayer = NFSpotifyMiniPlayerView.instance(withDelegate: self)
let playerFrame = CGRect(x: 0, y: view.frame.height - miniPlayer.frame.size.height, width: view.frame.size.width, height: miniPlayer.frame.size.height)
view.addSubview(miniPlayer)
miniPlayer.updateFrame(playerFrame)
// MARK: - NFSpotifyLoginViewDelegate
extension ViewController {
func spotifyLoginViewDidShow(_ view: NFSpotifyLoginView) {
}
func spotifyLoginViewDidClose(_ view: NFSpotifyLoginView) {
}
func spotifyLoginView(_ view: NFSpotifyLoginView, didFailWithError error: Error?) {
print("err: \(error)")
}
func spotifyLoginView(_ view: NFSpotifyLoginView, didLoginWithTokenObject tObject: NFSpotifyToken) {
print("didLoginWithTokenObject: \(tObject)")
}
}
作者
Neil Francis Ramirez Hipona, [email&rameriz]
许可证
NFSpotifyAuth 基于 MIT 许可证。有关更多信息,请参阅 LICENSE 文件。