Skip to content

endemic/cordova-gamecenter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cordova Game Center Plugin

Installation Instructions (Currently Unfinished)

  1. Copy GameCenterPlugin.h and GameCenterPlugin.m to your project's Plugins directory.
  2. Copy gamecenter.js to your project's www directory.
  3. Edit your project's config.xml file:
  4. Add <plugin name="GameCenterPlugin" value="GameCenterPlugin" /> to the <plugins> node. 2. if your access origin tag is not set to *, add *.apple.com to the origin string.
  5. Include a reference to gamecenter.js in your index file (e.g. <script src="js/gamecenter.js"></script>).
  6. Set up GameCenter for your app in iTunes Connect. more in the apple docs

in cordova iOS projects before 2.3.0:
3. Edit your project's Cordova.plist file: 1. Add *.apple.com to the ExternalHosts array. 2. Add GameCenterPlugin to the Plugins dictionary (for both key and value).

Documentation

GameCenter.authenticatePlayer(success, error)
Displays the Game Center login UI, or automatically log the player in if they've previously authenticated. The success callback is passed an object which looks like the following: { authenticated: true, playerID: XXXXX, alias: "Public display name" }. The error callback is passed a string which gives details about the error.

GameCenter.reportScore(score, category, success, error)
Send a score to a Game Center leaderboard, represented by the category string. category must be the identifier that you set up for the leaderboard in iTunes Connect. The error callback is passed a string which gives details about the error. The plugin doesn't save/resend scores if there was a transmission failure; it's up to you to keep track of which scores were successfully sent. A common technique for this is to save your scores in an array, iterate/send each one, and splice the score out of the array if it was successfully sent.

GameCenter.showLeaderboard(category, time, success, error)
Display the "native" Game Center UI for the category leaderboard. category must be the identifier that you set up for the leaderboard in iTunes Connect. time is a string representing the time interval of displayed scores. Acceptable values are "day," "week," or "all." The error callback is passed a string which gives details about the error.

GameCenter.retrieveScores(category, friends, time, range, success, error)
Get an array of high scores to use in your own custom UI. category must be the identifier that you set up for the leaderboard in iTunes Connect. friends is the string "global" or "friends" to show scores from friends only. time is a string representing the time interval of displayed scores. Acceptable values are "day," "week," or "all." range is the number of returned results, from 1 to 100 (the default is 25). success is passed the array of scores, while error is passed a string which gives details about the error.

GameCenter.loadAchievements(success, error)
Get the status of all achievements. success callback receives an array with objects representing each achievement. Note that you need to call this method before reporting any achievement progress.

GameCenter.reportAchievement(identifier, percent, success, error)
Update the completion percentage (percent) of a particular achievement with ID identifier.
more to come...

About

GameCenter plugin for Apache Cordova

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published