Ionic pause and resume event not working when image gallery is open and press the home button

I am developing an chat app inside I am using onpause and onresume event.

document.addEventListener('pause',onpause, false);
document.addEventListener('resume' , onresume,false);

This event works perfectly when I open the app and press home button of an Android phone this events are perfectly. But my problem is that in chat app I am sending file attachments from gallery when I select the browse button the phone image gallery, and same time pause event is fire. while I am on image galleryat an not selecting the any image same time when I click on home button the same event is not firing. So how I can prevent the pause event while selecting the file from gallery.

Is there any other way to do this in ionic? Or how I can fire onpause and onresume event for the same.