swift - Scores are not registered on the leaderboard of GameCenter -
i've got such log when score report leaderboard.
<gkscore: 0xxxxxxxxxx>player:playerid:g:9999999999 alias:tester ajw rank:0 date:2017-03-28 08:31:26 +0000 value:1 formattedvalue:(null) context:0x0 leaderboard:testscore group:(null)
the value seems sent, formattedvalue , group null.
i've tried app on testflight, score never registered on leaderboard. shows "no scores".
appdelegate.swift
func application(_ application: uiapplication, didfinishlaunchingwithoptions launchoptions: [uiapplicationlaunchoptionskey: any]?) -> bool { // login check if let presentvc = window?.rootviewcontroller { let targetvc = presentvc let player = gklocalplayer.localplayer() player.authenticatehandler = {(viewcontroller, error) -> void in if ((viewcontroller) != nil) { print("login: faile") // login phase start targetvc.present(viewcontroller!, animated: true, completion: nil); } else { print("login: success") if (error == nil){ print("authentication: success") } else { print("authentication: faile") } } } } return true }
viewcontroller.swift
func reportscore(_ value: int, id: string) { if gklocalplayer.localplayer().isauthenticated { let score: gkscore = gkscore(leaderboardidentifier: id) score.value = int64(value) gkscore.report([score]){ (error) in if error != nil { print(error!.localizeddescription) } else { print("best score submitted leaderboard!") print("value:\(score.value)") print("\(score)") } } } } func showleaderboard(){ // leaderboard let localplayer = gklocalplayer() // default leaderboard id localplayer.loaddefaultleaderboardidentifier(completionhandler: { (leaderboardidentifer, error) in if error != nil { print(error any) } else { let gamecentercontroller:gkgamecenterviewcontroller = gkgamecenterviewcontroller() gamecentercontroller.gamecenterdelegate = self gamecentercontroller.viewstate = gkgamecenterviewcontrollerstate.leaderboards gamecentercontroller.leaderboardidentifier = self.leaderboardid self.present(gamecentercontroller, animated: true, completion: nil) } }) }
do find problems on it?
Comments
Post a Comment