Package 

Class CleverTapAPI

  • All Implemented Interfaces:
    com.clevertap.android.sdk.inbox.CTInboxActivity.InboxActivityListener

    
    public class CleverTapAPI
     implements CTInboxActivity.InboxActivityListener
                        
    CleverTapAPIThis is the main CleverTapAPI class that manages the SDK instances
    • Method Detail

      • getDebugLevel

         static int getDebugLevel()

        Returns the log level set for CleverTapAPI

      • setDebugLevel

         static void setDebugLevel(int level)

        Enables or disables debugging. If enabled, see debug messages in Android's logcat utility.Debug messages are tagged as CleverTap.

        Parameters:
        level - Can be one of the following: -1 (disables all debugging), 0 (default, shows minimal SDKintegration related logging),1(shows debug output), 3(shows verbose output)
      • changeCredentials

         static void changeCredentials(String accountID, String token)

        This method is used to change the credentials of CleverTap account Id and token programmatically

        Parameters:
        accountID - CleverTap Account Id
        token - CleverTap Account Token
      • changeCredentials

         static void changeCredentials(String accountID, String token, String region)

        This method is used to change the credentials of CleverTap account Id, token and region programmaticallyOnce the SDK is initialized with a default instance, subsequent calls to this method will be ignored.

        Parameters:
        accountID - CleverTap Account Id
        token - CleverTap Account Token
        region - Clever Tap Account Region
      • changeCredentials

         static void changeCredentials(String accountID, String token, String proxyDomain, String spikyProxyDomain)

        This method is used to change the credentials of CleverTap account Id, token, proxyDomain and spikyProxyDomain programmatically

        Parameters:
        accountID - CleverTap Account Id
        token - CleverTap Account Token
        proxyDomain - CleverTap Proxy Domain
        spikyProxyDomain - CleverTap Spiky Proxy Domain
      • changeCredentials

         static void changeCredentials(String accountID, String token, String proxyDomain, String spikyProxyDomain, String customHandshakeDomain)

        This method is used to change the credentials of CleverTap account Id, token, proxyDomain, spikyProxyDomain programmatically

        Parameters:
        accountID - CleverTap Account Id
        token - CleverTap Account Token
        proxyDomain - CleverTap Proxy Domain
        spikyProxyDomain - CleverTap Spiky Proxy Domain
        customHandshakeDomain - Custom handshake Domain
      • createNotification

         static void createNotification(Context context, Bundle extras, int notificationId)

        Launches an asynchronous task to download the notification icon from CleverTap,and create the Android notification.

        If your app is using CleverTap SDK's built in FCM message handling,this method does not need to be called explicitly.

        Use this method when implementing your own FCM handling mechanism. Refer to theSDK documentation for usage scenarios and examples.

        Note: Starting from core v5.1.0, this method runs on the caller's thread. Make sure to call itin onMessageReceive() of messaging service.

        Parameters:
        context - A reference to an Android context
        extras - The Bundle object received by the broadcast receiver
        notificationId - A custom id to build a notification
      • processPushNotification

         static void processPushNotification(Context context, Bundle extras)

        Pass Push Notification Payload to CleverTap for smooth functioning of Pull Notifications

        Parameters:
        context - - Application Context
        extras - - Bundle received via FCM/Pull Notifications
      • createNotification

         static void createNotification(Context context, Bundle extras)

        Launches an asynchronous task to download the notification icon from CleverTap,and create the Android notification.

        Use this method when implementing your own FCM handling mechanism. Refer to theSDK documentation for usage scenarios and examples.

        Note: Starting from core v5.1.0, this method runs on the caller's thread. Make sure to call itin onMessageReceive() of messaging service.

        Parameters:
        context - A reference to an Android context
        extras - The Bundle object received by the broadcast receiver
      • createNotificationChannel

         static void createNotificationChannel(Context context, String channelId, CharSequence channelName, String channelDescription, int importance, boolean showBadge)

        Launches an asynchronous task to create the notification channel from CleverTap

        Use this method when implementing your own FCM handling mechanism. Refer to theSDK documentation for usage scenarios and examples.
        Parameters:
        context - A reference to an Android context
        channelId - A String for setting the id of the notification channel
        channelName - A String for setting the name of the notification channel
        channelDescription - A String for setting the description of the notification channel
        importance - An Integer value setting the importance of the notifications sent in this channel
        showBadge - An boolean value as to whether this channel shows a badge
      • createNotificationChannel

        @RequiresApi(api = Build.VERSION_CODES.O) static void createNotificationChannel(Context context, String channelId, CharSequence channelName, String channelDescription, int importance, String groupId, boolean showBadge)

        Launches an asynchronous task to create the notification channel from CleverTap

        Use this method when implementing your own FCM handling mechanism and creatingnotification channel groups. Refer to theSDK documentation for usage scenarios and examples.
        Parameters:
        context - A reference to an Android context
        channelId - A String for setting the id of the notification channel
        channelName - A String for setting the name of the notification channel
        channelDescription - A String for setting the description of the notification channel
        importance - An Integer value setting the importance of the notifications sent in thischannel
        groupId - A String for setting the notification channel as a part of a notificationgroup
        showBadge - An boolean value as to whether this channel shows a badge
      • createNotificationChannel

        @RequiresApi(api = Build.VERSION_CODES.O) static void createNotificationChannel(Context context, String channelId, CharSequence channelName, String channelDescription, int importance, boolean showBadge, String sound)

        Launches an asynchronous task to create the notification channel from CleverTap

        Use this method when implementing your own FCM handling mechanism. Refer to theSDK documentation for usage scenarios and examples.
        Parameters:
        context - A reference to an Android context
        channelId - A String for setting the id of the notification channel
        channelName - A String for setting the name of the notification channel
        channelDescription - A String for setting the description of the notification channel
        importance - An Integer value setting the importance of the notifications sent in this channel
        showBadge - An boolean value as to whether this channel shows a badge
        sound - A String denoting the custom sound raw file for this channel
      • createNotificationChannel

        @RequiresApi(api = Build.VERSION_CODES.O) static void createNotificationChannel(Context context, String channelId, CharSequence channelName, String channelDescription, int importance, String groupId, boolean showBadge, String sound)

        Launches an asynchronous task to create the notification channel from CleverTap

        Use this method when implementing your own FCM handling mechanism and creatingnotification channel groups. Refer to theSDK documentation for usage scenarios and examples.
        Parameters:
        context - A reference to an Android context
        channelId - A String for setting the id of the notification channel
        channelName - A String for setting the name of the notification channel
        channelDescription - A String for setting the description of the notification channel
        importance - An Integer value setting the importance of the notifications sent in thischannel
        groupId - A String for setting the notification channel as a part of a notificationgroup
        showBadge - An boolean value as to whether this channel shows a badge
        sound - A String denoting the custom sound raw file for this channel
      • createNotificationChannelGroup

        @RequiresApi(api = Build.VERSION_CODES.O) static void createNotificationChannelGroup(Context context, String groupId, CharSequence groupName)

        Launches an asynchronous task to create the notification channel group from CleverTap

        Use this method when implementing your own FCM handling mechanism. Refer to theSDK documentation for usage scenarios and examples.
        Parameters:
        context - A reference to an Android context
        groupId - A String for setting the id of the notification channel group
        groupName - A String for setting the name of the notification channel group
      • deleteNotificationChannel

        @RequiresApi(api = Build.VERSION_CODES.O) static void deleteNotificationChannel(Context context, String channelId)

        Launches an asynchronous task to delete the notification channel from CleverTap

        Use this method when implementing your own FCM handling mechanism. Refer to theSDK documentation for usage scenarios and examples.
        Parameters:
        context - A reference to an Android context
        channelId - A String for setting the id of the notification channel
      • deleteNotificationChannelGroup

        @RequiresApi(api = Build.VERSION_CODES.O) static void deleteNotificationChannelGroup(Context context, String groupId)

        Launches an asynchronous task to delete the notification channel from CleverTap

        Use this method when implementing your own FCM handling mechanism. Refer to theSDK documentation for usage scenarios and examples.
        Parameters:
        context - A reference to an Android context
        groupId - A String for setting the id of the notification channel group
      • getDefaultInstance

         static CleverTapAPI getDefaultInstance(Context context, String cleverTapID)

        Returns the default shared instance of the CleverTap SDK.

        Parameters:
        context - The Android context
        cleverTapID - Custom CleverTapID passed by the app
      • isAppForeground

         static boolean isAppForeground()

        Returns whether or not the app is in the foreground.

      • setAppForeground

         static void setAppForeground(boolean appForeground)

        Use this method to notify CleverTap that the app is in foreground

        Parameters:
        appForeground - boolean true/false
      • registerCustomInAppTemplates

         static synchronized void registerCustomInAppTemplates(TemplateProducer producer)

        Register CustomTemplates through a TemplateProducer. See CustomTemplate.Builder. Templates must be registered before the CleverTapAPI instance, that would usethem, is created. A common place for this initialization is in onCreate. If yourapplication uses multiple CleverTapAPI instances, use the CleverTapInstanceConfig within theTemplateProducer to differentiate which templates should be registered to which CleverTapAPI instances.This method can be called multiple times with different TemplateProducers, however all of theproduced templates must have unique names.Example usage:Java:

        CleverTapAPI.registerCustomInAppTemplates(ctConfig -> CustomTemplatesExtKt.templatesSet(
                        new CustomTemplate.TemplateBuilder()
                                .name("template")
                                .presenter()
                                .stringArgument("string", "Text")
                                .build()));
        
        Kotlin:
        CleverTapAPI.registerCustomInAppTemplates {
            setOf(
                template {
                    name("template")
                    presenter()
                    stringArgument("string", "Text")
                })
        }
        
        Parameters:
        producer - The TemplateProducer that would create a set of templates
      • registerCustomInAppTemplates

         static synchronized void registerCustomInAppTemplates(@NonNull() String templatesJson, @Nullable() TemplatePresenter templatesPresenter, @Nullable() FunctionPresenter functionsPresenter)

        Register CustomTemplates through ajson definition. Templates must be registered before the CleverTapAPI instance, that would usethem, is created. A common place for this initialization is in onCreate. If yourapplication uses multiple CleverTapAPI instances, extend JsonTemplatesProducer with definitions for each instance and register using registerCustomInAppTemplates.Use the CleverTapInstanceConfig in defineTemplates to controlfor which instance the templates should be registered.This method can be called multiple times with different json definitions and presenters,however all of the templates must have unique names.

        Parameters:
        templatesJson - A string with the json definitions of templates.
        templatesPresenter - A presenter for all templates in the json definitions.Required if there is at least one template with type "template".
        functionsPresenter - A presenter for all functions in the json definitions.Required if there is at least one template with type "function".
      • syncRegisteredInAppTemplates

         void syncRegisteredInAppTemplates()

        Sync all currently registered templates (through registerCustomInAppTemplates to thebackend. Use this method to transfer template definitions from the SDK to the CT dashboard. This method canonly be called from a debug build of the application and the current logged-in user must be marked as atest profile through the web dashboard.

      • isPushPermissionGranted

         boolean isPushPermissionGranted()

        Checks whether notification permission is granted or denied for Android 13 and above devices.

      • promptPushPrimer

         void promptPushPrimer(JSONObject jsonObject)

        Calls the push primer flow for Android 13 and above devices.

        Parameters:
        jsonObject - JSONObject - Accepts jsonObject created by CTLocalInApp object
      • promptForPushPermission

         void promptForPushPermission(boolean showFallbackSettings)

        Calls directly hard permission dialog, if push primer is not required.

        Parameters:
        showFallbackSettings - - boolean - If `showFallbackSettings` is true then we show a alertdialog which routes to app's notification settings page.
      • addMultiValueForKey

         void addMultiValueForKey(String key, String value)

        Add a unique value to a multi-value user profile propertyIf the property does not exist it will be created

        Max 100 values, on reaching 100 cap, oldest value(s) will be removed.Values must be Strings and are limited to 512 characters.If the key currently contains a scalar value, the key will be promoted to a multi-value propertywith the current value cast to a string and the new value(s) added
        Parameters:
        key - String
        value - String
      • addMultiValuesForKey

         void addMultiValuesForKey(String key, ArrayList<String> values)

        Add a collection of unique values to a multi-value user profile propertyIf the property does not exist it will be created

        Max 100 values, on reaching 100 cap, oldest value(s) will be removed.Values must be Strings and are limited to 512 characters.If the key currently contains a scalar value, the key will be promoted to a multi-value propertywith the current value cast to a string and the new value(s) added
        Parameters:
        key - String
        values - ArrayList with String values
      • disablePersonalization

         void disablePersonalization()

        Disables the Profile/Events Read and Synchronization APIPersonalization is enabled by default

      • discardInAppNotifications

         void discardInAppNotifications()

        Suspends the display of InApp Notifications and discards any new InApp Notifications to be shownafter this method is called.The InApp Notifications will be displayed only once resumeInAppNotifications() is called.

      • enableDeviceNetworkInfoReporting

         void enableDeviceNetworkInfoReporting(boolean value)

        Use this method to enable device network-related information tracking, including IP address.This reporting is disabled by default. To re-disable tracking call this method with enabled set to false.

        Parameters:
        value - boolean Whether device network info reporting should be enabled/disabled.
      • enablePersonalization

         void enablePersonalization()

        Enables the Profile/Events Read and Synchronization APIPersonalization is enabled by default

      • flush

         void flush()

        Sends all the events in the event queue.

      • decrementValue

         void decrementValue(String key, Number value)

        This method is used to decrement the given valueNumber should be in positive range

        Parameters:
        key - String
        value - Number
      • getCount

        @Deprecated(since = 7.1.0) int getCount(String event)

        Returns the total count of the specified event

        Parameters:
        event - The event for which you want to get the total count
      • getUserEventLogCount

        @WorkerThread() int getUserEventLogCount(String eventName)

        Retrieves the count of logged events for a specific event name associated with the currentuser/CleverTap ID.This operation involves a database query and should be called from a background thread.Example usage:// Call from background thread int itemSelectedCount = getUserEventLogCount("item_selected")

        Parameters:
        eventName - Name of the event to get the count for (e.g.
      • getDetails

        @Deprecated(since = 7.1.0) EventDetail getDetails(String event)

        Returns an EventDetail object for the particular event passed. EventDetail consists of event name, count, firsttimeand last time timestamp of the event.

        Parameters:
        event - The event name for which you want the Event details
      • getUserEventLog

        @WorkerThread() UserEventLog getUserEventLog(String eventName)

        Retrieves user-specific event log associated with the current user/ CleverTap ID.This operation involves a database query and should be called from a background thread.Example usage:// Call from background thread UserEventLog log = getUserEventLog("navigation_clicked") long firstOccurrence = log.firstTs

        Parameters:
        eventName - Name of the event to get the log for (e.g.
      • getFirstTime

        @Deprecated(since = 7.1.0) int getFirstTime(String event)

        Returns the timestamp of the first time the given event was raised

        Parameters:
        event - The event name for which you want the first time timestamp
      • setGeofenceCallback

         void setGeofenceCallback(GeofenceCallback geofenceCallback)

        This method is used to set the geofence callbackRegister to handle geofence responses from CleverTapThis is to be used only by clevertap-geofence-sdk

        Parameters:
        geofenceCallback - The GeofenceCallback instance
      • getUserEventLogHistory

        @WorkerThread() Map<String, UserEventLog> getUserEventLogHistory()

        Retrieves history of all event logs associated with the current user/CleverTap ID in the ascending order of lastTs.This operation involves a database query and should be called from a background thread.Example usage:// Call from background thread Map<String, UserEventLog> history = getUserEventLogHistory()

      • getInboxMessageCount

         int getInboxMessageCount()

        Returns the count of all inbox messages for the user

      • getInboxMessageUnreadCount

         int getInboxMessageUnreadCount()

        Returns the count of total number of unread inbox messages for the user

      • getLastTime

        @Deprecated(since = 7.1.0) int getLastTime(String event)

        Returns the timestamp of the last time the given event was raised

        Parameters:
        event - The event name for which you want the last time timestamp
      • getLocation

         Location getLocation()

        get the current device locationrequires Location Permission in AndroidManifest e.g. "android.permission.ACCESS_COARSE_LOCATION"You can then use the returned Location value to update the user profile location in CleverTap via

      • setLocation

         void setLocation(Location location)

        set the user profile location in CleverTaplocation can then be used for geo-segmentation etc.

        Parameters:
        location - android.location.
      • getUserLastVisitTs

         long getUserLastVisitTs()

        Retrieves timestamp of last visit by current user/CleverTap ID.Example usage:long lastVisitTs = getUserLastVisitTs()

      • getProperty

         Object getProperty(String name)

        Return the user profile property value for the specified key.Date related property values are returned as number of seconds since January 1, 1970, 00:00:00 GMT

        Parameters:
        name - String
      • getScreenCount

         int getScreenCount()

        Returns the number of screens which have been displayed by the app

      • getTimeElapsed

         int getTimeElapsed()

        Returns the time elapsed by the user on the app

      • getTotalVisits

        @Deprecated(since = 7.1.0) int getTotalVisits()

        Returns the total number of times the app has been launched

      • getUserAppLaunchCount

        @WorkerThread() int getUserAppLaunchCount()

        Retrieves number of times app launched by current user/CleverTap ID.This operation involves a database query and should be called from a background thread.Example usage:// Call from background thread int launchCount = getUserAppLaunchCount()

      • getUTMDetails

         UTMDetail getUTMDetails()

        Returns a UTMDetail object which consists of UTM parameters like source, medium & campaign

      • onUserLogin

         void onUserLogin(Map<String, Object> profile, String cleverTapID)

        Creates a separate and distinct user profile identified by one or more of Identity,Email, FBID or GPID values,and populated with the key-values included in the profile map argument.

        If your app is used by multiple users, you can use this method to assign them each aunique profile to track them separately.

        If instead you wish to assign multiple Identity, Email, FBID and/or GPID values to the sameuser profile,use profile.push rather than this method.

        If none of Identity, Email, FBID or GPID is included in the profile map,all profile map values will be associated with the current user profile.

        When initially installed on this device, your app is assigned an "anonymous" profile.The first time you identify a user on this device (whether via onUserLogin or profilePush),the "anonymous" history on the device will be associated with the newly identified user.

        Then, use this method to switch between subsequent separate identified users.

        Please note that switching from one identified user to another is a costly operationin that the current session for the previous user is automatically closedand data relating to the old user removed, and a new session is startedfor the new user and data for that user refreshed via a network call to CleverTap.In addition, any global frequency caps are reset as part of the switch.

        Parameters:
        profile - The map keyed by the type of identity, with the value as the identity
        cleverTapID - Custom CleverTap ID passed by the App
      • onUserLogin

         void onUserLogin(Map<String, Object> profile)

        Creates a separate and distinct user profile identified by one or more of Identity,Email, FBID or GPID values,and populated with the key-values included in the profile map argument.

        If your app is used by multiple users, you can use this method to assign them each aunique profile to track them separately.

        If instead you wish to assign multiple Identity, Email, FBID and/or GPID values to the sameuser profile,use profile.push rather than this method.

        If none of Identity, Email, FBID or GPID is included in the profile map,all profile map values will be associated with the current user profile.

        When initially installed on this device, your app is assigned an "anonymous" profile.The first time you identify a user on this device (whether via onUserLogin or profilePush),the "anonymous" history on the device will be associated with the newly identified user.

        Then, use this method to switch between subsequent separate identified users.

        Please note that switching from one identified user to another is a costly operationin that the current session for the previous user is automatically closedand data relating to the old user removed, and a new session is startedfor the new user and data for that user refreshed via a network call to CleverTap.In addition, any global frequency caps are reset as part of the switch.

        Parameters:
        profile - The map keyed by the type of identity, with the value as the identity
      • productConfig

        @Deprecated() CTProductConfigController productConfig()

        Note: This method has been deprecated since v5.0.0 and will be removed in the future versions of this SDK.

        The handle for product config functionalities(fetch/activate etc.)
      • pushDeepLink

         void pushDeepLink(Uri uri)

        Use this method to pass the deeplink with UTM parameters to track installs

        Parameters:
        uri - URI of the deeplink
      • pushError

         void pushError(String errorMessage, int errorCode)

        Internally records an "Error Occurred" event, which can be viewed in the dashboard.

        Parameters:
        errorMessage - The error message
        errorCode - The error code
      • pushEvent

         void pushEvent(String eventName)

        Pushes a basic event.

        Parameters:
        eventName - The name of the event
      • pushFcmRegistrationId

         void pushFcmRegistrationId(String fcmId, boolean register)

        Sends the FCM registration ID to CleverTap.

        Parameters:
        fcmId - The FCM registration ID
        register - Boolean indicating whether to registeror not for receiving push messages from CleverTap.Set this to true to receive push messages from CleverTap,and false to not receive any messages from CleverTap.
      • pushSignedCallEvent

         Future<out Object> pushSignedCallEvent(String eventName, JSONObject eventProperties)

        Pushes a Signed Call event to CleverTap with a set of attribute pairs.

        Parameters:
        eventName - The name of the event
        eventProperties - The JSONObject object that contains theevent properties regarding Signed Call event
      • pushGeoFenceError

         void pushGeoFenceError(int errorCode, String errorMessage)

        Used to record errors of the Geofence module

        Parameters:
        errorCode - - int - predefined error code for geofences
        errorMessage - - String - error message
      • pushGeoFenceExitedEvent

         Future<out Object> pushGeoFenceExitedEvent(JSONObject geoFenceProperties)

        Pushes the Geofence Cluster Exited event to CleverTap.

        Parameters:
        geoFenceProperties - The JSONObject object that contains theevent properties regarding GeoFence Cluster Exited event
      • pushGeofenceEnteredEvent

         Future<out Object> pushGeofenceEnteredEvent(JSONObject geofenceProperties)

        Pushes the Geofence Cluster Entered event to CleverTap.

        Parameters:
        geofenceProperties - The JSONObject object that contains theevent properties regarding GeoFence Cluster Entered event
      • pushInstallReferrer

         void pushInstallReferrer(String url)

        This method is used to push install referrer via url String

        Parameters:
        url - A String with the install referrer parameters
      • pushInstallReferrer

         synchronized void pushInstallReferrer(String source, String medium, String campaign)

        This method is used to push install referrer via UTM source, medium & campaign parameters

        Parameters:
        source - The UTM source parameter
        medium - The UTM medium parameter
        campaign - The UTM campaign parameter
      • pushNotificationClickedEvent

         void pushNotificationClickedEvent(Bundle extras)

        Pushes the Notification Clicked event to CleverTap.

        Parameters:
        extras - The Bundle object that contains thenotification details
      • pushNotificationViewedEvent

         void pushNotificationViewedEvent(Bundle extras)

        Pushes the Notification Viewed event to CleverTap.

        Parameters:
        extras - The Bundle object that contains thenotification details
      • recordScreen

         void recordScreen(String screenName)

        Record a Screen View event

        Parameters:
        screenName - String, the name of the screen
      • removeMultiValueForKey

         void removeMultiValueForKey(String key, String value)

        Remove a unique value from a multi-value user profile property

        If the key currently contains a scalar value, prior to performing the remove operationthe key will be promoted to a multi-value property with the current value cast to a string.If the multi-value property is empty after the remove operation, the key will be removed.
        Parameters:
        key - String
        value - String
      • removeMultiValuesForKey

         void removeMultiValuesForKey(String key, ArrayList<String> values)

        Remove a collection of unique values from a multi-value user profile property

        If the key currently contains a scalar value, prior to performing the remove operationthe key will be promoted to a multi-value property with the current value cast to a string.If the multi-value property is empty after the remove operation, the key will be removed.
        Parameters:
        key - String
        values - ArrayList with String values
      • removeValueForKey

         void removeValueForKey(String key)

        Remove the user profile property value specified by key from the user profile. Alternatively this methodcan also be used to remove PII data (for eg. Email,Name,Phone), locally from database and shared prefs

        Parameters:
        key - String
      • resumeInAppNotifications

         void resumeInAppNotifications()

        Resumes display of InApp Notifications.

        If suspendInAppNotifications() was called previously, calling this method will instantly showall queued InApp Notifications and also resume InApp Notifications on events raised after thismethod is called.

        If discardInAppNotifications() was called previously, calling this method will only resumeInApp Notifications on events raised after this method is called.

      • incrementValue

         void incrementValue(String key, Number value)

        This method is used to increment the given value.

        Number should be in positive range.

        Parameters:
        key - String
        value - Number
      • setLibrary

         void setLibrary(String library)

        Not to be used by developers. This is used internally to help CleverTap know which library is wrapping thenative SDK

        Parameters:
        library - String library name
      • setMultiValuesForKey

         void setMultiValuesForKey(String key, ArrayList<String> values)

        Set a collection of unique values as a multi-value user profile property, any existing value will beoverwritten.Max 100 values, on reaching 100 cap, oldest value(s) will be removed.Values must be Strings and are limited to 512 characters.

        Parameters:
        key - String
        values - ArrayList with String values
      • setOffline

         void setOffline(boolean value)

        If you want to stop recorded events from being sent to the server, use this method to set the SDK instance tooffline.Once offline, events will be recorded and queued locally but will not be sent to the server until offline isdisabled.Calling this method again with offline set to false will allow events to be sent to server and the SDK instancewill immediately attempt to send events that have been queued while offline.

        Parameters:
        value - boolean, true sets the sdk offline, false sets the sdk back online
      • setOptOut

         void setOptOut(boolean userOptOut)

        Use this method to opt the current user out of all event/profile tracking.You must call this method separately for each active user profile (e.g. when switching user profiles usingonUserLogin).Once enabled, no events will be saved remotely or locally for the current user. To re-enable tracking call thismethod with enabled set to false.

        Parameters:
        userOptOut - boolean Whether tracking opt out should be enabled/disabled.
      • setOptOut

         void setOptOut(boolean userOptOut, boolean allowSystemEvents)

        Use this method to manage the user's consent for event and profile tracking.You must call this method separately for each active user profile (e.g., when switching user profiles usingonUserLogin).This method supports the following consent management scenarios:

        • Complete Opt-Out (userOptOut = true, allowSystemEvents = false):No events (neither custom nor system) will be saved remotely or locally for the current user.This provides the highest level of privacy.
        • Full Opt-In (userOptOut = false, allowSystemEvents = true):All events (custom and system) will be tracked and saved. This is the default behaviorif no opt-out preferences are set.
        • Partial Opt-In (userOptOut = true, allowSystemEvents = true):Only system-level CleverTap events (e.g., app launch, notification viewed) will be tracked.Custom events raised by the client application will be filtered out.
        Note: The case where `userOptOut = false` and `allowSystemEvents = false` is invalid.If this combination is provided, the SDK will default to the "Full Opt-In" behavior(userOptOut = false, allowSystemEvents = true).To re-enable full tracking after any form of opt-out, call this method with `userOptOut = false` and `allowSystemEvents = true`.
        Parameters:
        userOptOut - boolean: Set to `true` to opt the user out of custom event tracking.Set to `false` to opt the user into custom event tracking.
        allowSystemEvents - boolean: Set to `true` to allow system-level CleverTap events.Set to `false` to disallow system-level CleverTap events (only if `userOptOut` is also `true`).
      • dismissAppInbox

         void dismissAppInbox()

        Dismisses the App Inbox Activity if already opened

      • suspendInAppNotifications

         void suspendInAppNotifications()

        Suspends display of InApp Notifications.The InApp Notifications are queued once this method is calledand will be displayed once resumeInAppNotifications() is called.

      • getCleverTapID

         void getCleverTapID(@NonNull() OnInitCleverTapIDListener onInitCleverTapIDListener)

        Subscribe to receive a unique identifier by which CleverTap identifies this user. The listener is called on themain thread and it is invoked each time the id changes until the listener is removed through removeCleverTapIDListener

        Parameters:
        onInitCleverTapIDListener - non-null callback to retrieve identifier on main thread.
      • getNotificationBitmapWithTimeoutAndSize

        @Nullable() static Bitmap getNotificationBitmapWithTimeoutAndSize(Context context, Bundle bundle, String bitmapSrcUrl, boolean fallbackToAppIcon, long timeoutInMillis, int sizeInBytes)

        Retrieves a notification bitmap with a specified timeout and size constraint.

        Parameters:
        context - The context of the application.
        bundle - The Bundle object received by the push receiver.
        bitmapSrcUrl - The URL of the bitmap to download.
        fallbackToAppIcon - Specifies whether to fallback to the app icon if the bitmap is not available.
        timeoutInMillis - The timeout duration for the bitmap download in milliseconds.
        sizeInBytes - The maximum size of the bitmap in bytes.
      • getNotificationBitmapWithTimeout

        @Nullable() static Bitmap getNotificationBitmapWithTimeout(Context context, Bundle bundle, String bitmapSrcUrl, boolean fallbackToAppIcon, long timeoutInMillis)

        Retrieves a notification bitmap with a specified timeout.

        Parameters:
        context - The context of the application.
        bundle - The Bundle object received by the push receiver.
        bitmapSrcUrl - The URL of the bitmap to download.
        fallbackToAppIcon - Specifies whether to fallback to the app icon if the bitmap is not available.
        timeoutInMillis - The timeout duration for the bitmap download in milliseconds.
      • defineVariable

         <T> Var<T> defineVariable(String name, T defaultValue)

        Defines a new variable. If the default vale is null it won't resolve the type properly. Inthat case it is better to use the @Variable annotation instead of this method.

        Parameters:
        name - Name of the variable.
        defaultValue - Default value of variable, used when resolving the underlying value type.
      • defineFileVariable

         Var<String> defineFileVariable(String name)

        Defines a new file variable. Disclaimer: cannot be used with @Variable annotation.

        Parameters:
        name - Name of the variable.
      • parseVariables

         void parseVariables(Array<Object> instances)

        Parses the @Variable annotated fields from a given instance or multiple instances.

        Parameters:
        instances - Instance or instances to parse.
      • parseVariablesForClasses

         void parseVariablesForClasses(Array<Class<out Object>> classes)

        Parses the @Variable annotated static fields from a given class or multiple classes.

        Parameters:
        classes - Class object or objects to parse.
      • getVariableValue

         Object getVariableValue(String name)

        Get a copy of the current value of a variable or a group.

        Parameters:
        name - The name of the variable or the group.
      • getVariable

         <T> Var<T> getVariable(String name)

        Get an instance of a variable or a group.

        Parameters:
        name - The name of the variable or the group.
      • fetchVariables

         void fetchVariables()

        Fetches variable values from server.

      • fetchVariables

         void fetchVariables(FetchVariablesCallback callback)

        Fetches variable values from server.Note that SDK keeps only one registered callback, if you call that method again it wouldoverride the callback.

        Parameters:
        callback - Callback instance to be invoked when fetching is done.
      • syncVariables

         void syncVariables()

        Uploads variables to server.

      • setLocale

         void setLocale(String locale)

        Use this method to set a custom locale for the current CleverTap instance

        Parameters:
        locale - - The custom locale to be set
      • getLocale

         String getLocale()

        Returns the custom locale set for the current CleverTap instance

      • clearInAppResources

        @WorkerThread() void clearInAppResources(boolean expiredOnly)

        Deletes all images and gifs which are preloaded for inapps in cs mode

        Parameters:
        expiredOnly - to clear only assets which will not be needed further for inapps
      • clearFileResources

        @WorkerThread() void clearFileResources(boolean expiredOnly)

        Deletes all types of files which are preloaded for SDK features like custom in-app templates, app functions andvariables etc.

        Parameters:
        expiredOnly - to clear only files which will not be needed further for SDK features like custom in-apptemplates, app functions and variables etc.
      • pushRegistrationToken

         void pushRegistrationToken(String token, PushType pushType, boolean register)

        Sends push registration token for the given push type

        Parameters:
        token - The token
        pushType - Push Provider type for which the token is registered
        register - Boolean indicating whether to registeror not for receiving push messages from CleverTap.Set this to true to receive push messages from CleverTap,and false to not receive any messages from CleverTap.