Set sdkbox_config outside of build dir

Set sdkbox_config outside of build dir
0

#1

i am using cocos creator 2.1
i am building for web, ios and android.
The problem is that i store my admob info on sdkbox_config but i have to put it on each build dir and sometimes it gets deleted on any update.
any way to reference as a whole project file?


#2

web? sdkbox don’t support web platform for now.


#3

follow solution can store sdkbox_config.json in assets folder.

http://docs.sdkbox.com/en/qa/crypt-sdkbox-config/#use-cocos-creators-solution


#4

thank you!


#5

How can i use it for ads ?


#6

i don’t know what’s meaning?

this is just take sdkbox_config.json as a js file, usage is same as sdkbox_config.json


#7

no really
because the file is a js file
const sdkbox_config = require(’…/SDKBox/sdkbox_config’)

then it is called into sdkbox.IAP.init;
sdkbox.IAP.init(JSON.stringify(sdkbox_config));

IAP is for In app


#8

i know. which plugin are you use?


#9

sdkbox.PluginAdMob


#10

ok, we will provider a more common solution, will update this thread when finish.


#11
  • modify AppDelegate.cpp like follow:
...
#include "SDKBoxJSHelper.h"
...

bool AppDelegate::applicationDidFinishLaunching()
{
    ...

    jsb_register_all_modules();
    se->addRegisterCallback(register_all_SDKBoxJS_helper);

    ...

    return true;
}

  • move and rename jsb-link/res/sdkbox_config.json to assets/SDKBox/sdkbox_config.js.
  • add module.exports = to assets/SDKBox/sdkbox_config.js at first line
module.exports =
{
    "android": {
        "iap": {
            ...
        }
        ...
    },
    "ios": {
        "iap": {
            ...
        }
        ...
    }
}

  • require sdkbox_config.js, and send json string to sdkbox
const sdkbox_config = require('../SDKBox/sdkbox_config')
...
sdkbox.setConfig(JSON.stringify(sdkbox_config)); // make sure call this before sdkbox pluign init
...
sdkbox.PluginAdMob.init();
...

#12

setConfig doesnt exists


#13

please register by yourself