测试测试 | ✗ |
语言语言 | Obj-CObjective C |
许可证 | MIT |
发布最后发布 | 2015年12月 |
由 Anton Bukov 维护。
依赖关系 | |
SAMCache | >= 0 |
VK-ios-sdk | = 1.2.2 |
在 Apple CloudKit 之上的 iOS 和 OSX 社交排行榜和最高分推送通知
pod 'LeaderboardKit'
#import <LeaderboardKit/LeaderboardKit.h>
在 application:didFinishLaunchingWithOptions:
中设置排行榜
LKGameCenterIdentifierToNameTranform = ^NSString *(NSString *identifier){
return [identifier substringFromIndex:@"scores.".length];
};
LKGameCenterNameToIdentifierTranform = ^NSString *(NSString *name){
return [@"scores." stringByAppendingString:name];
};
[[LeaderboardKit shared] setupLeaderboardNames:@[@"3x3",@"4x4",@"5x5"]];
标识符: scores.3x3
、scores.4x4
和 scores.5x5
[[LeaderboardKit shared] whenInitialized:^{
id<LKAccount> account = [[LeaderboardKit shared] accountWithClass:[LKGameCenter class]];
if (!account) {
account = [[LKGameCenter alloc] init];
[[LeaderboardKit shared] addAccount:account];
}
[account requestAuthWithViewController:self success:^{
[[[UIAlertView alloc] initWithTitle:@"Success" message:@"GameCenter account connected" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
} failure:^(NSError *error) {
[[[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
}];
}];
当需要配置某些按钮状态时
self.connectTwitterButton.enabled = NO;
[[LeaderboardKit shared] whenInitialized:^{
self.connectTwitterButton.enabled = ![[LeaderboardKit shared] accountForIdentifier:LKAccountIdentifierTwitter];
}];
当玩家想要连接社交时(例如 Twitter)
if ([LeaderboardKit shared].isInitialized && ![[LeaderboardKit shared] accountForIdentifier:LKAccountIdentifierTwitter])
{
id<LKAccount> account = [[LKTwitterAccount alloc] initWithUserRecord:[LeaderboardKit shared].userRecord];
[account requestAuthWithViewController:self success:^{
[[LeaderboardKit shared] setAccount:account forIdentifier:LKAccountIdentifierTwitter];
[[[UIAlertView alloc] initWithTitle:@"Success" message:@"Twitter account connected" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
} failure:^(NSError *error) {
[[[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
}];
}