Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

after close Interstitial ad then angular not able to detect changes on next page in capacitor/ionic

Homepage.ts

//all imports 
 async ionViewWillEnter() {
    this.init();
    // this.zone.run(async () => {
    this.InterDish = await AdMob.addListener(InterstitialAdPluginEvents.Dismissed, () => {
      console.log("Interstitial Dismissed");
      this.nextpage();
    });
    this.InterLoadFailh = await AdMob.addListener(InterstitialAdPluginEvents.FailedToShow, () => {
      console.log("Iterstitial FailedToShow");
      this.nextpage();
    });
    // });
  }

  ionViewWillLeave() {
    this.InterDish.remove();
    this.InterLoadFailh.remove();
  }

nextpage.html

<ion-segment [(ngModel)]="Design" (ionChange)="segmentChanged($event)">
      <ion-segment-button value="new">
        new
      </ion-segment-button>
      <ion-segment-button value="old">
        old
      </ion-segment-button>
      <ion-segment-button value="other">
        Other
      </ion-segment-button>
    </ion-segment>

when ads is disply and if i close the ad and on the "nextpage" segment not change, if i add write this
this.cdr.detectChanges(); code then only it detect change,
and if ad not display then it work correctly .

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

use ngZone

import { NgZone } from '@angular/core';

constructor(
   private zone: NgZone,    
) { }

this.InterDish = AdMob.addListener(InterstitialAdPluginEvents.Dismissed, () => {
  this.zone.run(() => {
     console.log("Interstitial Dismissed");
     this.nextpage();
  })
});
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading