League of Legends chat service library for iOS and OS X.
Add the following to your Podfile
and then run pod install
pod 'Folklore'
Don't forget to #import <Folklore/Folklore.h>
.
- (void)didTapConnectButton:(id)sender {
_folklore = [[Folklore alloc] initWithServerRegion:LoLServerRegionNorthAmerica];
[_folklore setDelegate:self];
[_folklore connectWithUsername:@"jdoe"
password:@"secret123"];
}
#pragma mark - FolkloreDelegate Protocol
- (void)folkloreDidConnect:(Folklore *)folklore {
NSLog(@"Connection successful");
}
- (void)folkloreConnection:(Folklore *)folklore didFailWithError:(NSError *)error {
NSLog(@"Connection failed with error: %@", error);
}
Folklore does not maintain a list of friends. It is obtained by this delegate method for the implementation to manage. By default every friend object in the list will be offline/unavailable until a friend update is received for each online friends, individually.
#pragma mark - FolkloreDelegate Protocol
- (void)folklore:(Folklore *)folklore didReceiveFriends:(NSArray *)friends {
for (FolkloreFriend *friend in friends) {
NSLog(@"\t%@", friend.name);
}
}
#pragma mark - FolkloreDelegate Protocol
- (void)folklore:(Folklore *)folklore didReceiveFriendUpdate:(FolkloreFriend *)friend {
NSLog(@"%@", friend);
}
// `_friends` is a NSArray of FolkloreFriend objects, obtained during a friend list update.
[_folklore sendMessage:@"Welcome to Summoner's Rift!" toFriend:_friends[index]];
#pragma mark - FolkloreDelegate Protocol
- (void)folklore:(Folklore *)folklore didReceiveMessage:(NSString *)message fromfriend:(FolkloreFriend *)friend {
NSLog(@"[%@] %@", friend.name, message);
}
Folklore is available under the MIT license. See the LICENSE file for more info.
League of Legends content and materials are trademarks and copyrights of Riot Games or its licensors. All rights reserved.