I want to close my app when user force close.
Any event arise for force close in ionic application ?
Any plugin for force close event handling in ionic app ?
example: A common piece of functionality for native mobile applications is the ability to logged out if the user closes the application(force stop/force close).
How can this be achieved for a Cordova / Ionic / PhoneGap ?
Put the following code accordingly to your angular.run configuration, and that's it. You can even add some checks, for example using a boolean value in a Service or a check to the current state to decide if prompt to the user the closing app notice or not.
.run(function($ionicPlatform, $ionicPopup) {
$ionicPlatform.onHardwareBackButton(function () {
if(true) { // your check here
$ionicPopup.confirm({
title: 'System warning',
template: 'are you sure you want to exit?'
}).then(function(res){
if( res ){
navigator.app.exitApp();
}
})
}
})
});
i am looking for this(below steps)
1) start app.(with login)
2)press home button(from device(middle button).
3)go to->settings->application manager ->click on my app->force stop my app.
4)after pressing force stop. the app should be clear all data which available in local storage like(login info).
5)app should logout.
but in my application i can't logout or clear data after pressing force stop.