rahadur / capacitor-admob

This is Ionic Capacitor native AdMob plugin for IOS & Android
https://xplatform.app
MIT License
77 stars 28 forks source link

Interstitial loads previous tab onAdClosed event #63

Open cerveira9 opened 4 years ago

cerveira9 commented 4 years ago

I have an application that has 3 tabs.

The second tab has videos and when I tap "watch here" it shows an interstitial add. When I close it, the app redirects me to the youtube page where the video was uploaded and starts to play it. Nice! Thats what I want it to do.

The problem comes next. My third tab has a card that when i touch it, it redirects me to another screen inside the app. I coded to show an interstitial when you tap the card. So the idea is to show the Interstitial on between screen changes. It shows but when I close it, it loads the youtube video just like if I was on the second tab. If I close YT app and go back to my app, it changes the screen normally.

The issue is to redirect to youtube since this was not suposed to do.

even the interstitial unitId codes are different

tab2.ts showAd method:

showAd(link: String) {
    this.linkFixo = link;
    AdMob.showInterstitial().then(
      value => {
        AdMob.addListener('onAdClosed', (info: any) => {
          window.open(this.linkFixo.toString(), '_system', 'location=yes');
          return false;
        }); 
        AdMob.prepareInterstitial(this.options).then(
          value => {
            console.log(value); // true
          },
          error => {
            console.error(error); // show error
          }
        );
      },
      error => {
        console.error(error); // show error
      }

    );
  }

tab3.ts showAd method:

showAd() {
    AdMob.showInterstitial().then(
      value => {
        console.log(value); // true
        AdMob.addListener('onAdClosed', (info: any) => {

          return null;
        });
        AdMob.prepareInterstitial(this.options).then(
          value => {
            console.log(value); // true
          },
          error => {
            console.error(error); // show error
          }
        );
      },
      error => {
        console.error(error); // show error
      }
    );
  }