React Native Advanced Features

Learn more about React Native advanced features.

Advanced Features

Debugging

Set Debug Level

CleverTap.setDebugLevel(3);

Push Notifications

Registering FCM Token

CleverTap.setPushToken("<Your FCM Token>", CleverTap.FCM);

Create Notification

CleverTap.createNotification(data);

Native Display

On Display Units Loaded

CleverTap.addListener(CleverTap.CleverTapDisplayUnitsLoaded, (event) => {
        _handleCleverTapDisplayUnitsLoaded(CleverTap.CleverTapDisplayUnitsLoaded, event);
    });

function _handleCleverTapDisplayUnitsLoaded(eventName, event) {
    console.log('CleverTap Display Unit Event - ', eventName, event);
}

Get All Display Units

function _handleCleverTapDisplayUnitsLoaded(eventName, event) {
    console.log('CleverTap Display Unit Event - ', eventName, event);
    CleverTap.getAllDisplayUnits((err, res) => {
        console.log('All Display Units: ', res, err);
    });
}

Display unit viewed event for ID

CleverTap.pushDisplayUnitViewedEventForID('Display Unit Id');

Display unit clicked event for ID

CleverTap.pushDisplayUnitClickedEventForID('Display Unit Id');

Product Config

Set Product Configuration to default

//Add the Product Config Initialized listener
CleverTap.addListener(CleverTap.CleverTapProductConfigDidInitialize, (event) => {
        _handleCleverTapEvent(CleverTap.CleverTapProductConfigDidInitialize, event);
    });

//Set the defaults Map
CleverTap.setDefaultsMap({
        'text_color': 'red',
        'msg_count': 100,
        'price': 100.50,
        'is_shown': true,
        'json': '{"key":"val"}'
    });

//Handle the callback
function _handleCleverTapEvent(eventName, event) {
    console.log('CleverTap Product Config Event - ', eventName, event);
}

Fetching product configs

//Add the Product Config Fetched listener
CleverTap.addListener(CleverTap.CleverTapProductConfigDidFetch, (event) => {
        _handleCleverTapEvent(CleverTap.CleverTapProductConfigDidFetch, event);
    });

//Fetch the Product Config
CleverTap.fetch();

//Handle the callback
function _handleCleverTapEvent(eventName, event) {
    console.log('CleverTap Product Config Event - ', eventName, event);
}

Activate the most recently fetched product config

//Add the Product Config Activated listener
CleverTap.addListener(CleverTap.CleverTapProductConfigDidActivate, (event) => {
        _handleCleverTapEvent(CleverTap.CleverTapProductConfigDidActivate, event);
    });

//Activate the Product Config
CleverTap.activate();

//Handle the callback
function _handleCleverTapEvent(eventName, event) {
    console.log('CleverTap Product Config Event - ', eventName, event);
}

Fetch And Activate product config

CleverTap.fetchAndActivate();

Fetch Minimum Time Interval

CleverTap.setMinimumFetchIntervalInSeconds(interval);

Get Boolean key

CleverTap.getProductConfigBoolean(“key”);

Get String Key

CleverTap.getProductConfigString(“key”);

Get Number key

CleverTap.getNumber(“key”);

Get last fetched timestamp in millis

CleverTap.getLastFetchTimeStampInMillis();

Feature Flag

Get Feature Flag

//Add the Feature Flag Updated listener
CleverTap.addListener(CleverTap.CleverTapFeatureFlagsDidUpdate, (event) => {
        _handleCleverTapEvent(CleverTap.CleverTapFeatureFlagsDidUpdate, event);
    });

//Get the Feature Flag on the callback
function _handleCleverTapEvent(eventName, event) {
    console.log('CleverTap Product Config Event - ', eventName, event);
    CleverTap.getFeatureFlag("BoolKey", false);
}

App Personalization

Enable Personalization

CleverTap.enablePersonalization();

Disable Personalization

CleverTap.disablePersonalization();

Attributions

Push Install Referrer

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

GDPR

Set Opt Out

CleverTap.setOptOut(false); ///Will opt in the user to send data to CleverTap
CleverTap.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
CleverTap.enableDeviceNetworkInfoReporting(false);
// Will opt in the user to send Device Network data to CleverTap
CleverTap.enableDeviceNetworkInfoReporting(true);

Set Offline

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

Did this page help you?