forked from phyx3r/Game-Center-Phonegap-Plugin
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGameCenterPlugin.js
46 lines (37 loc) · 1.18 KB
/
GameCenterPlugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
(function(window) {
var GameCenter = function() {
if(!localStorage.getItem('GameCenterLoggedin')) {
cordova.exec("GameCenterPlugin.authenticateLocalPlayer");
}
};
GameCenter.prototype = {
authenticate: function() {
cordova.exec("GameCenterPlugin.authenticateLocalPlayer");
},
showLeaderboard: function(category) {
cordova.exec("GameCenterPlugin.showLeaderboard", category);
},
reportScore: function(category, score) {
cordova.exec("GameCenterPlugin.reportScore", category, score);
},
showAchievements: function() {
cordova.exec("GameCenterPlugin.showAchievements");
},
getAchievement: function(category) {
cordova.exec("GameCenterPlugin.reportAchievementIdentifier", category, 100);
},
};
GameCenter._userDidLogin = function() {
localStorage.setItem('GameCenterLoggedin', 'true');
};
GameCenter._userDidSubmitScore = function() {
alert('score submitted');
};
GameCenter._userDidFailSubmitScore = function() {
alert('score error');
};
cordova.addConstructor(function() {
if(!window.plugins) window.plugins = {};
window.plugins.gamecenter = new GameCenter();
});
})(window);