How do I make a push notification system whenever the app is closed?

I'm making a messaging app but what I want to add is a push notification whenever someone replies and when the app is closed (just as the messages that you receive from WhatsApp or text when the app is closed) Ill appreciate someone's help! Thank you.

There is the OneSignal extension.

Thanks for the help! But can you teach me how to use it?

The developer of the extension should provide notes and an example.