Skip to content

Commit

Permalink
Merge pull request #24 from openforge/fix/user-score-zero-error
Browse files Browse the repository at this point in the history
fix/user-score-zero-error
  • Loading branch information
Ricardo385 authored Nov 22, 2023
2 parents d5a4942 + 0890d44 commit a55a64a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
Binary file not shown.
28 changes: 18 additions & 10 deletions ios/Plugin/CapacitorGameConnect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,26 @@ import Capacitor
leaderboard.timeScope = .allTime // * Time to search for

leaderboard.loadScores { (scores, error) in
if let error = error {
call.reject("Error loading leaderboard score: \(error.localizedDescription)")
} else if let scores = scores {
for score in scores {
if score.player.gamePlayerID == GKLocalPlayer.local.gamePlayerID {
let result = [
"player_score": score.value
]
call.resolve(result)
break
let hasScore = scores ?? nil
if hasScore != nil {
if let error = error {
call.reject("Error loading leaderboard score: \(error.localizedDescription)")
} else if let scores = scores {
for score in scores {
if score.player.gamePlayerID == GKLocalPlayer.local.gamePlayerID {
let result = [
"player_score": score.value
]
call.resolve(result)
break
}
}
}
} else {
let result = [
"player_score": 0
]
call.resolve(result as PluginCallResultData)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions ios/Plugin/CapacitorGameConnectPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ public class CapacitorGameConnectPlugin: CAPPlugin {

@objc func getUserTotalScore(_ call: CAPPluginCall) {
implementation.getUserTotalScore(call)
call.resolve()
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openforge/capacitor-game-connect",
"version": "5.0.0",
"version": "5.0.1",
"description": "Use Game Services and Game Connect",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down

0 comments on commit a55a64a

Please sign in to comment.