Skip to content

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.


The delegate passed to [Plot initializeWithDelegate:] may implement the optional method -(void)plotFilterNotifications:(PlotFilterNotifications*)filterNotifications. When the method is implemented, 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. Please note that due to restrictions in iOS the notification filter for dwelling notifications is called when the user enters the geofence or beacon region and that the returned notifications are only shown when the user remains in the region for the specified amount of time.

The “data” field of a notification allows you to add custom information to a notification in our dashboard that you can access in the plotFilterNotifications: method. Plot doesn’t prescribe a format for this data. You can use plain text, or for example use JSON. You can access it by reading the PlotNotificationDataKey (constant defined in plot.h) from the userInfo dictionary of the UNNotificationRequest.

Make sure to always call showNotifications: at the end of your filtering, even when you have no notifications left. This way our plugin knows you have finished filtering.

//Example for plotFilterNotifications:
-(void)plotFilterNotifications:(PlotFilterNotifications*)filterNotifications {
    NSArray* notifications = filterNotifications.uiNotifications;
    for (UNNotificationRequest* notification in notifications) {

        //alter notification
        //ensure the keys in the userInfo also present in the new object.
        NSString* customMessage = @"Custom message";
        UNMutableNotificationContent* customContent =  [[UNMutableNotificationContent alloc] init];
        customContent.body = customMessage;
        NSMutableDictionary* userInfo = [notification.content.userInfo mutableCopy];
        customContent.userInfo = userInfo;
        UNNotificationRequest* updatedNotification =  [UNNotificationRequest requestWithIdentifier:notification.identifier content:customContent trigger:notification.trigger];
        [updatedNotifications addObject: updatedNotification];
    // Always call showNotifications at the end of the method
    [filterNotifications showNotifications:updatedNotifications];
//Example for plotFilterNotifications creating a rich notification:
-(void)plotFilterNotifications:(PlotFilterNotifications*)filterNotifications {
NSArray* notifications = filterNotifications.uiNotifications;
for (UNNotificationRequest* notification in notifications) {

    NSURL *fileURL = ... //  your media item file url
    NSError *error;

    NSArray* attachments = [NSMutableArray array];
    UNNotificationAttachment *attachment = [UNNotificationAttachment attachmentWithIdentifier:@"attachment" URL:imageURL options:nil error:&error]

    // first create your custom content object as in the previous example...

    customContent.attachments = [attachments arrayByAddingObject:attachment];

    //...ensure you update the notification object with the new content as in the previous example
// Always call showNotifications at the end of the method
[filterNotifications showNotifications:notifications];

You can change all fields of the PlotFilterNotifications object, except the fields that are related to scheduling. That functionality is not supported. For a reference of all fields you can change, you can check the Apple iOS Documentation. In order to implement rich notifications, you need to add each media item (UNNotificationAttachment) to the attachments array present in the UNMutableNotificationContent using the Notification Filter. Similarly to the rich content, to implement the Custom actions feature, you have to resort to the Notification Filter. This feature relies on two classes UNNotificationAction and UNNotificationCategory

When you have enabled the data protection feature of iOS, you have to ensure that the files you read in the filter are readable when the phone is locked. This can for example be done by setting the protection level of these files to None or CompleteUntilFirstUserAuthentication.