Sdkbox is undefined in JavaScript

I’ve run sdkbox import iap and sdkbox import review, running them again produces the message “Installation already complete, no actions were taken”.

The program will compile and deploy to web and android. However, as soon as I try to use anything involving a call to sdkbox the program crashes and I get a message saying sdkbox is undefined.

For example: sdkbox.PluginReview.init();

I have a feeling I’m not including some javascript file that has the bindings somewhere but I’m unable to find it. Any help is appreciated.

Can you double check if these binding files are included in your project?
https://github.com/sdkbox/sdkbox-review-sample/tree/master/js/frameworks/runtime-src/Classes

This usually means binding functions are not correctly registered with spider monkey.
Please also follow this integration documentation to make sure the binding files are integrated correctly.
http://docs.sdkbox.com/en/plugins/review/v3-js/#usage

That directory exists and contains those files.

Also, I followed all the directions on that page prior to installing. However, I will note that I didn’t have to make any modifications as the changes it suggested were already in place.

I had assumed these changes must have been done automagically for me since I used sdkbox to install them.

Can you double check you have these change in your AppDelegate.cpp?

sc->addRegisterCallback(register_all_PluginIAPJS);
sc->addRegisterCallback(register_all_PluginIAPJS_helper);
sc->addRegisterCallback(register_all_PluginReviewJS);
sc->addRegisterCallback(register_all_PluginReviewJS_helper);

Yes. These are in AppDelegate.cpp In fact, they are in the file twice. Below is the file contents:

#include "SimpleAudioEngine.h"

#if (CC_TARGET_PLATFORM != CC_PLATFORM_LINUX)
#include "ide-support/CodeIDESupport.h"
#endif

#if (COCOS2D_DEBUG > 0) && (CC_CODE_IDE_DEBUG_SUPPORT > 0)
#include "runtime/Runtime.h"
#include "ide-support/RuntimeJsImpl.h"
#else
#include "js_module_register.h"
#endif
#include "PluginReviewJS.hpp"
#include "PluginReviewJSHelper.h"
#include "PluginIAPJS.hpp"
#include "PluginIAPJSHelper.h"
#include "PluginReviewJS.hpp"
#include "PluginReviewJSHelper.h"
#include "PluginIAPJS.hpp"
#include "PluginIAPJSHelper.h"

USING_NS_CC;
using namespace CocosDenshion;

AppDelegate::AppDelegate()
{
}

AppDelegate::~AppDelegate()
{
	SimpleAudioEngine::end();
    ScriptEngineManager::destroyInstance();
    
#if (COCOS2D_DEBUG > 0) && (CC_CODE_IDE_DEBUG_SUPPORT > 0)
    // NOTE:Please don't remove this call if you want to debug with Cocos Code IDE
    RuntimeEngine::getInstance()->end();
#endif
}

//if you want a different context,just modify the value of glContextAttrs
//it will takes effect on all platforms
void AppDelegate::initGLContextAttrs()
{
    //set OpenGL context attributions,now can only set six attributions:
    //red,green,blue,alpha,depth,stencil
    GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};

    GLView::setGLContextAttrs(glContextAttrs);
}

bool AppDelegate::applicationDidFinishLaunching()
{
    // initialize director
    auto director = Director::getInstance();

    // set FPS. the default value is 1.0/60 if you don't call this
    director->setAnimationInterval(1.0 / 60);

#if (COCOS2D_DEBUG > 0) && (CC_CODE_IDE_DEBUG_SUPPORT > 0)

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    // for getIPAddress
    extern void setActivityPathForAndroid(const std::string &path);
    setActivityPathForAndroid("org/cocos2dx/javascript/AppActivity");
#endif

    auto runtimeEngine = RuntimeEngine::getInstance();
    auto jsRuntime = RuntimeJsImpl::create();
    runtimeEngine->addRuntime(jsRuntime, kRuntimeEngineJs);
    runtimeEngine->start();
    
    // js need special debug port
    if (runtimeEngine->getProjectConfig().getDebuggerType() != kCCRuntimeDebuggerNone)
    {
        jsRuntime->startWithDebugger();
    }
#else
    js_module_register();
    ScriptingCore* sc = ScriptingCore::getInstance();
    sc->addRegisterCallback(register_all_PluginReviewJS);
    sc->addRegisterCallback(register_all_PluginReviewJS_helper);
    sc->addRegisterCallback(register_all_PluginIAPJS);
    sc->addRegisterCallback(register_all_PluginIAPJS_helper);
    sc->addRegisterCallback(register_all_PluginReviewJS);
    sc->addRegisterCallback(register_all_PluginReviewJS_helper);
    sc->addRegisterCallback(register_all_PluginIAPJS);
    sc->addRegisterCallback(register_all_PluginIAPJS_helper);
    sc->start();
    sc->runScript("script/jsb_boot.js");
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
    sc->enableDebugger();
#endif
    ScriptEngineProtocol *engine = ScriptingCore::getInstance();
    ScriptEngineManager::getInstance()->setScriptEngine(engine);
    ScriptingCore::getInstance()->runScript("main.js");
#endif

    return true;
}

// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground()
{
    auto director = Director::getInstance();
    director->stopAnimation();
    director->getEventDispatcher()->dispatchCustomEvent("game_on_hide");
    SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
    SimpleAudioEngine::getInstance()->pauseAllEffects();    
}

// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
    auto director = Director::getInstance();
    director->startAnimation();
    director->getEventDispatcher()->dispatchCustomEvent("game_on_show");
    SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
    SimpleAudioEngine::getInstance()->resumeAllEffects();
}

Hi @jocolloman

These are duplicated.