Last Updated: February 25, 2016
·
2.363K
· leecrossley

Game Center with PhoneGap in 4 Steps

I've made it incredibly easy to use the iOS Game Center in a PhoneGap / Cordova app:

1. Install the plugin

$ cordova plugin add https://github.com/leecrossley/cordova-plugin-game-center.git

2. Authenticate the user

gamecenter.auth(onSuccess, onError);

3. Submit a score

gamecenter.submitScore(onSuccess, onError, { 
    score: 100, 
    leaderboardId: "YOUR_ID"
});

4. Show the leaderboard

gamecenter.showLeaderboard(onSuccess, onError, { 
    period: "today",
    leaderboardId: "YOUR_ID"
});

Plugin is open source and on GitHub. More details available on the full blog post.

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside