Save chat messages with closed app

Good evening!

I’m developing a chat application that looks like WhatsApp. I need the received messages to be saved on the user’s mobile device. Until then everything was ok, because I was saving the messages when the user received the push notification on the mobile, but the problem happens when the application is closed because when the application is closed the push notification does not trigger the received push event (I am using the Onesignal to send the push).

I’d like to know how I can do this, ie get a notification and process it even with my closed application. I think it has to do this because Whatsapp does this and also Spotify also does it when I connect the Spotify to another device it automatically forces the opening of the application on my cell phone.

So my question is, how do I handle an event with the application closed or even force it to open according to a particular event?

I’m using the technology of Ionic 1 and Angular.js. For push notification I am using the OneSignal provider.

Thanks in advance for your attention and hope someone can help me. Thank you!