Altering or canceling notifications on the device

Plot Projects offers 2 ways of segmentation: client-side segmentation(with the Plot Projects NotificationFilter) and server-side segmentation (with the Plot Projects Segmentation feature).

In case you're not sure wich one suits your business the most please feel free to contact us so we can explain you a bit more the difference between these two.

More information on server-side segmentation can be found in paragraph Segmenting notifications.

The rest of this paragraph is about client-side segmentation.

When you want to personalize the notifications, you can use the notification filter, it allows you to filter out or edit notifications before they are shown.

Be aware even though the notification reached this stage, doesn't mean it will be displayed to the user. In case you have set up cooldown periods, it will be processed after this step.


Plot automatically detects whether a service is registered in AndroidManifest.xml that extends from the class NotificationFilterBroadcastReceiver. Implementations of NotificationFilterReceiver must implement the method public List<FilterableNotification> filterNotifications(List<FilterableNotification> notifications). When the service is defined Plot will send the notifications to this method before showing them on the mobile device. This allows you to prevent notifications from being shown or change the notifications.

The “data” field of a notification allows you to add custom information to a notification in our dashboard that you can access in the filterNotifications() method. Plot doesn’t prescribe a format for this data. You can use plain text, or for example use JSON.

//Example implementation for filterNotifications:
public class MyNotificationFilterReceiver extends NotificationFilterBroadcastReceiver {
    public List<FilterableNotification> filterNotifications(List<FilterableNotification> notifications) {
        String format = "Hello Paul: %s";
        for (FilterableNotification notification : notifications) {
            String newMessage = String.format(format, notification.getMessage());
        return notifications;

And add this receiver to the manifest:

<receiver android:name=".MyNotificationFilterReceiver" android:exported="false">
       <action android:name="${applicationId}.plot.FilterNotifications" />

It is possible to change the message with the setMessage() method or it is even possible to provide a custom Notification with the setNotification() method on FilterableNotification. By providing a custom notification object it is possible to send rich notifications, for example notifications with an image, to your users. When no custom Notification is specified, Plot will generate a Notification based on the message field and show that one.

We have written a more extensive blog post about this: Using The Notification Filter To Increase Relevance. A larger example is given in another blog post: Using Plot To Create Context-Aware Coupons, Offers And Promotions.


To enable the notification filter, you add the property notificationFilterEnabled with the value true to object passed to initPlot. When the notification filter is disabled the notification filter script won't be executed and all notifications will shown.

You define the filter in assets/plotfilter.js. When Plot detects that a notification could be shown, it executes the script. The script runs in a different context than the normal scripts are executed. Therefore you cannot reference views or global variables from the notification filter.

The message and the data property of the notification can be modified. You can remove notifications from the array you don't want to show. Always call plot.popFilterableNotifications() and plot.sendNotifications(filterableNotifications), even when no notifications will be shown.

An example for assets/plotfilter.js:

var plot = require('com.plotprojects.ti');'Notification Filter. Plot version: ' + plot.version);

var filterableNotifications = plot.popFilterableNotifications();

for (var i = 0; i < filterableNotifications.notifications.length; i++) {
    var n = filterableNotifications.notifications\[i\];
    n.message = "TestMessage: " + n.message; = "Test123: " +;

//always call plot.sendNotifications function, even if filterableNotifications.notifications becomes empty


You can see how to implement a notification filter for Phonegap/Cordova/Ionic at How to implement NotificationFilter and GeotriggerHandler for Phonegap/Cordova/Ionic .