'resume' isn't triggering consistently

I’m using the following code:

$ionicPlatform.on('resume', function() {
    // do stuff



My problem is on both the iOS simulator and on my iPhone, this seems very inconsistent. Sometimes it triggers resume and sometimes (actually, mostly) not.

I either a) don’t fully understand when resume is triggered or how it works or b) am putting it in the wrong place.

To test it I’ve tried clicking the home button and then opening the app again. I’ve also tried opening the app, closing it and opening it again.

Can anyone point me in the right direction?

I wonder if resume is not triggered if the app is taken out of ‘background’ mode rather than ‘suspend’?

You’re probably right. But my problem is when the app is hidden, not closed. Not sure what I am doing wrong here.

One thing I’m still trying to get my head around is in what order code executes. I seem o have to use $timeout() a lot so that things don’t execute before the should. Maybe that’s part of my problem?