getMyScore not working on iOS

Hi!

The following code works fine on android but not working on iOS:

void onConnectionStatusChanged(int status) {
        log("onConnectionStatusChanged(%i)", status);
        
        if (status == sdkbox::GPS_CONNECTED) {
            sdkbox::PluginSdkboxPlay::getMyScore(kLeaderboardName, 2, 2);
            log("call getMyScore()");
        }
    }

    void
    onMyScore(const std::string &leaderboard_name, int time_span, int collection_type, long score) {
        log("onMyScore(%s, %i %i %i)", leaderboard_name.c_str(), time_span, collection_type, score);
    }
    
    void onMyScoreError ( const std::string & leaderboard_name ,
                         int time_span ,
                         int collection_type ,
                         int error_code ,
                         const std::string & error_description ) {
        log("onMyScoreError(%s)", error_description.c_str());
    }

Console output:
onConnectionStatusChanged(1000)
call getMyScore()

and nothing, no error and no score.

Using performFunctionInCocosThread somehow fixes the issue:

    void onConnectionStatusChanged(int status) {
        if (status == sdkbox::GPS_CONNECTED) {
            cocos2d::Director::getInstance()->getScheduler()->performFunctionInCocosThread([=](){
                sdkbox::PluginSdkboxPlay::getMyScore(kLeaderboardName, 2, 2);
            });
        }
    }
1 Like

Thanks for your solution.