How does PubNub decide whether to publish an in-app message and when to send a push notification?
All messages published on an APN-enabled key are sent over both PubNub and APN. If the application is active the PubNub subscribe will receive the message and the push notification will also be received by the app. If the application is inactive, the message will only be received as a push notification via APN.
For more details, please see the community tip, Sending APNS and GCM Messages to Subscribers and Mobile Push Notification Services in One API Call