Using the Notification Filter in Appcelerator

Please Note: Support for Appcelerator has been deprecated.   

A little while ago Plot provided a filter for your notifications, we wrote a blog post about this. The filter enables you to show notifications that match the preferences of your users and personalize these messages accordingly. It also allows to smoke test your notifications. We want to explain in this post how to use it in your Appcelerator Titanium app!

Personalized Notification

Example of Personalized Notification


We will explain in short how to enable the notification filter, how to define the filter, and how to use it to modify your notifications just before they are sent. We assume you already have integrated our plugin into Appcelerator Titanium, if not, see our previous blog post about this.

To enable the notification filter, you add the property notificationFilterEnabled with the value true to object passed to initPlot. An example of this is displayed below. When the notification filter is disabled the notification filter script won’t be executed and all notifications will be shown.

The following snippet has to be added to your initialization script, which usually is app.js or alloy.js. You can obtain the public token at our dashboard.

var plot = require('com.plotprojects.ti');
plot.initPlot({ publicToken: 'REPLACE_ME',
				notificationFilterEnabled: true });

You define the filter in assets/plotfilter.js. When the Plot library detects that a notification could be shown, it executes the script. The script runs in a different context than the other scripts which are executed. Therefore you cannot reference views or global variables from the notification filter. This is done to allow the script to run independently from the rest of the app, making the background execution much more efficient.

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

That is all that is required to get the notification filter running in your application. You should receive your notifications based on your newly implemented filter!

Further information

We hope that this blogpost made it clear how to use the notification filter from Plot in Appcelerator Titanium. Additional information about our module can be found on our github repository.

Spread the love