I would suggest that you also have another method of getting messages from the database as well as receiving the notifications. When the app starts it can use this call to the read all messages which were sent whilst it was closed.
I am not aware of an example of this so you will probably have to code it yourself.
perhaps Erel's implementation of a Mastadon client will help.
Roughly speaking, Mastodon is an open source, distributed, social network a bit similar to Twitter: https://joinmastodon.org/ Pleroma is a lightweight implementation of Mastodon with some extensions: https://blog.soykaf.com/post/what-is-pleroma/ I'm building an open source client for Pleroma...
www.b4x.com