Notification Strategies allow you to implement specific behaviors for when Notifications are created in your application.

You can generate specific algorithms to determine when the BeaconNotification.createNotification method is called.

For example, you can decide to display a beacon notification only for specific bus stops or specific bus lines.
You can also decide to only send a maximum of 2 notifications every 30 min.

Each Notification Strategy must be registered in the AdtagBeaconManager class.

Connecthings' SDK provides you with a sample set of Notifications Strategies, which you can freely use. You can also code your own, and implement as many as you want in your application.

The SDK uses a 'first added, first executed' pattern to process the Notification Strategies that you have implemented.

Note:

Notification Strategies are simple, unitary rules to facilitate beacon notification management. Complex rules can be achieved by cumulating various Notification Strategies.

Using Notification Strategies provided by Connecthings

We provide three built-in Notification Strategies:

The Spam Region Filter Strategy

This strategy allows to condition the launch of new beacon notifications only when an entry into a new "region" is detected.
A region is an Adtag dynamic field, which enables you to dynamically organize beacons into regions at any time.

This strategy can be integrated using the ATBeaconNotificationStrategySpamRegionFilter class on iOs or the BeaconNotificationStrategySpamRegionFilter class on Android.

The Spam Region Time Filter Strategy

This strategy allows to define:

  • a minimum time lapse between two beacons notifications
  • a minimum time laps prior to generating a new notification, when the application goes to the background.

This strategy can be integrated using the ATBeaconNotificationStrategySpamTimeFilter class on iOs or the BeaconNotificationStrategySpamTimeFilter class on Android.

The Spam Max Filter Strategy

This strategy allows to define a maximum number of notifications that can be pushed to the user over a specific period of time.

This strategy can be integrated using the ATBeaconNotificationStrategySpamMaxFilter class on iOs or the BeaconNotificationStrategySpamMaxFilter class on Android.

Testing Connecthings' Notification Strategies

  • Clone the beacon-tutorial repository
git clone https://github.com/Connecthings/sdk-tutorial.git
  • Open the project/folder :

    • Android: android > beacon> 7-Default-Notification-Strategy > Complete with your Android Studio
    • iOs: ios > beacon > 7-Default-Notification-Strategies > Complete and launch cocoapod.
  • Configure the SDK as described in the quickstart tutorial

  • Play with the application:

    • Add/remove Notification Strategies
    • Test their impact on the creation process of beacon notifications

The Notification Strategy interface/delegate

A Notification Strategy must implement the following methods:

  • deleteCurrentNotification: query to know if the SDK has to delete the currently displayed notification. If no beacon notification is displayed, the method is not called. By default, the method must return true.

  • createNewNotification: query to know if the SDK has to create a new notification. If the method deleteCurrentNotification returns "false", this method is not called. By default, the method must return true.

  • onNotificationCreated: method to notify the Strategy that a notification has been created.

  • onNotificationDeleted: method to notify the Strategy that a notification has been deleted.

  • onBackground: method to notify the Strategy that the application is going into the background.

  • onForeground: method to notify the Strategy that the application is activated / in the foreground.

  • onStartMonitoringRegion: method to notify the Strategy that the SDK has started to monitor a new region based on the UUID, major, and minor of the nearest and last detected beacon.

  • save: allows to save data needed by the strategy when the application restarts.

  • load: allows to retrieve the data previously stored by the strategy.

Notification Lifecycle with Notification Strategies

The following diagram gives an overview of the notification lifecycle, and includes the various queries to the Notification Strategy methods.