A push notification meaning or a push message is an asynchronous message typically sent from a server to a device instructing the device to perform some action.
A push message results in a notification being displayed on mobile devices even if the device is on standby, informing the users that new data is available. A very common use case for push notifications is chat: The messaging server will send a new chat message to the device, and if the user has the chat app open, the message will appear in the conversation. If the chat app is in the background, the device will show the user a notification instead. Device Notifications are strongly linked with push use cases since they allow applications to perform work in the background.
Push notifications are not limited to mobile devices. For example, browser based calendar and mail apps will send a notification to your browser to alert you that a new event or message is available.
The PubNub API will receive messages for any subscribed channel, but this is only possible if the application that needs to receive the message is running. As previously mentioned, mobile devices will restrict what an application can do in the background, so if the user is not interacting with your app when a PubNub message is received, you have two choices:
Use the message history feature to fetch ‘missed’ messages when the application returns to the foreground. This choice is less than ideal if the user needs to be alerted immediately when a message is received, for example, a chat message.
Use the mobile device’s push notification mechanism (either Apple’s APNS or Google’s FCM, depending on the device) to immediately inform the user that a new message is available, even if the app is not running.
The diagram below shows how PubNub messages are delivered as the payload of the mobile device’s native push messaging technology (APNS / FCM), ensuring messages are received on the device even if it is on standby.
Push messaging and notifications are complex topics that can vary by platform. Please refer to Apple’s APNS or Google’s FCM for more information.