Using Appodeal with JS

Hi mates,

I’m trying to build an Android project coded with JS and using Appodeal sdkbox but I cannot find wich ad type values must be passed to:

sdkbox.PluginAppodeal.showAd(type);

Im trying this without luck:
sdkbox.PluginAppodeal.showAd(sdkbox.PluginAppodeal.ShowStyle.AppodealShowStyleInterstitial);

I also checked the sdkbox help but couldnt find this values.

any is using this?
I need some help.

1 Like

Can you try this sample and let me know if it works for you?
https://github.com/sdkbox/sdkbox-appodeal-sample

It works if I force the argument, like passing a 0 or 1, but I can’t find the corresponding costants in JS.

hi @kaotiklabs

Could you please check in your project at this location (not the sample app) -

<YOUR_PROJECT>/frameworks/runtime-src/proj.android/jni/pluginappodeal/PluginAppodeal.h 

Inside the file constants should be there inside enums…
Let me know.

Best,
Pabitra

    sdkbox.PluginAppodeal.init();

    // Attempt 1:        sdkbox.PluginAppodeal.showAd(sdkbox.PluginAppodeal.ShowStyle.AppodealShowStyleBannerBottom);
    //JS: assets/main.js:95:TypeError: sdkbox.PluginAppodeal.ShowStyle is undefined

    // Attempt 2:        sdkbox.PluginAppodeal.showAd(sdkbox.PluginAppodeal.AppodealShowStyleBannerBottom);
    //D/cocos2d-x debug info(23555): jsb: ERROR: File jni/../../Classes/PluginAppodealJS.cpp: Line: 535, Function: js_PluginAppodealJS_PluginAppodeal_showAd
    //D/cocos2d-x debug info(23555): js_PluginAppodealJS_PluginAppodeal_showAd : Error processing arguments
    //D/cocos2d-x debug info(23555): JS: assets/main.js:95:Error: js_PluginAppodealJS_PluginAppodeal_showAd : Error processing arguments

    // Attempt 3:        sdkbox.PluginAppodeal.showAd(AppodealShowStyleBannerBottom);
    // JS: assets/main.js:95:ReferenceError: AppodealShowStyleBannerBottom is not defined

    // Attempt 4:
    sdkbox.PluginAppodeal.showAd(0);
    // No Error
} 

None of the above 4 calls shows the Ad. Any help please.

hello @saiy2k

May we know which version of cocos2d-x and sdkbox you are using ?
also, please update sdkbox to latest version and try to run again.

Best,
Pabitra

Cocos2dx Version: 3.8.1
SDKBox Version: 0.5.7.24

Yup. I ll update to latest SDKBox (If any) on Monday and update here, if it works…

Guess I am working with the latest sdkbox version.

~/projects/game/ttt ]$ sdkbox update
  _______ ______  _     _ ______   _____  _     _
  |______ |     \ |____/  |_____] |     |  \___/ 
  ______| |_____/ |    \_ |_____] |_____| _/   \_
 Copyright (c) 2015 Chukong Technologies Inc. v0.5.7.24
 1.4.1.7 1.4.1.7
 1.4.1.7 1.4.1.7
 all packages are up to date.

Added the following listener functions:

    var plugin = sdkbox.PluginAppodeal
    plugin.setListener({
        onBannerDidLoadAd: function() { cc.log("onBannerDidLoadAd") },
        onBannerDidFailToLoadAd: function() { cc.log("onBannerDidFailToLoadAd") },
        onBannerDidClick: function() { cc.log("onBannerDidClick") },
        onBannerPresent: function() { cc.log("onBannerPresent") },
        onInterstitialDidLoadAd: function() { cc.log("onInterstitialDidLoadAd") },
        onInterstitialDidFailToLoadAd: function() { cc.log("onInterstitialDidFailToLoadAd") },
        onInterstitialWillPresent: function() { cc.log("onInterstitialWillPresent") },
        onInterstitialDidDismiss: function() { cc.log("onInterstitialDidDismiss") },
        onInterstitialDidClick: function() { cc.log("onInterstitialDidClick") },
        onVideoDidLoadAd: function() { cc.log("onVideoDidLoadAd") },
        onVideoDidFailToLoadAd: function() { cc.log("onVideoDidFailToLoadAd") },
        onVideoDidPresent: function() { cc.log("onVideoDidPresent") },
        onVideoWillDismiss: function() { cc.log("onVideoWillDismiss") },
        onVideoDidFinish: function() { cc.log("onVideoDidFinish") }
    }); 

    sdkbox.PluginAppodeal.init();
    sdkbox.PluginAppodeal.showAd(0);

and getting these logs:

D/cocos2d-x debug info( 2481): JS: onVideoDidFailToLoadAd
D/cocos2d-x debug info( 2481): JS: onBannerDidLoadAd
D/cocos2d-x debug info( 2481): JS: onInterstitialDidLoadAd
D/cocos2d-x debug info( 2481): JS: onVideoDidFailToLoadAd
D/cocos2d-x debug info( 2481): JS: onVideoDidFailToLoadAd
D/cocos2d-x debug info( 2481): JS: onVideoDidFailToLoadAd
D/cocos2d-x debug info( 2481): JS: onVideoDidFailToLoadAd
D/cocos2d-x debug info( 2481): JS: onVideoDidLoadAd

But the add is not getting displayed!

Thanks for log @saiy2k

This is why your ads are not loaded.

Syntax:

sdkbox.PluginAppodeal.showAd(<STYLE>);

These are the different values that should make your code look like this -

sdkbox.PluginAppodeal.showAd(sdkbox.PluginAppodeal.ShowStyle.AppodealShowStyleInterstitial);

As you can see below -
These are the various enum values that represents the STYLE, and it starts with 1 following the others as 2,3,4 etc. But in your code you have given value as 0 (which is not present).

typedef enum {
            AppodealShowStyleInterstitial = 1,
            AppodealShowStyleVideo,
            AppodealShowStyleVideoOrInterstitial,
            AppodealShowStyleBannerTop,
            AppodealShowStyleBannerCenter,
            AppodealShowStyleBannerBottom,
            AppodealShowStyleRewardedVideo
        } ShowStyle;

I believe now your issue will be solved.
Just try once and let me know.

Just for your reference, you should be able to find the Appodeal.h file as I have mentioned in my previous post.

Best,
Pabitra

1 Like

Hi,

Thanks for your comment. But As I said before,

sdkbox.PluginAppodeal.showAd(sdkbox.PluginAppodeal.ShowStyle.AppodealShowStyleBannerBottom);

was throwing this error:

JS: assets/src/MainMenu.js:131:TypeError: sdkbox.PluginAppodeal.ShowStyle is undefined

But this works perfectly fine:

sdkbox.PluginAppodeal.showAd(6);

Thanks a Lot :smile:

Yes, the problem is how to access correctly to the enum.

1 Like