appodeal / appodeal-cordova-plugin

Appodeal Cordova Plugin
https://www.appodeal.com
19 stars 33 forks source link

INTERSTITIAL shows twice with onLoaded callback #48

Closed mifkys closed 6 years ago

mifkys commented 6 years ago

I am working on app (Angular 2) with cordova-appodeal-plugin.

Initialization code:

let appKey = "xxx";
            Appodeal.setAutoCache(Appodeal.INTERSTITIAL, false);
            Appodeal.initialize(appKey, Appodeal.INTERSTITIAL | Appodeal.BANNER | Appodeal.REWARDED_VIDEO);
            this.registerCallBacks();

            this.do('cache', 'INTERSTITIAL'); // just Appodeal.cache(type) with console.log;

registerCallBacks() {
        Appodeal.setInterstitialCallbacks(container => {
            console.log('int container:', container);
            if (container.event == 'onLoaded') { // auto show on load
                console.log('INTERSTITIAL loaded');
                this.do('show', 'INTERSTITIAL');
            } 
        });
    }

This is console log:

main.js:31 initializing ads 10:45:04.808 main.js:82 cache INTERSTITIAL 10:45:05.640 main.js:47 int container: Object {event: "onInit"} 10:45:09.103 main.js:47 int container: Object {event: "onLoaded", isPrecache: false} 10:45:09.107 main.js:49 INTERSTITIAL loaded 10:45:09.114 main.js:82 show INTERSTITIAL 10:45:10.103 main.js:47 int container: Object {event: "onShown"} 10:45:12.616 main.js:47 int container: Object {event: "onLoaded", isPrecache: false} 10:45:12.619 main.js:49 INTERSTITIAL loaded 10:45:12.620 main.js:82 show INTERSTITIAL 10:45:23.902 main.js:47 int container: Object {event: "onClosed"}

info:

@ionic/cli-utils : 1.18.0 ionic (Ionic CLI) : 3.18.0

global packages:

cordova (Cordova CLI) : 7.0.1

local packages:

@ionic/app-scripts : 3.1.0
Cordova Platforms  : android 6.3.0
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 26.1.1
Node              : v8.9.0
npm               : 5.5.1
OS                : Windows 10

Environment Variables:

ANDROID_HOME : C:\dev\android-sdk

Misc:

backend : legacy

latest version of cordova-appodeal-plugin

Tamplier commented 6 years ago

@mifkys it's a bad idea to call show method in onLoaded callback. Appodeal plugin tries to load an ad while your application is working. In most cases, users want to show interstitials or banners more than one time during a work session. So, that's why our plugin tries to load an ad immediately after you call show for loaded one. And callbacks should work for every single attempt to cache an advertisement (in another case you won't know anything about loading status). So, callback works for the first interstitial, for the second interstitial and so on. Your second "onLoad" means that second interstitial is ready to be shown. You can add some boolean variable to your algorithm (wasInterstitialShown, for example). Or you can disable auto cache (Appodeal.setAutoCache(Appodeal.BANNER, false)) and perform your own algorithm of caching.

mifkys commented 6 years ago

It is a problem. Even AutoCache for INT ads already disabled (Appodeal.setAutoCache(Appodeal.INTERSTITIAL, false); in code above) fullscreen banners loads after every shown event.

Tamplier commented 6 years ago

@mifkys can you share your apk?