ID.login doesn't call the callback function

Hi,

We are trying to implement the Y8 login system in our game. We are following the code in the page “JavaScript Basics” (I can’t post the link) but as soon as we reach ID.login(loginCallback); the callback function is never executed. Intead we get the following warning in the console

The key “target-densitydpi” is not supported.

Any clue about what is going on? This is the full code:

 window.idAsyncInit = function() {
    	  ID.Event.subscribe('id.init', function(){
    		  ID.login(loginCallback);
    	  });
    	  var loginCallback = function(response){
      	      console.log('loginCallback:'+ response);
	      	    if (response) { // That means that the server processed the response
	      	      console.log(response.authResponse.details);
	      	      //var obj = response.authResponse.details;
	      	      //obj.network = 'y8';
	      	      //this.loggedIn(response.authResponse.details);
	      	    }
	      	  }
    	  // init the JS interface
    	  ID.init({
    	        appId: 'APP_ID'//Hiden here but correct in the code 
    	  });
	  };

We have tried another way to do it using ID.getLoginStatus(loginCallback, true) instead of ID.login and we get the following response:

{authResponse: null, success: false, status: “not_linked”}

But we don’t know if it’s usefull or not, neither how to get a correct response.

Thanks in advance for any help on this.

Regards

Hi,

Try this

window.idAsyncInit = function() {
  ID.Event.subscribe('id.init', function(){
    if (data.status == 'not_linked') {
      ID.login(loginCallback);
    }
  });
}

You want everything inside the first 2 callbacks. They say when the SDK is downloaded and when it has been initialized.

The above means the user is logged in but has not shared privileges. So we call login to display the privileges menu as needed.

This should work, it was taken from the example on that first page for the JS SDK.

Cheers

Hi. Thanks for the response.

Unfortunately it didn’t work. The variable “data” is not defined, even if I add it as parameter inside the function, like this:

window.idAsyncInit = function() {
  ID.Event.subscribe('id.init', function(data){
    if (data.status == 'not_linked') {
      ID.login(loginCallback);
    }
  });
}

We are using this URL to test it https://storage-direct.y8.com/adventurebox/html5/local/index.html.

Cheers.

Oh, I forgot a line

window.idAsyncInit = function() {
  ID.Event.subscribe('id.init', function(){
    ID.getLoginStatus(function(data) {
      if (data.status == 'not_linked') {
        ID.login(loginCallback);
      }
    });
  });
}

I will update the documentation, these areas could be improved.

1 Like

Sorry for the late response. Unfortunately we tried that and we still have the same problem. The loginCallback is never executed and we get a warning message in the log:

The key “target-densitydpi” is not supported.
11:27:34.789 authorize?_sdk=id-169b95ad201b4&client_id=5b7d716ae694aa55a15895b8&prefill[widgets]=1&redirect_uri=https%3A%2F%2Flocalservice.adventurebox.com%2Fplay%3Fgame%3D3596a18b-3eb0-9b8f-3838-8d8179939021%26utm_source%3Dy8%26utm_medium%3DDistributor&response_type=token&scope=:75

There was one thing missing in the docs while I was testing that code. It’s required to test from an actual domain. Local files and ip addresses don’t work. If you need a place, the storage.y8.com would work or upload.y8.com

Hi,
We finally found the problem. It was related to the way requirejs deal with the function loginCallback.
We have been testing here:
https://storage-direct.y8.com/adventurebox/html5/dev/index.html
Thanks for the help

1 Like
Y8 Games