简体   繁体   中英

Ionic 3 / Cordova Admob Rewarded Video Ads

Tried to make the Admob Rewarded videos work in Ionic 3 but couldn't make it happen! the ad doesn't trigger, have searched around stack and ionic forum but couldn't find a healing answer, I'm using Admob-free plugin

Here's what I have so far:

async showRewardedAds() {
    try {
      const rewardedConfig: AdMobFreeRewardVideoConfig = {
        id: "ID goes here...",
        isTesting: false
      }
      this.adMobFree.rewardVideo.config(rewardedConfig);
      const result = await this.adMobFree.rewardVideo.prepare();
      await this.adMobFree.rewardVideo.show();
      console.log(result)
    }
    catch (e) {
      console.log(e)
    }
  }

Whether I'm emulating it on Android or browser, nothing seems to work! Could anyone have some ideas or encountered this before?

  • Android platform version: android@6.4.0
  • Ionic v3

I have never used this plugin, but reading the docs ( https://ionicframework.com/docs/native/admob-free/ )
I think you should try something like this, handling the catch and the success of the promise

showRewardedAds() {
      const rewardedConfig: AdMobFreeRewardVideoConfig = {
        id: "ID goes here...",
        isTesting: false
      }
      this.adMobFree.rewardVideo.config(rewardedConfig);
      this.adMobFree.rewardVideo.prepare().then((data:any)=>{
        // HERE YOU WILL NEED TO MAKE THE SAME THING
        // catching the Error or the Success of the Promise
        this.adMobFree.rewardVideo.show()
      })
      .catch((e:Error)=>{
         console.log("Error ",e);
      });
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM