Cordova Galaxy plugin for Android and iOS.
Table of content
Installation
$ cordova plugin add cordova-plugin-galaxy
Setup
Add the following lines to your code to be able to initialize tracking with your own Galaxy Publishable key:
document.addEventListener('deviceready', function() {
// InitSDK
window.galaxy.InitSDK({
publishableKey: 'Your Galaxy Publishable Key',
}, (result) => {
console.log(result);
}, (error) => {
console.error(error);
});
/* Client API */
// ReportScore
document.getElementById('button').addEventListener(
'click',
(e) => window.galaxy.ClientAPI.ReportScore({
leaderboard_id: 'Your Leaderboard Id',
score: 1,
}, (result, error) => {
console.log(result);
}),
);
/* Galaxy UI */
// ShowLeaderboard
document.getElementById('button').addEventListener(
'click',
(e) => window.galaxy.ShowLeaderboard({
leaderboard_id: 'Your Leaderboard Id',
}, (result) => {
console.log(result);
}, (error) => {
console.error(error);
}),
);
// ShowAvatarEditor
document.getElementById('button').addEventListener(
'click',
(e) => window.galaxy.ShowAvatarEditor((result) => {
console.log(result);
}, (error) => {
console.error(error);
}),
);
// ShowClan
document.getElementById('button').addEventListener(
'click',
(e) => window.galaxy.ShowClan({
leaderboard_id: 'Your Leaderboard Id',
clan_id: 'clan id'
}, (result) => {
console.log(result);
}, (error) => {
console.error(error);
}),
);
}, false);