Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
Fixing bug related to unused class described in issue #2
Browse files Browse the repository at this point in the history
  • Loading branch information
artberri committed Aug 11, 2019
1 parent 4fa87ea commit 4b634dc
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 250 deletions.
20 changes: 0 additions & 20 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +0,0 @@
# Non-project-specific build files:
build.xml
local.properties
/gradlew
/gradlew.bat
/gradle
# Ant builds
ant-built
ant-gen
# Eclipse builds
gen
out
# Gradle builds
/build
# IntelliJ/Android Studio
.idea/*
*.iml
.log
.log.lck
.vscode
182 changes: 137 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,77 +27,135 @@ cordova plugin add https://github.com/artberri/cordova-plugin-play-games-service
### Authentication

#### Sign in

You should do this as soon as your `deviceready` event has been fired. The plugin handles the various auth scenarios for you.

```js
window.plugins.playGamesServices.auth();
cordova.plugins.playGamesServices.auth(function() {
// On logged in
}, function() {
// On not logged in
});
```

#### Sign out
You should provde the option for users to sign out

You should provide the option for users to sign out

```js
window.plugins.playGamesServices.signout();
cordova.plugins.playGamesServices.signOut(function() {
// On logged out
});
```

#### Auth status

To check if the user is already logged in (eg. to determine weather to show the Log In or Log Out button), use the following

```js
window.plugins.playGamesServices.isSignedIn(function (result) {
// ‘result’ is a JSON object with a single boolean property of ‘isSignedIn’
// {
// “isSignedIn” : true
// }

console.log(“Do something with result.isSignedIn”);
cordova.plugins.playGamesServices.isSignedIn(function (result) {
// ‘result’ is the following object
// {
// "isSignedIn": boolean
// }
console.log("Is user signed in: " + result.isSignedIn);
}, function() {
// On error: Auth check could not be done
});
```

#### Player Information

Fetch the currently authenticated player's data.

```js
window.plugins.playGamesServices.showPlayer(function (playerData) {
...
console.log(“Authenticated as ”+playerData['displayName']);
cordova.plugins.playGamesServices.showPlayer(function (playerData) {
// playerData is the following object
// {
// displayName: string;
// playerId: string;
// title: string;
// iconImageUrl: string;
// hiResIconImageUrl: string;
// }
console.log("Authenticated as " + playerData.displayName);
});
```

### Leaderboards

#### Submit Score

Ensure you have had a successful callback from `window.plugins.playGamesServices.auth()` first before attempting to submit a score. You should also have set up your leaderboard(s) in Google Play Game Console and use the leaderboard identifier assigned there as the `leaderboardId`.
Ensure you have had a successful callback from `cordova.plugins.playGamesServices.auth()` first before attempting to submit a score. You should also have set up your leaderboard(s) in Google Play Game Console and use the leaderboard identifier assigned there as the `leaderboardId`.

```js
var data = {
score: 10,
leaderboardId: "board1"
};
window.plugins.playGamesServices.submitScore(data);
cordova.plugins.playGamesServices.submitScore(data, function () {
// On success
}, function() {
// On error
});
```

#### Sumit Score Now

Ensure you have had a successful callback from `window.plugins.playGamesServices.auth()` first before attempting to submit a score. You should also have set up your leaderboard(s) in Google Play Game Console and use the leaderboard identifier assigned there as the `leaderboardId`.
Ensure you have had a successful callback from `cordova.plugins.playGamesServices.auth()` first before attempting to submit a score. You should also have set up your leaderboard(s) in Google Play Game Console and use the leaderboard identifier assigned there as the `leaderboardId`.

This method submit the score immediately.
This method submit the score immediately and returns info.

```js
var data = {
score: 10,
leaderboardId: "board1"
};
window.plugins.playGamesServices.submitScoreNow(data);
cordova.plugins.playGamesServices.submitScoreNow(data, function (result) {
// ‘result’ is the following object
// {
// leaderboardId: string;
// playerId: string;
// formattedScore: string;
// newBest: boolean;
// rawScore: number;
// scoreTag: string;
// }
console.log("Is this your best score: " + result.newBest);
}, function() {
// On error
});
```

#### Get player's score

This method gets the score of a leaderboard.

```js
var data = {
leaderboardId: "board1"
};
cordova.plugins.playGamesServices.getPlayerScore(data, function (result) {
// ‘result’ is the following object
// {
// playerScore: number;
// }
console.log("Is this your score: " + result.playerScore);
}, function() {
// On error
});
```

#### Show all leaderboards

Launches the native Play Games leaderboard view controller to show all the leaderboards.

```js
window.plugins.playGamesServices.showAllLeaderboards();
cordova.plugins.playGamesServices.showAllLeaderboards(function () {
// On success
}, function() {
// On error
});
```

#### Show specific leaderboard
Expand All @@ -106,68 +164,102 @@ Launches directly into the specified leaderboard:

```js
var data = {
leaderboardId: "board1"
leaderboardId: "board1"
};
window.plugins.playGamesServices.showLeaderboard(leaderboardId);
cordova.plugins.playGamesServices.showLeaderboard(leaderboardId, function () {
// On success
}, function() {
// On error
});
```

### Achievements

#### Unlock achievement

Unlocks the specified achievement:

```js
var data = {
achievementId: "achievementId1"
achievementId: "achievementId1"
};

window.plugins.playGamesServices.unlockAchievement(data);
cordova.plugins.playGamesServices.unlockAchievement(data, function () {
// On success
}, function() {
// On error
});
```

#### Increment achievement
#### Unlock achievement Now

Increments the specified incremental achievement by the provided numSteps:
Unlocks the specified achievement inmediately and waits for response:

```js
var data = {
achievementId: "achievementId1",
numSteps: 1
achievementId: "achievementId1"
};

window.plugins.playGamesServices.incrementAchievement(data);
cordova.plugins.playGamesServices.unlockAchievementNow(data, function () {
// On success
}, function() {
// On error
});
```

#### Show achievements
#### Increment achievement

Launches the native Play Games achievements view controller to show the user’s achievements.
Increments the specified incremental achievement by the provided numSteps:

```js
window.plugins.playGamesServices.showAchievements();
var data = {
achievementId: "achievementId1",
numSteps: 1
};

cordova.plugins.playGamesServices.incrementAchievement(data, function () {
// On success
}, function() {
// On error
});
```

### Other
#### Increment achievement Now

#### Success/Failure callbacks
Increments the specified incremental achievement by the provided numSteps and waits for response

For all methods, you can optionally provide custom success/failure callbacks.
```js
var data = {
achievementId: "achievementId1",
numSteps: 1
};

For example:
cordova.plugins.playGamesServices.incrementAchievementNow(data, function () {
// On success
}, function() {
// On error
});
```

```js
var successfullyLoggedIn = function () { ... };
var failedToLogin = function () { ... };
window.plugins.playGamesServices.auth(successfullyLoggedIn, failedToLogin);
#### Show achievements

Launches the native Play Games achievements view controller to show the user’s achievements.

var data = { ... };
var successfullySubmittedScore = function () { ... };
var failedToSubmitScore = function () { ... };
window.plugins.playGamesServices.submitScore(data, successfullySubmittedScore, failedToSubmitScore);
```js
cordova.plugins.playGamesServices.showAchievements(function () {
// On success
}, function() {
// On error
});
```

## Platform
### Other

Callbacks are optional for all methods.

Currently, only Android is supported
## Platforms

Currently, only Android is supported

## License

Expand Down
20 changes: 20 additions & 0 deletions plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Non-project-specific build files:
build.xml
local.properties
/gradlew
/gradlew.bat
/gradle
# Ant builds
ant-built
ant-gen
# Eclipse builds
gen
out
# Gradle builds
/build
# IntelliJ/Android Studio
.idea/*
*.iml
.log
.log.lck
.vscode
5 changes: 5 additions & 0 deletions plugin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "cordova-plugin-play-games-services",
"version": "1.1.0",
"description": "Google Play Games Services Cordova Plugin for Android",
"scripts": {},
"cordova": {
"id": "cordova-plugin-play-games-services",
"platforms": [
Expand Down Expand Up @@ -33,4 +34,4 @@
"email": "alberto@berriart.com"
},
"license": "MIT"
}
}
4 changes: 2 additions & 2 deletions plugin/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</engines>

<js-module src="www/play-games-services.js" name="PlayGamesServices">
<clobbers target="cordova.plugins.playGamesServices" />
<clobbers target="window.plugins.playGamesServices" />
</js-module>

Expand Down Expand Up @@ -51,8 +52,7 @@

<source-file src="src/com/berriart/cordova/plugins/PlayGamesServices.java" target-dir="src/com/berriart/cordova/plugins/" />
<source-file src="src/com/berriart/cordova/plugins/BaseGameUtils.java" target-dir="src/com/berriart/cordova/plugins/" />
<source-file src="src/com/berriart/cordova/plugins/BaseGameActivity.java" target-dir="src/com/berriart/cordova/plugins/" />
<source-file src="src/com/berriart/cordova/plugins/GameHelper.java" target-dir="src/com/berriart/cordova/plugins/" />
<source-file src="src/com/berriart/cordova/plugins/GameHelperUtils.java" target-dir="src/com/berriart/cordova/plugins/" />
</platform>
</plugin>
</plugin>
Loading

0 comments on commit 4b634dc

Please sign in to comment.