SDKBoxPlay isSignedIn not Working Cocos Creator

I am trying to add SDKBoxPlay to my Cocos Creator app and it’s not working properly. I only checked iOS and have yet to try Android. sdkbox.PluginSdkboxPlay.isSignedIn() is returning false every time you switch scenes even after signing in again.

On app launch, I do sdkbox.PluginSdkboxPlay.init(); and then sdkbox.PluginSdkboxPlay.signin(); after sigining in sdkbox.PluginSdkboxPlay.isSignedIn() returns true. I then move to another scene, I am signed in and sdkbox.PluginSdkboxPlay.isSignedIn() returns false. I then try to sign in again and sdkbox.PluginSdkboxPlay.isSignedIn() continues to return false. If I hit the home button and launch the app again, then sdkbox.PluginSdkboxPlay.isSignedIn() works.

I can’t submit scores and launch leaderboards etc without knowing if the user is signed in. I tried to submit a score without checking if the user is signed in and an error is thrown by Apple.

This isSignedIn problem was also mentioned in the thread below back in 2016:

I would fix this myself if I could but can’t find a hack like I did for other SDKbox plugins. I already tried finding a way for the past few hours. sdkbox.PluginSdkboxPlay.isSignedIn() is one of the most important and valuable functions inside the SDKBoxPlay plugin.

I thought about registering a global bool on application launch of the initial sign in but I don’t think this is a proper way of doing things when the plugin has a function to check if the user is signed in.

This is the error I get when I try to submit a score etc without knowing the player is signed in:

[Error] asking for GKLocalPlayer playerID when player is not authenticated

Also each time I launch the leaderboard or achievements I get the error below:

Presenting view controllers on detached view controllers is discouraged

I don’t know if the above is a big problem but things should be done according to guidelines

sdkbox::PluginSdkboxPlay::isSignedIn() should work but since I don’t want to wait for this to be fixed or a reply, I will try to use the onConnectionStatusChanged method to edit a global bool which will help me know if the user is signed in.

you can use:

if (! sdkbox::PluginSdkboxPlay::isSignedIn()) {
    sdkbox.PluginSdkboxPlay.signin();
}

As mentioned in my post, it doesn’t work. That is what I tried to do. It works on app launch but when you change scenes and run the code:

     if (!sdkbox.PluginSdkboxPlay.isSignedIn()) {

                    sdkbox.PluginSdkboxPlay.signin();

   }

sdkbox.PluginSdkboxPlay.isSignedIn() still returns false. It only works after hitting the home button and relaunching the app. It seems sdkbox.PluginSdkboxPlay.isSignedIn() gets reset after changing scenes and is as useful as onConnectionStatusChanged. It seems to inherit information from onConnectionStatusChanged or something like that…

My only option seems to be using my own logic in onConnectionStatusChanged. Hopefully sdkbox.PluginSdkboxPlay.isSignedIn() works properly in Android because Android might have stuff going wrong as well so it will be difficult for me to test all scenarios in both Android and Apple.

OK, I 'll make a c++ test example.

Ok. I started implementing my own logic and it seems ok so far. I will report back on whether Android works properly.

Ok, I checked Android and it seems that sdkbox.PluginSdkboxPlay.isSignedIn() is working on Android. I have other issues with Android but that might be due to my negligence so I will have to spend more time with Android to diagnose the issues. I will test some more and try to solve all the issues.

For Apple, I just started using onConnectionStatusChanged and global bools to solve the sdkbox.PluginSdkboxPlay.isSignedIn() issue.

Note: people using Google Play App Signing should be made aware that you cannot test SDKBoxPlay without downloading the app from the play store due to the keystore SHA1 being changed by Google. You will get UNREGISTERED_ON_API_CONSOLE. This is 1 issue I ran into. I don’t like uploading & downloading from Google Play to test because it’s time consuming… IAP I am able to test without these hassles.

Ok… So I solved this problem and figured out solutions to my other Sdkbox Play issues. Any people having problems with sdkbox.PluginSdkboxPlay.isSignedIn() should be made aware that you can only call sdkbox.PluginSdkboxPlay.init() once. When you change scenes or reload the current scene, you should avoid calling sdkbox.PluginSdkboxPlay.init() again.

If you need a listener which differs for each scene, you should call sdkbox.PluginSdkboxPlay.removeListener() to remove the old one and then create the new listener.

This is odd because other sdkbox plugins don’t work this way. For example the Cocos Creator Admob tutorial (http://docs.sdkbox.com/en/qa/cocos_creator/) instructs you to call init onload. No where is it mentioned that Sdkbox plugins can hold static references to plugins after a scene is destroyed.

In general, Sdkbox needs better examples and documentation. The Github example is ok but isn’t very good because it doesn’t cover scene changes etc. So it is not a good real world example.

1 Like

would you want to help improving the doc ?