Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 229110

this.platform.registerBackButtonAction doesn't work

$
0
0

i try different app (conference app- blank app) its worked but i try my app it doesn’t work .
I’ve been struggling 2 days I could not find the cause

my app.component

rootPage: any;
public counter = 0;
constructor(
public platform: Platform,
public statusBar: StatusBar,
public splashScreen: SplashScreen,
public app: App,
public toastCtrl: ToastController,
public splitPane: SplitPane,
public menu: MenuController,

) {
this.rootPage=Welcome;
this.platformbegin();

}

platformbegin(){

this.platform.ready().then(() => {
  this.statusBar.styleDefault();
  this.splashScreen.hide();


  this.platform.registerBackButtonAction(() => {
    if (this.counter == 0) {
      this.counter++;
      this.presentToast();
      setTimeout(() => { this.counter = 0 }, 2000)
    } else {
      // console.log("exitapp");
     this.platform.exitApp();
    }
  }, 0)
});

}

presentToast() {
let toast = this.toastCtrl.create({
message: “Press again to exit”,
duration: 2000,
position: “bottom”
});
toast.present();
}

backToWelcome() {
const root = this.app.getRootNav();
root.popToRoot();
}

logout() {
//Api Token Logout

localStorage.clear();
this.menu.enable(false);
setTimeout(() => this.backToWelcome(), 1000);
this.nav.setRoot(Welcome);

}
openPage(page: PageInterface) {

this.nav.push(page.component, { item: page.index });

}
}


Viewing all articles
Browse latest Browse all 229110

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>