GameCenterManager icon indicating copy to clipboard operation
GameCenterManager copied to clipboard

Request GKScore

Open YanSte opened this issue 10 years ago • 3 comments

Hi i create this function for request GKScore can you implement that ? it is swift if you want convert it tell me .

func requestLeaderboard(#leaderboardIdentifier:String,completion: ((result:GKScore?) -> Void)) {
    if GameCenterManager.sharedManager().isGameCenterAvailable {
        let leaderBoardRequest = GKLeaderboard()
        leaderBoardRequest.identifier = leaderboardIdentifier
        leaderBoardRequest.loadScoresWithCompletionHandler { (scores, error) ->
            Void in
            if error != nil {
                println("Error: \(error!.localizedDescription)")
                completion(result: nil)
            } else if (scores != nil) {
                completion(result: leaderBoardRequest.localPlayerScore)
            }
        }
    }
}

YanSte avatar Mar 18 '15 19:03 YanSte

it is with callback

YanSte avatar Mar 18 '15 19:03 YanSte

I have again that /** Show banner game center

:param: title       title
:param: description description
:param: completion  if show message is showing
*/
class func showBannerWithTitle(#title:String, description:String,completion: ((isShow:Bool) -> Void)?) {
    GKNotificationBanner.showBannerWithTitle(title, message: description, completionHandler: { () -> Void in
        if completion != nil { completion!(isShow:true) }
    })
}

YanSte avatar Mar 18 '15 20:03 YanSte

in - (void)syncGameCenter you have
GKLeaderboard *leaderboardRequest = [[GKLeaderboard alloc] initWithPlayerIDs:[NSArray arrayWithObject:[self localPlayerId]]];

it is deprecated

For Ios8 you have that GKLeaderboard *leaderboardRequest = [[GKLeaderboard alloc] initWithPlayers:[NSArray arrayWithObject:[self localPlayerId]]];

YanSte avatar Mar 18 '15 20:03 YanSte