Flutter Advanced Features

Learn more about advanced features such as Product Config, Feature Flags, Native Display, and more.

Advanced Features

Debugging

During development, we recommend that you set the SDK to DEBUG mode, in order to log warnings or other important messages to the iOS logging system. This can be done by setting the debug level.

Set Debug Level

Debug level can be one of the following:

  • -1: Disables all debugging. You can set the debugLevel to -1 if you want to disable CleverTap logs for the production environment.
  • 0 : Default, shows minimal SDK integration related logging.
  • 2 : Shows debug output.
  • 3 : Shows verbose output.
CleverTapPlugin.setDebugLevel(debugLevel);

🚧

Note

To get the SDK logs in the killed state, add platform-specific debugging.

Push Notifications

Registering FCM, Baidu, or Huawei Token

CleverTap supports integration with various 3rd party push providers for Android platform

  • To enable automatic integration with Various providers via CleverTap , integrate the associated clevertap service in Android module of your code by following the Android push guide
  • To enable manual integration with various 3rd party push providers, You can integrate them via their associated implementation guides and use the Flutter plugin's built in methods to send Push token to CT server:
CleverTapPlugin.setPushToken(β€œvalue”);
CleverTapPlugin.setBaiduPushToken(β€œvalue”);
CleverTapPlugin.setHuaweiPushToken(β€œvalue”);

Create Notification

CleverTapPlugin.createNotification(data);

Custom Handling for Pull Notifications

Process Push Notification

CleverTapPlugin.processPushNotification(data);

Native Display

Native Display helps to display content natively within your app without interrupting the user. It also provides the ability to change the content of your app dynamically and deliver relevant and contextual content to your users.

On Display Units Loaded Callback

_clevertapPlugin.setCleverTapDisplayUnitsLoadedHandler(onDisplayUnitsLoaded);

void onDisplayUnitsLoaded(List<dynamic>? displayUnits) {
    this.setState(() {
      print("Display Units = " + displayUnits.toString());
   });
}

Get All Display Units

void getAdUnits() {
    this.setState(() async {
      List? displayUnits = await CleverTapPlugin.getAllDisplayUnits();
      print("Display Units Payload = " + displayUnits.toString());

      displayUnits?.forEach((element) {
        var customExtras = element["custom_kv"];
        if (customExtras != null) {
           print("Display Units CustomExtras: " +  customExtras.toString());
         }
      });
     });
}

Display Unit Viewed Event for ID

CleverTapPlugin.pushDisplayUnitViewedEvent(β€œunitId”);

Display Unit Clicked Event for ID

CleverTapPlugin.pushDisplayUnitClickedEvent(β€œunitId”);

Product Config

πŸ“˜

Feature Availability

A new and enhanced version of Product Experiences is coming soon. New customers (CleverTap for Enterprise or CleverTap for Startups) who have not enabled the current functionalities can use this feature only when the new version is released. However, the existing users can continue to use it. The methods for the Product Experiences feature have been deprecated and will be removed from the code by September 2024.

With Product Experiences, you can change the behavior and appearance of your app remotely without an update. This helps you to deliver an in-app personalization experience to your app users and test their response. You can use product config to modify app behavior and feature flags to add or remove features from your app without performing an app store deployment.

Set Product Configuration to Default

You can set in-app default parameter values in the Product Config object so that your app behaves as intended before values are fetched from CleverTap, and so that default values are available if none are set on the dashboard.

void productConfigInitialized() {
    print("Product Config Initialized");
    this.setState(() async {
      await CleverTapPlugin.fetch();
    });
}

Fetch and Activate Values

To fetch parameter values from CleverTap, call the fetch() method. Any values you set on the dashboard are fetched and stored in the Product Config object.
To make fetched parameter values available to your app, call the activate() method.

For cases where you want to fetch and activate values in one call, you can use a fetchAndActivate()request to fetch values from CleverTap and make them available to the app:

Fetching Product Configs

By default, the fetch calls are throttled, which is controlled from the CleverTap servers as well as SDK. To know more, see the Throttling section. The default value for minimum fetch interval is set at 60*10 by default from CleverTap.

void fetch() {
    CleverTapPlugin.fetch();
    // CleverTapPlugin.fetchWithMinimumIntervalInSeconds(60*10);
}

Activate the Most Recently Fetched Product Config

void activate() {
    CleverTapPlugin.activate();
}

Fetch And Activate Product Config

void fetchAndActivate() {
    CleverTapPlugin.fetchAndActivate();
 }

Fetch Minimum Time Interval

CleverTapPlugin.setMinimumFetchIntervalInSeconds(interval);

Get Boolean Key

CleverTapPlugin.getProductConfigBoolean(β€œkey”);

Get String Key

CleverTapPlugin.getProductConfigString("StringKey");

Get Long Key

CleverTapPlugin.getProductConfigLong("IntKey");

Get Double Key

CleverTapPlugin.getProductConfigDouble("DoubleKey");

Get the Last Fetched Timestamp in Milliseconds

CleverTapPlugin.getLastFetchTimeStampInMillis();

Feature Flag

Feature flags let you toggle a feature on and off controlled via CleverTap Backend.

Get Feature Flag

Feature flags are automatically fetched every time a new app session is created. Once the flags are fetched you can get it via the getters.

void featureFlagsUpdated() {
    this.setState(() async {
      bool booleanVar = await CleverTapPlugin.getFeatureFlag("BoolKey", false);
   });
}

App Personalization

Enable Personalization

CleverTapPlugin.enablePersonalization();

Disable Personalization

CleverTapPlugin.disablePersonalization();

Attributions

Push Install Referrer

CleverTapPlugin.pushInstallReferrer("source", "medium", "campaign");

GDPR

Set Opt Out

CleverTapPlugin.setOptOut(false); ///Will opt in the user to send data to CleverTap
CleverTapPlugin.setOptOut(true); ///Will opt out the user to send data to CleverTap

Enable Device Networking Info Reporting

// Will opt out the user to send Device Network data to CleverTap
CleverTapPlugin.enableDeviceNetworkInfoReporting(false);
// Will opt in the user to send Device Network data to CleverTap
CleverTapPlugin.enableDeviceNetworkInfoReporting(true);

Set Offline

// Will set the user online
CleverTapPlugin.setOffline(false);
// Will set the user offline
CleverTapPlugin.setOffline(true);

Encryption for PII data

PII data is stored across the SDK and could be sensitive information. From CleverTap Flutter SDK v1.9.0 onwards, you can enable encryption for PII data such as Email, Identity, Name, and Phone.

Currently, two levels of encryption are supported, i.e., None(0) and Medium(1). The encryption level is None by default.

  • None: All stored data is in plaintext
  • Medium: PII data is encrypted completely

Android

The only way to set the encryption level in Android is from the manifest file. Add the encryption level in the manifest as following:

<meta-data
    android:name="CLEVERTAP_ENCRYPTION_LEVEL"
    android:value="1" />

iOS

The only way to set the encryption level in iOS is from the info.plist file. Add the CleverTapEncryptionLevel String key to info.plist file, where value 1 means Medium and 0 means None. The encryption level is set to None if any other value is provided.


What’s Next