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.
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.
You can configure the strategies you want to use directly on the App Management section of the Adtag Platform, including your own strategies.
And so, your strategies will be automatically active/deactive in your application depending on the schedulingInterval variable you seized on the App Mananger section.
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.
Two are directly available through the Adtag Application Management section under the Spam Management section in the Notifcations Tab.
The last strategy is the Spam Region Filter Strategy, which 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.
Testing The Region Filter Strategy
Register strategy in Adtag
Connect to the Adtag Platform
Click on your name at top right of your screen
Select Application Management in the menu
A page with the list of applications configured on your account opens
Select your application
Click on the Notifications tab
Activate the custom strategies
Add the region filter strategy under the name spamRegionFilter to the list of custom strategies
Test the strategy
- 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
The Notification Strategy interface/delegate
A Notification Strategy must implement the following methods:
getName: this method returns the string key associated to your notification strategy that was created. You must add this key to the appropriate custom notification field on the Adtag platform.
updateParameters: for now, this method is for Connecthings' SDK private use.
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.