TechCrunch Disrupt SF 2013

in San Francisco, CA

Use Case Summary

We will build an iOS app which measures how many times you shake your iPhone device for 10 seconds. Your world ranking is calculated using SoTopless leaderboard server built on top of Nanolat Database.

Leaderboard is a useful tool for games and gamified apps providing rankings of users based on score of each user.

Nanolat Database can calculate ranking of a user within 20 micro seconds using order statistics tree. SoTopless server provides Thrift based client API that connects to Nanolat Database server.

These are open source projects :

The demo video is here :

Project Summary

We will use SoTopless leaderboard server, which already works with C++ client SDK. In this project, we will develop iOS shaking app by creating Objective C SDK and the app itself from the scratch. The Objective C SDK will communicate with SoTopless leaderboard server using Thrift.

Following will be developed from the scratch during the TechCrunch Disrupt SF 2013 Hackathon.

1) Objective C client SDK to the SoTopless leaderboard server.
2) An iOS app asking you to shake your iPhone. The number of shakes for 10 seconds will be measured, and you will see your ranking in your app.

Leaderboard API in Objective C

Specification of the leaderboard JavaScript C is as follows.
We will convert it to Objective C soon.

List of Features

Followings are list of leaderboard features to implement.

  • Post a new score of a user.
  • Get top N users with scores from a leaderboard.
  • Get rank and score of a user from a leaderboard.
  • Add different kinds of leaderboards such as weekly, monthly, asia, europe, etc.

User Management

To post scores of a user, or get scores and ranks of a user, you need to create the user on SoTopless server. You need to create the user only once, like you sign-up on a web site only once.
After the user is created, you can use the name of the user to post scores, to get scores and ranks of the user on a leaderboard.

Leaderboard Management

You can create multiple leaderboards, post scores of users based on different criteria. For example, you may want to create leaderboards based on users' countries such as USA, Canada, or Germany. Creating weekly, monthly, and daily leaderboards also requires you to create multiple leaderboards.

Leaderboard management APIs help you to create, get, drop, and purge leaderboards. After creating a leaderboard, you can get the handle of the created leaderboard. The handle will be used to purge, drop a leaderboard. Also it will be used to get scores and ranks of a user, or to get the top N users on a leaderboard.

In case you have monthly, weekly, or daily leaderboards, you can purge those leaderboards regularly to keep the rankings up-to-date.

Posting and Getting Scores

Whenever a user achieves a new high score, you post the user's score with the identity of the user and the name of the leaderboard. While you post the user's score, you can provide a string containing the situation of the user such as game items the user used to clear the stage.

You can get the ranking and score on the leaderboard where you posted the user's score. Also you can get a range of ranking on a leaderboard. For example, you can get the list of users and scores of the top 10 scoreboard by quering the rankings from 1st to 10th.

Also, you may want to remove a score posted by a user. Removing the score posted by a user is supported.

iOS SDK Example

    // Login

    NSString * uuid = [ NSString stringWithFormat:@"GET-UUID-DONT-USE-THIS"];

    NLLocalPlayer * localPlayer = [ NLLocalPlayer localPlayer:uuid playerAlias:@"Kangdori" password:uuid ];

    localPlayer.authenticateHandler = ^(NSError * error) {
        if (error != NULL) {
            NSLog( @"Error : while authenticating : %@", error.description );
        NSLog( @"Success : User authenticated.");

        // Report Score
        NLScore * myScore = [[NLScore alloc] initWithCategory:@"all"];
        myScore.value = 300; // score

        [myScore reportScoreWithCompletionHandler:^(NSError * error) {
            if (error != NULL) {
                NSLog( @"Error : while authenticating : %@", error.description );
            NSLog( @"Success : Score reported.");

            // List top 10 Scores
            NLLeaderboard * leaderboard = [[NLLeaderboard alloc] init];
            leaderboard.category = @"all";
            leaderboard.range = NSMakeRange(1,10); // 10 users from the 1st user.

            [leaderboard loadScoresWithCompletionHandler:^(NSArray* scores, NSError* error) {
                if (error != NULL) {
                    NSLog( @"Error : while loading scores : %@", error.description );
                NSLog( @"Success : Scores loaded.");

                NSLog( @"Listing scores." );

                for (NLScore * score in scores) {
                    NSString *dateString = [NSDateFormatter

                    NSLog( @"Rank: %d, Display Alias : %@, Score : %lld, Time : %@",
                          score.rank, score.playerAlias, score.value, dateString );



Demo Video

0 Favorites




We've joined the Mashery family. Read the announcement.