Leaderboard

Handles Leaderboard requests via IMS web services.

Opt in

To opt in or join a user into the leaderboard, the following API can be used.

Concrete Example

let service = LeaderboardService()
service.optIn(then: { result in
        switch result {
        case .success:
            // leaderboard opt in successful
            break
        case .failure:
            // error
        }
})

Opt out

To opt out or leave the leaderboard, the following API can be used.

Concrete Example

let service = LeaderboardService()
service.optOut(then: { result in
    switch result {
    case .success:
        // opts out successful
        break
    case .failure:
        // error
    }
})

Fetch

To fetch the leaderboard, the following API can be used.

Parameters:

  • dateComponents: The date (by component) to fetch the Leaderboard for. Leaderboards are fetched by month, so specifying the year and month in the components are necessary to receive the correct leaderboard. Defaults to fetching the current leaderboard.

let service = LeaderboardService()
service.fetch(dateComponents: DateComponents(year, month)) { result in
    switch result {
    case .success:
        // fetch succesful
        break
    default:
        // error
    }
})

Last updated