Event handler for close/force stop an ionic app
<p>I am developing an ionic app. I am wondering if there is any event handler for this condition when the app is being stop/close in follow ways:<br>
1) Settings -> Application -> Application Name -> Force stop <br>
2) Swipe to close app. <br></p>

<p>I would expect something like this. But the best i could found is to cater for app exiting via <code>$ionicPlatform.registerBackButtonAction</code> which does not include the above two scenario.</p>

<p>Also, I am not sure whether this can be done in native platform as well. Please advise on this.</p>

<pre><code>angular.module('app').run(function($ionicPlatform) {
    $ionicPlatform.onAppStopOrForceClose(function() {
        // Any function here
    });
});
</code></pre>