Ionic resume pause event prevent from fire on file browse only fire at 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.

any plugin you use for the chat app?? I am also doing a chat app but with video chatā€¦ Sending text have been done but for the video part I still in the developmentā€¦