Sending Push Notifications

The send operation allows you to send either a generic push notification to all recipients or a customized, targeted push notification based on a JSON notification object.

Despite its name, the send operation only schedules push notifications for sending. If you have not specified sending time, the server dispatches the push notification immediately or almost immediately. If a sending time is available, the push notification is send accordingly.

You can choose between the following methods for sending push notifications:

The Telerik Platform portal allows you to compose and target push notification using a graphical user interface (GUI). It provides a rich set of filtering and scheduling options, as well as tools to monitor the progress and the state of your push notifications. Filters and options that are not available in the GUI must be used through one of the client SDKs or the RESTful API.

The GUI is suitable for sending single push notification. When you need to send large numbers or regular push notifications, you may find it more convenient to use the other sending methods.

To create a push notification using the portal:

Open you app.

Navigate to Notifications > Push Notifications > Push Browser.

Click the Send a push notification button.

In the details panel that appears, fill in your details and select options.

Click Send Now.

This adds a row to the push browser. Clicking it opens the details pane where you can track the state of the push notification.

Sending push notifications using Cloud Code has certain benefits compared to the other methods.

The benefits include:

You can use the Cloud Code for Data events to trigger automatic sending of push notifications when something in your data changes.

Cloud Code for Data events are only triggered when data is changed trough the Backend Services APIs. For (Data Connectors, this means that no events will be triggered if you change the data directly in the connected database or through another application that does not utilize the Backend Services APIs.

When writing a Cloud Function to send push notifications you can safely use your master key to invoke operations that require it because it does not leave Telerik Platform. You can then invoke the Cloud Function's HTTP endpoint using only your App ID.

You can use the Backend Services JavaScript SDK or the RESTful API.

The following example demonstrates how to use the Backend Services JavaScript SDK to send a simple push notification from the beforeRead Cloud Code for Data event:

This code above schedules the "Hello" message for sending to all devices registered for push notifications in your application. If you want to target a subset of your devices or to specify advanced options, you need to construct the payload notification object accordingly: