I am developing a chat app inside I am using on pause and on resume event.
document.addEventListener('pause',onpause, false);
document.addEventListener('resume' , onresume,false);
This event works perfectly when I open the app and press home button to an Android phone these events are perfect. But my problem is that in chat app I am sending file attachments from the gallery when I select the browse button the phone image gallery, and same time pause event is fire. while I am on image gallery at a not selecting any image same time when I click on the home button the same event is not firing. So how I can prevent the pause event while selecting the file from the gallery.
Is there any other way to do this in ionic v1? Or how I can fire on pause and on resume event for the same.
I'm not sure if you're using Ionic 1 or 2, but for both versions you have the lifecycle events.
Here are the ones for Ionic 2 (scroll down to "Lifecycle events") https://ionicframework.com/docs/api/navigation/NavController/
Here are the ones for Ionic 1 https://forum.ionicframework.com/t/order-of-lifecycle-events/28251/2
You can remove the pause event before you open the gallery and reattach the event on the gallery's callback.
I wrote a small Service to solve that problem:
The gallery call is also wrapped in a service. Every time I call it, I "halt" the event and "continue" it after the user interaction finishes:
The last step: Instead of listening for the resume event, I subscribe to the resume Oberservable: