Skip to content

Commit

Permalink
Fix plugin Game Center and Google Play Games plugin conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro committed Oct 21, 2015
1 parent d44703e commit 0f581e5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/inapps/cocoon-inapps/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ cr.plugins_.ATPInApps = function(runtime) {

if (!(this.runtime.isAndroid || this.runtime.isiOS))
return;
if (typeof Cocoon == 'undefined')
if (!window.Cocoon)
return;

this.storeService = Cocoon.InApp;
Expand Down
3 changes: 3 additions & 0 deletions src/share/cocoon-share/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ cr.plugins_.ATPShare = function(runtime) {

// banner actions
Acts.prototype.Share = function(text, img) {
if (!window.Cocoon || !window.Cocoon.Share) {
return;
}
Cocoon.Share.share({
message: text,
image: img
Expand Down
11 changes: 5 additions & 6 deletions src/social/cocoon-gc/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ cr.plugins_.ATPGameCenter = function(runtime) {

instanceProto.onCreate = function() {

if (!(this.runtime.isAndroid || this.runtime.isiOS))
if (!this.runtime.isiOS)
return;
if (typeof Cocoon == 'undefined')
return;
Expand All @@ -42,12 +42,11 @@ cr.plugins_.ATPGameCenter = function(runtime) {
self = this;

this.startGameCenter = function() {
this.GC = Cocoon.Social.GameCenter;
this.GC = window.Cocoon && window.Cocoon.Social ? Cocoon.Social.GameCenter : null;
if (this.GC) {
var config = {};
if (!!this.GC.nativeAvailable) {
this.GCInterface = this.GC.getSocialInterface();
}
this.GCInterface = this.GC.getSocialInterface();

} else {
throw new Error("Cannot find Game Center service, are you using the latest ATP for Game Center?");
}
Expand All @@ -63,7 +62,7 @@ cr.plugins_.ATPGameCenter = function(runtime) {
* Conditions
*/
Cnds.prototype.isLoggedIn = function() {
return this.GCInterface.isLoggedIn();
return this.GCInterface ? this.GCInterface.isLoggedIn() : false;
};
Cnds.prototype.onGCLoginSuccess = function() {
return true;
Expand Down
10 changes: 4 additions & 6 deletions src/social/cocoon-gpg/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ cr.plugins_.ATPGooglePlayGames = function(runtime) {

instanceProto.onCreate = function() {

if (!(this.runtime.isAndroid || this.runtime.isiOS))
if (!this.runtime.isAndroid)
return;
if (typeof Cocoon == 'undefined')
return;
Expand All @@ -47,14 +47,12 @@ cr.plugins_.ATPGooglePlayGames = function(runtime) {
self = this;

this.startGooglePlay = function() {
this.GPG = Cocoon.Social.GooglePlayGames;
this.GPG = window.Cocoon && window.Cocoon.Social ? Cocoon.Social.GooglePlayGames : null;
if (this.GPG) {
var config = {};
//if (this.GPGClientID) config.clientId = this.GPGClientID;
this.GPG.init(config);
if (!!this.GPG.nativeAvailable) {
this.GPGInterface = this.GPG.getSocialInterface();
}
this.GPGInterface = this.GPG.getSocialInterface();
} else {
throw new Error("Cannot find Google Play Games service, are you using the latest ATP for Google Play Games?");
}
Expand All @@ -70,7 +68,7 @@ cr.plugins_.ATPGooglePlayGames = function(runtime) {
* Conditions
*/
Cnds.prototype.isLoggedIn = function() {
return this.GPGInterface.isLoggedIn();
return this.GPGInterface ? this.GPGInterface.isLoggedIn() : false;
};
Cnds.prototype.onGPGLoginSuccess = function() {
return true;
Expand Down

0 comments on commit 0f581e5

Please sign in to comment.