I have added a back button in my app on the home page that will allow my app to exit. Somehow when I want to go back from another page to home page then also the app destroys and I return to my phone.
import { Component, OnInit, OnDestroy, AfterViewInit } from '@angular/core';
import { Platform } from '@ionic/angular';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage implements OnInit, OnDestroy, AfterViewInit {
backButtonSubscription;
constructor( private platform: Platform) {
}
ngOnInit() {
}
ngAfterViewInit() {
this.backButtonSubscription = this.platform.backButton.subscribe(() => {
navigator['app'].exitApp();
});
}
ngOnDestroy() {
this.backButtonSubscription.unsubscribe();
}
}
What should I do so that my application only exits from the home page and not from all the pages.