Search code examples
ionic-frameworknavigationionic4back-button

Navigating to an external link from an ionic 4 app makes the hardware back button close the app where there is navigation history?


Navigate to an external link or display an interstitial Ad (AdMob) and then return to the app by clicking on the hardware back button. At this stage where there are pages in the history (navigation stack), clicking on the hardware back button will cause the app to close! Knowing that I had tried to register to the back button by:

this.platform.backbutton.subscribe(()=>{
this.navCtrl.pop();
// Also tried: this.navCtrl.back();
});

But it is still exiting the app!

Any idea about how to solve this?!


Solution

  • Actually, I had realized that navigating to an external link from the app and returning to it will not cause hardware back button issues, but the problem was that I am displaying the AdMob banner at top of the screen, and when I place it at the bottom (default position) the hardware back button is stable and works as expected even when navigating from the app to an external link and then returning back! So, I kept the banner at bottom where I noticed that positioning banner at bottom was more elegant (at least to my app).

    It seems that this is one of the issues in the AdMob plugin, where I had seen other issues about the ionic AdMob plugin without solutions!