0.4.40 • Published 6 months ago

cordova-plugin-game-center-remove-playerid v0.4.40

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Game Center Plugin for Apache Cordova

⚠️ Please note this is a work in progress and may not work as intended

This plugin allows developers to utilise the iOS Game Center in their Cordova app.

Before you start

Adding Game Center support requires more than simple coding changes. To create a Game Center-aware game, you need to understand these basics before you begin writing code. The full outline of all the Game Center concepts and impacts can be viewed here.

Install

Latest published version on npm (with Cordova CLI >= 6.0.0)

cordova plugin add cordova-plugin-game-center-remove-playerid

Latest version from GitHub

cordova plugin add https://github.com/BrianLeonSmith/cordova-plugin-game-center-remove-playerid.git

You do not need to reference any JavaScript, the Cordova plugin architecture will add a GameCenter object to your root automatically when you build. It will also automatically add the GameKit framework dependency.

Usage

Authentication

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

var successCallback = (success) => {
    alert("Success: " + JSON.stringify(success));
};

var failureCallback = (err) => {
    alert("Error: " + err);
};

GameCenter.auth(successCallback, failureCallback);

Fetch Player Image

Loads the current player's photo. Automatically cached on first retrieval.

var successCallback = (path) => {
    alert("Success: " + path);
};

GameCenter.getPlayerImage(successCallback, failureCallback);

Submit Score

Ensure you have had a successful callback from GameCenter.auth() first before attempting to submit a score. You should also have set up your leaderboard(s) in iTunes connect and use the leaderboard identifier assigned there as the leaderboardId.

var data = {
    score: 10,
    leaderboardId: "board1"
};

GameCenter.submitScore(successCallback, failureCallback, data);

Show leaderboard

Launches the native Game Center leaderboard view controller for a leaderboard.

var data = {
    leaderboardId: "board1"
};

GameCenter.showLeaderboard(successCallback, failureCallback, data);

Report achievement

Reports an achievement to the game center:

var data = {
	achievementId: "MyAchievementName",
	percent: "100"
};

GameCenter.reportAchievement(successCallback, failureCallback, data);

Reset achievements

Resets the user's achievements and leaderboard.

GameCenter.resetAchievements(successCallback, failureCallback);

Fetch achievements

Fetches the user's achievements from the game center:

var successCallback = (results) => {
	if (results) {
    	for (var i = 0; i < results.length; i += 1) {
            results[i].identifier
            results[i].percentComplete
            results[i].completed
            results[i].lastReportedDate
            results[i].showsCompletionBanner
        }
    }
}

GameCenter.getAchievements(successCallback, failureCallback);

Platforms

  • ios
0.4.40

6 months ago

0.4.20

6 months ago

0.4.21

6 months ago

0.4.28

6 months ago

0.4.29

6 months ago

0.4.26

6 months ago

0.4.27

6 months ago

0.4.24

6 months ago

0.4.25

6 months ago

0.4.22

6 months ago

0.4.23

6 months ago

0.4.19

6 months ago

0.4.31

6 months ago

0.4.32

6 months ago

0.4.30

6 months ago

0.4.39

6 months ago

0.4.17

6 months ago

0.4.18

6 months ago

0.4.37

6 months ago

0.4.15

6 months ago

0.4.38

6 months ago

0.4.16

6 months ago

0.4.35

6 months ago

0.4.13

6 months ago

0.4.36

6 months ago

0.4.14

6 months ago

0.4.33

6 months ago

0.4.11

6 months ago

0.4.34

6 months ago

0.4.12

6 months ago

0.4.10

6 months ago

0.4.9

6 months ago

0.4.8

6 months ago

0.4.5

6 months ago

0.4.4

6 months ago

0.4.7

6 months ago

0.4.6

6 months ago

0.4.3

6 months ago

0.4.2

6 months ago