Objective-C wrapper for Last.fm API
Install cocoapods with the following command:
$ gem install cocoapods
To integrate LastFMKit into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
target 'TargetName' do
pod 'LastFMKit', '~> 1.0'
end
Then, run the following command:
$ pod install
Install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate LastFMKit into your Xcode project using Carthage, specify it in your Cartfile
:
github "mourke/LastFMKit" ~> 1.0
Run carthage
to build the framework and drag the built LastFMKit.framework
into your Xcode project.
The API information must be set every time the application starts. If you do not do this, an exception will be raised on any attempt to make calls to the wrapper. The best place to do this is inside the application:didFinishLaunchingWithOptions:
function in your AppDelegate.m file:
[[LFMAuth sharedInstance] setApiKey:@"YOUR_API_KEY"];
[[LFMAuth sharedInstance] setApiSecret:@"YOUR_API_SECRET"];
Auth.shared().apiKey = "YOUR_API_KEY"
Auth.shared().apiSecret = "YOUR_API_SECRET"
Authentication need only be done once, but is required to make any authenticated calls to the API. The LFMSession
object will be stored in the user's keychain and loaded on subsequent app launches.
LFMAuth *sharedInstance = [LFMAuth sharedInstance];
if (!sharedInstance.userHasAuthenticated) {
[sharedInstance getSessionWithUsername:@"USERNAME" password:@"PASSWORD" callback:^(NSError * _Nullable error, LFMSession * _Nullable session) {
if (error != nil) {
// Handle error
} else {
// Success
}
}];
}
let shared = Auth.shared()
if !shared.userHasAuthenticated {
shared.getSession(username: "USERNAME", password: "PASSWORD") { (error, session) in
if let session = session {
// Success
} else if let error = error {
// Handle error
}
}
}
LastFMKit is released under the MIT license. See LICENSE for details.