LeaderboardKit 0.0.5

LeaderboardKit 0.0.5

测试测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2015年12月

Anton Bukov 维护。



 
依赖关系
SAMCache>= 0
VK-ios-sdk= 1.2.2
 

  • 作者
  • Anton Bukov

在 Apple CloudKit 之上的 iOS 和 OSX 社交排行榜和最高分推送通知

安装

  1. pod 'LeaderboardKit'
  2. #import <LeaderboardKit/LeaderboardKit.h>
  3. 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.3x3scores.4x4scores.5x5

当 LeaderboardKit 准备就绪时集成 GameCenter

[[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];
    }];
}];

集成社交网络

  1. 当需要配置某些按钮状态时

    self.connectTwitterButton.enabled = NO;
    [[LeaderboardKit shared] whenInitialized:^{
        self.connectTwitterButton.enabled = ![[LeaderboardKit shared] accountForIdentifier:LKAccountIdentifierTwitter];
    }];
  2. 当玩家想要连接社交时(例如 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];
        }];
    }

贡献

  1. 创建分支
  2. 创建新的分支
  3. 将一些提交添加到你的分支中
  4. 创建 Pull Request
  5. 当 pull 请求合并后,删除分支