I am making an ionic app that uses an iframe to open a website on Android 11. To navigate utilizing the back button on the phone, I'm using the following code (this is executed when the app's homepage is launched):
constructor(private platform : Platform ) {
this.platform.backButton.subscribeWithPriority(10, () => {
window.history.go(-1);
});
}
Here is the homepage code:
<ion-content> <iframe id="mainIframeBrowser" src="http://192.168.1.19:8000" width="100%" height="100%" frameborder="0" allow="camera; microphone" style="padding:0;margin:0;"> </iframe> </ion-content>
What I want to do: when I click the back button on the first page of the history index, it exits the app.
ex:
if(window history index == 0) navigator['app'].exitApp();
Can I do this using the Window Object, with either history or location?
If so or if not, then how?
Thank you in advance.