LeaderboardKit
iOS and OSX social leaderboards and highscore push notifications on top of Apple CloudKit
Install / Use
/learn @k06a/LeaderboardKitREADME
LeaderboardKit
iOS and OSX social leaderboards and highscore push notifications on top of Apple CloudKit
Installation
-
pod 'LeaderboardKit' -
#import <LeaderboardKit/LeaderboardKit.h> -
Setup leaderboards inside
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"]];for leaderboard identifiers:
scores.3x3,scores.4x4andscores.5x5
Integrate GameCenter when LeaderboardKit become ready
[[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];
}];
}];
Integrate social networks
- When need to configure some button state:
self.connectTwitterButton.enabled = NO;
[[LeaderboardKit shared] whenInitialized:^{
self.connectTwitterButton.enabled = ![[LeaderboardKit shared] accountForIdentifier:LKAccountIdentifierTwitter];
}];
- Connect ane social when player wants (Twitter, for example):
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];
}];
}
Contribute
- Create fork
- Create new branch
- Add some commits to your branch
- Create Pull Request
- When pull request merged, delete brach
Related Skills
node-connect
344.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
99.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
344.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
344.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
