Localytics provides callbacks/delegates that allow you to modify or suppress a Localytics Places campaign before it's displayed to the user. For example, you can insert a user-specific offer code or personalized info from your app, or block notifications from a store outside of its store hours.
Set up the callbacks after your Localytics initialization code.
For Places notification suppression or modification, call
* Add a listener that will be notified of certain messaging callbacks:
* @param listener The object that will receive the callbacks. Pass in null to
* remove an existing listener.
public static void setMessagingListener(@Nullable final MessagingListener listener)
And pass a MessagingListener with callbacks for suppressing and for modifying Places notifications:
* Callback to determine if the triggering of a Places campaign should
* show a local notification.
* @param campaign An object defining a Places Campaign
* @return The decision to show the local notification.
boolean localyticsShouldShowPlacesPushNotification(@NonNull PlacesCampaign campaign);
* Callback to modify a Places notification before display.
* @param builder The Android Notification builder used to customize a local
* @param campaign The campaign that triggered the push notification
* @return The Android Notification Builder with all updated preferences
@NonNull NotificationCompat.Builder localyticsWillShowPlacesPushNotification(
@NonNull NotificationCompat.Builder builder, @NonNull PlacesCampaign campaign);
Localytics.LLMessagingDelegate is a protocol which defines methods to be called when an in-app or Places campaign will be rendered. When you have implemented your delegate, call
[Localytics setMessagingDelegate: delegate] after Localytics initialization to hook in your custom logic to suppress or modify Places notifications. This delegate can include these methods:
- (BOOL)localyticsShouldDisplayPlacesCampaign:(nonnull LLPlacesCampaign *)campaign;
- (nonnull UILocalNotification *)localyticsWillDisplayNotification:(nonnull UILocalNotification *)notification forPlacesCampaign:(nonnull LLPlacesCampaign *)campaign;
shouldDisplayPlacesCampaign can return
NO to suppress the display of a Places notification.
localyticsWillDisplayNotification allows you to modify and return a
UILocalNotification for display. The delegate will be called with a
LLPlacesCampaign object, which includes a
region property that includes the identifier as well as any extra attributes associated with the region that triggered the campaign.
You can also add callbacks to fire when geofence events occur independently of Places campaigns.