Flutter In-App

Learn how to handle in-app notifications in Flutter.

In-App Notifications

The CleverTap SDK allows you to show In-App notifications to your users and send In-App messages with images, GIFs, video, and audio. You can design In-App notifications right from the dashboard without writing a single line of code. No code is required for this feature. You can also do A/B testing on your In-App notifications.

πŸ“˜

Header and Footer In-App Notification Template for Android

To use CleverTap's Header and Footer In-App Notification Templates, update the MainActivity class to inherit the FlutterFragmentActivity class instead of FlutterActivity.

public class MainActivity extends FlutterFragmentActivity {  
//FlutterFragmentActivity supports Header & Footer InApp Notification Templates  
}

In-App Notification Button onClick Callbacks

CleverTap supports callback on the click of InApp Notification Buttons by returning a Map of Key-Value pairs. To handle on In-App Button click, add the following code snippet:

_clevertapPlugin.setCleverTapInAppNotificationButtonClickedHandler(inAppNotificationButtonClicked);

void inAppNotificationButtonClicked(Map<String, dynamic> map) {
    this.setState(() {
      print("inAppNotificationButtonClicked called = ${map.toString()}");
    });
}

In-App Notification Button onDismissed callback

To handle on Dismissed callback:

_clevertapPlugin.setCleverTapInAppNotificationDismissedHandler(inAppNotificationDismissed)

void inAppNotificationDismissed(Map<String, dynamic> map) {
    this.setState(() {
      print("inAppNotificationDismissed called");
    });
}

In-App Notification onShow() callback

To handle onShow callback:

_clevertapPlugin.setCleverTapInAppNotificationShowHandler(inAppNotificationShow);

void inAppNotificationShow(Map<String, dynamic> map) {
    this.setState(() {
      print("inAppNotificationShow called = ${map.toString()}");
    });
}

Control In-App Notifications

You can suspend, discard, or resume in-app notifications.

πŸ“˜

Note

The CleverTap SDK automatically resumes displaying the in-app notification after every new session.

Suspend

This method suspends and saves in-app notifications until resumeInAppNotifications method is called for the current session.

CleverTapPlugin.suspendInAppNotifications();

Discard

This method suspends the display of in-app Notifications and discards any new in-app notification.
In-app notifications are discarded until the resumeInAppNotifications method is called for the current session.

CleverTapPlugin.discardInAppNotifications();

Resume

The resumeInAppNotifications method resumes displaying in-app notifications. If you call this method after the discardInAppNotifications() method, it resumes the in-app notifications for events raised after the call is performed.

However, if you call the resumeInAppNotifications method after the suspendInAppNotifications() method, then it displays all queued in-app notifications and also resumes in-app notifications for events raised after the call is performed.

CleverTapPlugin.resumeInAppNotifications();

Web Pop-Ups

CleverTap Flutter SDK v2.0.0 onwards supports Web Pop-Ups