Skip to content

nfhipona/NFSpotifyAuth

Repository files navigation

NFSpotifyAuth

CI Status Version License Platform

Demo

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Features

  • Spotify Authentication using WebOAuth
  • Mini Player View

Requirements

  • iOS 13.0+
  • Xcode 11.0+

Installation

CocoaPods

NFSpotifyAuth is available through CocoaPods. To install NFSpotifyAuth, simply add the following line to your Podfile:

pod 'NFSpotifyAuth'

Manually

  1. Download and drop /Pod/Classesfolder in your project.
  2. Congratulations!

Usage

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)")
    }
}

Author

Neil Francis Ramirez Hipona, nferocious76@gmail.com

License

NFSpotifyAuth is available under the MIT license. See the LICENSE file for more info.

About

Spotify authenticator using WebOAuth Spotify API

Resources

License

Stars

Watchers

Forks

Packages

No packages published