Ionic 2: How to handle the hardware back button which checks confirmation of Exit in app

前端 未结 7 652
你的背包
你的背包 2020-12-05 06:12

I am facing an issue how to handle the default mobile\'s back button which checks the confirmation while exiting from the application, if I pressed the back button there sho

7条回答
  •  忘掉有多难
    2020-12-05 06:54

    This is my resolved and working Code. Thank you everyone.

    constructor(platform: Platform,public alertCtrl: AlertController,public toastCtrl:ToastController) {
        platform.ready().then(()=>{
           platform.registerBackButtonAction(()=>this.myHandlerFunction());
           StatusBar.styleDefault();
          Splashscreen.hide();
    })
      }
    
        myHandlerFunction(){
         let toast = this.toastCtrl.create({
          message: "Press Again to Confirm Exit",
          duration: 3000
        });
        toast.present(); 
         }
    

提交回复
热议问题