Drual Push Notification API functions

Drupal Push Notifications Module’s Functions List (API Manuel)

The goal of this article is to give developers’ awareness about the functions included in the push notification module that can be used for your Drupal module development. There are around 20 functions available in the push notification module from which I am selecting 6 functions that can be used for your module to send notifications to APNS and GCM/C2DN services:


This function is the most valuable, which can be used to send push notification messages to selected users. The function sends messages to both Android and iPhone devices. There are two parameters for this message: the first parameter accepts the user IDs as an array; the second parameter accepts the message.

Usage in your module:


This function will get all registered tokens either for Android or iPhone devices. The function accepts three parameters: the device type id, a particular language based registered tokens, the return format – as raw token value array or as token object.

Note: The default type ids’ are: 0 – Apple; 1 – Android.

You have to use only the first parameter if you are not using any specific languages for your applications. Usage:


This function will help you to get all devices registered under a particular user. The function accepts User ID and returns the device tokens for both Apple and Android devices.

Usage in your module:


The function will send messages to the tokens given through the Apple Push Notification Service. The function accepts two parameters: Array of IOS tokens; The payload array to send message.

Make sure that you pass your payload in the correct array format. A valid format of the payload with custom data is given below:


This function will send a message to the Android devices through the Google Cloud Messaging service by accepting Android device tokens. The parameters are same as the previous method. The payload format is slightly different from the APNS function.

A valid payload format is:


The application of this function is same as the previous function. The only difference is that this function will use the Android Cloud to Device Messaging service instead of GCM. The two parameters and its formats are the same like the previous function.

Note: For implementing push notification in your custom module, please read the article: Sending Push Notification from your Drupal Module.