TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Oct 2016 |
Maintained by Kevin Renskers, eightytwo.
Loosely based on LastFMService from the old Last.fm iPhone app, but non-blocking, more readable, much easier to use (and to extend) and with less dependencies.
// Set the Last.fm session info
[LastFm sharedInstance].apiKey = @"xxx";
[LastFm sharedInstance].apiSecret = @"xxx";
[LastFm sharedInstance].session = session;
[LastFm sharedInstance].username = username;
// Get artist info
[[LastFm sharedInstance] getInfoForArtist:@"Pink Floyd" successHandler:^(NSDictionary *result) {
NSLog(@"result: %@", result);
} failureHandler:^(NSError *error) {
NSLog(@"error: %@", error);
}];
// Scrobble a track
[[LastFm sharedInstance] sendScrobbledTrack:@"Wish You Were Here" byArtist:@"Pink Floyd" onAlbum:@"Wish You Were Here" withDuration:534 atTimestamp:(int)[[NSDate date] timeIntervalSince1970] successHandler:^(NSDictionary *result) {
NSLog(@"result: %@", result);
} failureHandler:^(NSError *error) {
NSLog(@"error: %@", error);
}];
Save the username and session you get with getSessionForUser:password:successHandler:failureHandler:
somewhere, for example in NSUserDefaults
, and on app start up set it back on [LastFm sharedInstance].username
and [LastFm sharedInstance].session
.
See the included iOS project for examples on login, logout, getting artist info and more.
There's an extensive example app available which handles login, logout, getting lots of artists in a tableview and showing their details, caching, canceling API calls, and much more.
To install the example app, you need to use CocoaPods: pod install
. You can also try it by running pod try LastFm
.
The example app only works in iOS 5 and higher due to the usage of storyboards. The SDK itself works in iOS 4 and higher.
You can install LastFm with CocoaPods. Just add the following line to your Podfile, and run pod install
:
pod 'LastFm'
You can also simply clone the repository and drag the LastFm subfolder into your Xcode project. Be sure to install KissXML yourself.
Have a bug? Please create an issue on GitHub!
Are you using LastFm in your iOS or Mac OS X app? Send a pull request with an updated README.md file to be included.
LastFm is available under the MIT license. See the LICENSE file for more info.