APNS - how to tell when to send notification?

In the apple APNS docs, it says: ‘When you have a notification to send to the user’

how do I determine the device has reach a state where the user needs a notification from normal websocket reception?

for instance, let’s say Johnny and Amber are arguing over chat. They each send each other 50 texts, which are received over websocket. Johnny then leaves his phone chat, how does the push provider server know that Johnny needs APNS notifications to be sent?

note that I am not having issue with sending notifications, nor do I want to send notifications for every chat message.

if the switch from websocket -> APNS isn’t consistent, I’ll have to request data from the server, which includes data prior to the notification, to make sure all messages are received. Is this the way it’s done?

APNS - how to tell when to send notification?
 
 
Q