How to prevent hardware backbutton from redirecting to previous page , but i need to exit app when it is pressed twice.
ie, single press -> Do nothing
More than single times -> Exit app
Somebody help me out
How to prevent hardware backbutton from redirecting to previous page , but i need to exit app when it is pressed twice.
ie, single press -> Do nothing
More than single times -> Exit app
Somebody help me out
somebody ???
Thanks, i was hoping for an example
just make a function like this:
//pseudocode - no gurantee that it will work what so ever
doubletap:boolean = false;
reset (){
setTimeout(_ =>{this.doubletap = false}, /* milliseconds max between the presses */);
}
backpressed (){
this.reset();
if(this.doubletap)
this.platform.exitApp();
else
this.doubletap = true;
}
platform.registerBackButtonAction(backpressed);
I also found this gist: https://gist.github.com/shrekuu/1d0ac923a322f5296a778d3d5c6a9ac9
Futhermore look for ionViewCanLeave
if you want only to restrict going back with the hardware button instead of disabeling it in your app at all.