Ionic.Platform.exitApp() does not fire scope destroy

Hi,

We are having trouble shutting down our polling services on app exit and on app pause.
In the controllers I added

$scope.$on('$destroy', function () {
 $interval.cancel(<pollingIntervall>);
});

But the destroy signal does not fire if I call

ionic.Platform.exitApp()

nor if the app gets paused (hardware home button).

If I add

$rootScope.$destroy();

before I call …extiApp() all scopes receive the destroy signal. But that doesnt work if the user is closing the app by using the hardware back button.

Thanks for any help.

1 Like

How have you solved that?
I need to fire a method when the android OnStop() is called (when the OS kills the app). Any suggestion?

We used a ugly workaround. Overwriting the back button action to make it impossible to leave the app via back button. Then we used a broadcast to send the pause event (home button) to all scopes to clean up.

The only way a user may close the app then is to use the application manager or swiping it out under the recently used apps. In both cases the user will have to leave the app first via home button.

We also tryed to manually call ionic.Platform.exitApp() in the back button action but I’m not quite sure we had some trouble with that so we used the first mentioned workaround.