Giter Site home page Giter Site logo

cordova-google-play-game's Introduction

cordova-google-play-game

IMPORTANT NOTICE: This library is nolonger actively maintained as I'm not working with Cordova anymore. Better to find abother library that does the job better.

Cordova Plugin For Google Play Game Service

Live demo

See this plugin working in a live app:

WOW PUZZLES iOS

WOW PUZZLES Android

How it works: http://trinhtrunganh.com/cordova-plugin-for-google-play-game-service/

Before you start

Understand about Leaderboard and Achievement. Setting up your game in Google Play Developer Console https://developers.google.com/games/services/android/quickstart

Install

cordova plugin add https://github.com/ptgamr/cordova-google-play-game.git --variable APP_ID=you_app_id_here

Usage

Authentication

Sign in

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

googleplaygame.auth();

Sign out

You should provde the option for users to sign out

googleplaygame.signout();

Auth status

To check if the user is already logged in (eg. to determine weather to show the Log In or Log Out button), use the following

googleplaygame.isSignedIn(function (result) {
	// ‘result’ is a JSON object with a single boolean property of ‘isSignedIn’
	// {
	// 		“isSignedIn” : true
	// }
	
	console.log(“Do something with result.isSignedIn”);
});

Player Information

Fetch the currently authenticated player's data.

googleplaygame.showPlayer(function (playerData) {
	...
	console.log(“Authenticated as ”+playerData['displayName']);
});

Leaderboards

Submit Score

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

var data = {
    score: 10,
    leaderboardId: "board1"
};
googleplaygame.submitScore(data);

Show all leaderboards

Launches the native Play Games leaderboard view controller to show all the leaderboards.

googleplaygame.showAllLeaderboards();

Show specific leaderboard

Launches directly into the specified leaderboard:

var data = {
	leaderboardId: "board1"
};
googleplaygame.showLeaderboard(leaderboardId);

Achievements

Unlock achievement

Unlocks the specified achievement:

var data = {
	achievementId: "achievementId1"
};

googleplaygame.unlockAchievement(data);

Increment achievement

Increments the specified incremental achievement by the provided numSteps:

var data = {	
	achievementId: "achievementId1",
	numSteps: 1
};

googleplaygame.incrementAchievement(data);

Show achievements

Launches the native Play Games achievements view controller to show the user’s achievements.

googleplaygame.showAchievements();

Other

Success/Failure callbacks

For all methods, you can optionally provide custom success/failure callbacks.

For example:

var successfullyLoggedIn = function () { ... };
var failedToLogin = function () { ... };
googleplaygame.auth(successfullyLoggedIn, failedToLogin);

var data = { ... };
var successfullySubmittedScore  = function () { ... };
var failedToSubmitScore  = function () { ... };
googleplaygame.submitScore(data, successfullySubmittedScore, failedToSubmitScore);

Platform

Currently, only Android is supported

Donation:

Wish you dont mind buying me a cup of coffee (highfive)

Donate

License

MIT License

cordova-google-play-game's People

Contributors

agamemnus avatar ptgamr avatar pyko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cordova-google-play-game's Issues

isSignedIn() always returns true after user is signedOut via default dialog

Hi, everyone.

I implemented this plugin in my app and reached the following scenario:

  • Call googleplaygame.isSignedIn() --> result is false
  • Call googleplaygame.auth() --> OK, UI messages are shown indicating that user has been signed in.
  • Call googleplaygame.showAllLeaderboards() --> OK, "Leaderboards" diaglog is shown.
  • In "Leaderboards" dialog, go to "Settings" menu and choose option to sign out.
  • Call googleplaygame.isSignedIn() --> result is true (but must be false)

It seems that the return of isSignedIn() does not correctly reflect the real status.

After that, subsequent calls to googleplaygame.showAllLeaderboards() break the app with the exception java.lang.SecurityException: Not signed in when calling API instead of just calling the error callback provided.

Thanks,

App crushes when calling googleplaygame.auth();

Good day all

I'm trying to implement google game play serves to my simple game but my app crushes when I call googleplaygame.auth();. Please help

*ps I'm calling it after onDeviceReady and I've an app id

auth() is not doing anything!!

when i call auth() on deviceready, nothing happens.... no success or failure callback fires.... what can be the solution??

Conflict with adMob plug-in

Since both are using the google-play-services lib. To solve, get rid of the google-play-services-admob.jar as ads will show fine without it after installing this plug-in.

error when compiling with admob plugin

after compilation i get following error : Error: more than one library with package name 'com.google.android.gms', because i have cordova-plugin-admobpro 2.8.3 also installed.
How can i solve this?

regards,
David

Misprints in README.md (showLeaderboard and signout)

There are 2 misprints in the README.md:

1. Sign Out
googleplaygame.signout(); should be googleplaygame.signOut();
2. Show Leaderboards
var data = { leaderboardId: "board1" }; googleplaygame.showLeaderboard(leaderboardId);

should be

var data = { leaderboardId: "board1" }; googleplaygame.showLeaderboard(data);

#14

Misprint in readme:showLeaderboard

In readme, section "Show specific leaderboard" theres a misprint:

Should be:

var data = {
    leaderboardId: "board1"
};
googleplaygame.showLeaderboard(data);

(says googleplaygame.showLeaderboard(leaderboardId);)

Cannot login again if canceling first time

I get the following message in console: 01-18 22:48:08.301: W/GameHelper(26899): !!! GameHelper WARNING: beginUserInitiatedSignIn() called when already connecting. Be patient! You can only call this method after you get an onSignInSucceeded() or onSignInFailed() callback. Suggestion: disable the sign-in button on startup and also when it's clicked, and re-enable when you get the callback.

This happens when canceling the login window called from googleplaygame.auth(GPsuccess, GPfail); and trying to login again. Any suggestion?

UNEXPECTED TOP-LEVEL EXCEPTION

Hey,
the only plugin i want to use now is your 'cordova-google-play-game' plugin,
but when i'm trying to do 'ionic run android' my build fails with this error:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)

How can i solve it?

plugin hangs after repetition of login-logout

i have an app with this plugin. Everythings works fine, thanx except some special cases :

  • when i do following actions, the interface towards google play services hangs
    • auth, signOut, auth, signOut, auth -> hangs
    • auth, showAchievements, signOut, auth -> hangs
    • auth, showHighscores, signOut, auth -> hangs

With 'hangs' i mean that the function Success or function Fail is not called! My app is still working, exept no reaction when calling google play services.

Since i'm not an expert, i cannot find the reason. Do i miss something here. Anyone an idea?

regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.