-
- 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceCleverTapAPI.DevicePushTokenRefreshListenerImplement to get called back when the device push token is refreshed
public interfaceCleverTapAPI.RequestDevicePushTokenListenerImplement to get called back when the device push token is received
public enumCleverTapAPI.LogLevel
-
Field Summary
Fields Modifier and Type Field Description public final static StringNOTIFICATION_TAGprivate static intdebugLevelprivate static HashMap<String, CleverTapAPI>instancesprivate CoreStatecoreStateprivate WeakReference<InboxMessageButtonListener>inboxMessageButtonListener
-
Method Summary
Modifier and Type Method Description static intgetDebugLevel()Returns the log level set for CleverTapAPI static voidsetDebugLevel(int level)Enables or disables debugging. static HashMap<String, CleverTapAPI>getInstances()static voidsetInstances(HashMap<String, CleverTapAPI> instances)CoreStategetCoreState()voidsetCoreState(CoreState cleverTapState)voidsetInboxMessageButtonListener(InboxMessageButtonListener listener)static voidchangeCredentials(String accountID, String token)This method is used to change the credentials of CleverTap account Id and token programmatically static voidchangeCredentials(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. static voidchangeCredentials(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 static voidchangeCredentials(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 static voidcreateNotification(Context context, Bundle extras, int notificationId)Launches an asynchronous task to download the notification icon from CleverTap,and create the Android notification. static CleverTapAPIgetGlobalInstance(Context context, String _accountId)static voidprocessPushNotification(Context context, Bundle extras)Pass Push Notification Payload to CleverTap for smooth functioning of Pull Notifications static voidcreateNotification(Context context, Bundle extras)Launches an asynchronous task to download the notification icon from CleverTap,and create the Android notification. static voidcreateNotificationChannel(Context context, String channelId, CharSequence channelName, String channelDescription, int importance, boolean showBadge)Launches an asynchronous task to create the notification channel from CleverTapUse this method when implementing your own FCM handling mechanism. static voidcreateNotificationChannel(Context context, String channelId, CharSequence channelName, String channelDescription, int importance, String groupId, boolean showBadge)Launches an asynchronous task to create the notification channel from CleverTapUse this method when implementing your own FCM handling mechanism and creatingnotification channel groups. static voidcreateNotificationChannel(Context context, String channelId, CharSequence channelName, String channelDescription, int importance, boolean showBadge, String sound)Launches an asynchronous task to create the notification channel from CleverTapUse this method when implementing your own FCM handling mechanism. static voidcreateNotificationChannel(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 CleverTapUse this method when implementing your own FCM handling mechanism and creatingnotification channel groups. static voidcreateNotificationChannelGroup(Context context, String groupId, CharSequence groupName)Launches an asynchronous task to create the notification channel group from CleverTapUse this method when implementing your own FCM handling mechanism. static voiddeleteNotificationChannel(Context context, String channelId)Launches an asynchronous task to delete the notification channel from CleverTapUse this method when implementing your own FCM handling mechanism. static voiddeleteNotificationChannelGroup(Context context, String groupId)Launches an asynchronous task to delete the notification channel from CleverTapUse this method when implementing your own FCM handling mechanism. static voidfcmTokenRefresh(Context context, String token)static CleverTapAPIgetDefaultInstance(Context context, String cleverTapID)Returns the default shared instance of the CleverTap SDK. static CleverTapAPIgetDefaultInstance(Context context)Returns the default shared instance of the CleverTap SDK. static NotificationInfogetNotificationInfo(Bundle extras)Checks whether this notification is from CleverTap. static voidhandleNotificationClicked(Context context, Bundle notification)static CleverTapAPIinstanceWithConfig(Context context, @NonNull() CleverTapInstanceConfig config)Returns an instance of the CleverTap SDK using CleverTapInstanceConfig. static CleverTapAPIinstanceWithConfig(Context context, @NonNull() CleverTapInstanceConfig config, String cleverTapID)Returns an instance of the CleverTap SDK using CleverTapInstanceConfig. static booleanisAppForeground()Returns whether or not the app is in the foreground. static voidsetAppForeground(boolean appForeground)Use this method to notify CleverTap that the app is in foreground static voidonActivityPaused()static voidonActivityResumed(Activity activity)static voidonActivityResumed(Activity activity, String cleverTapID)static voidrunJobWork(Context context)static voidtokenRefresh(Context context, String token, PushType pushType)static synchronized voidregisterCustomInAppTemplates(TemplateProducer producer)Register CustomTemplates through a TemplateProducer. static synchronized voidregisterCustomInAppTemplates(@NonNull() String templatesJson, @Nullable() TemplatePresenter templatesPresenter, @Nullable() FunctionPresenter functionsPresenter)Register CustomTemplates through ajson definition. CustomTemplateContextgetActiveContextForTemplate(@NonNull() String templateName)Retrieve a CustomTemplateContext for a template that is currently displaying. voidsyncRegisteredInAppTemplates()Sync all currently registered templates (through registerCustomInAppTemplates to thebackend. booleanisPushPermissionGranted()Checks whether notification permission is granted or denied for Android 13 and above devices. voidpromptPushPrimer(JSONObject jsonObject)Calls the push primer flow for Android 13 and above devices. voidpromptForPushPermission(boolean showFallbackSettings)Calls directly hard permission dialog, if push primer is not required. voidaddMultiValueForKey(String key, String value)Add a unique value to a multi-value user profile propertyIf the property does not exist it will be createdMax 100 values, on reaching 100 cap, oldest value(s) will be removed.Values must be Strings and are limited to 512 characters. voidaddMultiValuesForKey(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 createdMax 100 values, on reaching 100 cap, oldest value(s) will be removed.Values must be Strings and are limited to 512 characters. voiddeleteInboxMessage(CTInboxMessage message)Deletes the given CTInboxMessage object voiddeleteInboxMessage(String messageId)Deletes the CTInboxMessage object for given messageId voiddeleteInboxMessagesForIDs(ArrayList<String> messageIDs)Deletes multiple CTInboxMessage objects for given list of messageIDs voiddisablePersonalization()Disables the Profile/Events Read and Synchronization APIPersonalization is enabled by default voiddiscardInAppNotifications()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. voidenableDeviceNetworkInfoReporting(boolean value)Use this method to enable device network-related information tracking, including IP address.This reporting is disabled by default. voidenablePersonalization()Enables the Profile/Events Read and Synchronization APIPersonalization is enabled by default CTFeatureFlagsControllerfeatureFlag()Note: This method has been deprecated since v5.0.0 and will be removed in the future versions of this SDK. voidflush()Sends all the events in the event queue. voidsetSCDomainListener(SCDomainListener scDomainListener)This method is used to set the SCDomain callback. StringgetAccountId()ArrayList<CleverTapDisplayUnit>getAllDisplayUnits()Getter for retrieving all the Display Units. ArrayList<CTInboxMessage>getAllInboxMessages()Returns an ArrayList of all CTInboxMessage objects CTInboxListenergetCTNotificationInboxListener()Returns the CTInboxListener object voidsetCTNotificationInboxListener(CTInboxListener notificationInboxListener)This method sets the CTInboxListener CTPushAmpListenergetCTPushAmpListener()Returns the CTPushAmpListener object voidsetCTPushAmpListener(CTPushAmpListener pushAmpListener)This method is used to set the CTPushAmpListener CTPushNotificationListenergetCTPushNotificationListener()Returns the CTPushNotificationListener object voidsetCTPushNotificationListener(CTPushNotificationListener pushNotificationListener)This method is used to set the CTPushNotificationListener StringgetCleverTapAttributionIdentifier()Returns a unique CleverTap identifier suitable for use with install attribution providers. StringgetCleverTapID()Returns a unique identifier by which CleverTap identifies this user. voiddecrementValue(String key, Number value)This method is used to decrement the given valueNumber should be in positive range intgetCount(String event)Returns the total count of the specified event intgetUserEventLogCount(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. EventDetailgetDetails(String event)Returns an EventDetail object for the particular event passed. UserEventLoggetUserEventLog(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. StringgetDevicePushToken(PushType type)Returns the device push token or null CleverTapAPI.DevicePushTokenRefreshListenergetDevicePushTokenRefreshListener()Returns the DevicePushTokenRefreshListener voidsetDevicePushTokenRefreshListener(CleverTapAPI.DevicePushTokenRefreshListener tokenRefreshListener)This method is used to set the DevicePushTokenRefreshListener object voidsetRequestDevicePushTokenListener(CleverTapAPI.RequestDevicePushTokenListener requestTokenListener)This method is used to set the RequestDevicePushTokenListener object CleverTapDisplayUnitgetDisplayUnitForId(String unitID)Getter for retrieving Display Unit using the unitID intgetFirstTime(String event)Returns the timestamp of the first time the given event was raised GeofenceCallbackgetGeofenceCallback()Returns the GeofenceCallback object voidsetGeofenceCallback(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 Map<String, EventDetail>getHistory()Returns a Map of event names and corresponding event details of all the events raised 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. InAppNotificationListenergetInAppNotificationListener()Returns the InAppNotificationListener object voidsetInAppNotificationListener(InAppNotificationListener inAppNotificationListener)This method sets the InAppNotificationListener voidunregisterPushPermissionNotificationResponseListener(PushPermissionResponseListener pushPermissionResponseListener)This method unregisters the given instance of the PushPermissionResponseListener ifpreviously registered. voidregisterPushPermissionNotificationResponseListener(PushPermissionResponseListener pushPermissionResponseListener)This method registers the PushPermissionNotificationResponseListener. intgetInboxMessageCount()Returns the count of all inbox messages for the user CTInboxMessagegetInboxMessageForId(String messageId)Returns the CTInboxMessage object that belongs to the given message id intgetInboxMessageUnreadCount()Returns the count of total number of unread inbox messages for the user intgetLastTime(String event)Returns the timestamp of the last time the given event was raised LocationgetLocation()get the current device locationrequires Location Permission in AndroidManifest e.g. voidsetLocation(Location location)set the user profile location in CleverTaplocation can then be used for geo-segmentation etc. intgetPreviousVisitTime()Returns the timestamp of the previous visit longgetUserLastVisitTs()Retrieves timestamp of last visit by current user/CleverTap ID. ObjectgetProperty(String name)Return the user profile property value for the specified key. StringgetPushToken(@NonNull() PushType pushType)Returns the token for a particular push type intgetScreenCount()Returns the number of screens which have been displayed by the app SyncListenergetSyncListener()Returns the SyncListener object voidsetSyncListener(SyncListener syncListener)This method is used to set the SyncListener intgetTimeElapsed()Returns the time elapsed by the user on the app intgetTotalVisits()Returns the total number of times the app has been launched intgetUserAppLaunchCount()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. UTMDetailgetUTMDetails()Returns a UTMDetail object which consists of UTM parameters like source, medium & campaign ArrayList<CTInboxMessage>getUnreadInboxMessages()Returns an ArrayList of unread CTInboxMessage objects voidinitializeInbox()Initializes the inbox controller and sends a callback to the CTInboxListener This method needs to be called separately for each instance of CleverTapAPI voidmarkReadInboxMessage(CTInboxMessage message)Marks the given CTInboxMessage object as read voidmarkReadInboxMessage(String messageId)Marks the given messageId of CTInboxMessage object as read voidmarkReadInboxMessagesForIDs(ArrayList<String> messageIDs)Marks multiple CTInboxMessage objects as read for given list of messageIDs voidmessageDidClick(CTInboxActivity ctInboxActivity, int contentPageIndex, CTInboxMessage inboxMessage, Bundle data, HashMap<String, String> keyValue, int buttonIndex)voidmessageDidShow(CTInboxActivity ctInboxActivity, CTInboxMessage inboxMessage, Bundle data)voidonUserLogin(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. voidonUserLogin(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. CTProductConfigControllerproductConfig()Note: This method has been deprecated since v5.0.0 and will be removed in the future versions of this SDK. voidpushChargedEvent(HashMap<String, Object> chargeDetails, ArrayList<HashMap<String, Object>> items)Push Charged event, which describes a purchase made. voidpushDeepLink(Uri uri)Use this method to pass the deeplink with UTM parameters to track installs voidpushDisplayUnitClickedEventForID(String unitID)Raises the Display Unit Clicked event voidpushDisplayUnitViewedEventForID(String unitID)Raises the Display Unit Viewed event voidpushError(String errorMessage, int errorCode)Internally records an "Error Occurred" event, which can be viewed in the dashboard. voidpushEvent(String eventName)Pushes a basic event. voidpushEvent(String eventName, Map<String, Object> eventActions)Push an event with a set of attribute pairs. voidpushFcmRegistrationId(String fcmId, boolean register)Sends the FCM registration ID to CleverTap. Future<out Object>pushSignedCallEvent(String eventName, JSONObject eventProperties)Pushes a Signed Call event to CleverTap with a set of attribute pairs. voidpushGeoFenceError(int errorCode, String errorMessage)Used to record errors of the Geofence module Future<out Object>pushGeoFenceExitedEvent(JSONObject geoFenceProperties)Pushes the Geofence Cluster Exited event to CleverTap. Future<out Object>pushGeofenceEnteredEvent(JSONObject geofenceProperties)Pushes the Geofence Cluster Entered event to CleverTap. voidpushInboxNotificationClickedEvent(String messageId)Pushes the Notification Clicked event for App Inbox to CleverTap. voidpushInboxNotificationViewedEvent(String messageId)Pushes the Notification Viewed event for App Inbox to CleverTap. voidpushInstallReferrer(String url)This method is used to push install referrer via url String synchronized voidpushInstallReferrer(String source, String medium, String campaign)This method is used to push install referrer via UTM source, medium & campaign parameters voidpushNotificationClickedEvent(Bundle extras)Pushes the Notification Clicked event to CleverTap. voidpushNotificationViewedEvent(Bundle extras)Pushes the Notification Viewed event to CleverTap. voidpushProfile(Map<String, Object> profile)Push a profile update. voidrecordScreen(String screenName)Record a Screen View event voidremoveMultiValueForKey(String key, String value)Remove a unique value from a multi-value user profile propertyIf 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. voidremoveMultiValuesForKey(String key, ArrayList<String> values)Remove a collection of unique values from a multi-value user profile propertyIf 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. voidremoveValueForKey(String key)Remove the user profile property value specified by key from the user profile. voidresumeInAppNotifications()Resumes display of InApp Notifications. static NotificationHandlergetNotificationHandler()static NotificationHandlergetSignedCallNotificationHandler()voidincrementValue(String key, Number value)This method is used to increment the given value. voidsetCTFeatureFlagsListener(CTFeatureFlagsListener featureFlagsListener)Note: This method has been deprecated since v5.0.0 and will be removed in the future versions of this SDK. voidsetCTProductConfigListener(CTProductConfigListener listener)Note: This method has been deprecated since v5.0.0 and will be removed in the future versions of this SDK. voidsetDisplayUnitListener(DisplayUnitListener listener)Sets the listener to get the list of currently running Display Campaigns via callback voidsetInAppNotificationButtonListener(InAppNotificationButtonListener listener)voidsetCTInboxMessageListener(InboxMessageListener listener)static voidaddNotificationRenderedListener(String id, NotificationRenderedListener notificationRenderedListener)static NotificationRenderedListenergetNotificationRenderedListener(String id)static NotificationRenderedListenerremoveNotificationRenderedListener(String id)voidsetLibrary(String library)Not to be used by developers. Future<out Object>setLocationForGeofences(Location location, int sdkVersion)Sets the location in CleverTap to get updated GeoFences voidsetMultiValuesForKey(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. voidsetOffline(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. voidsetOptOut(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. voidsetOptOut(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). voidshowAppInbox(CTInboxStyleConfig styleConfig)Opens CTInboxActivity to display Inbox Messages voiddismissAppInbox()Dismisses the App Inbox Activity if already opened voidshowAppInbox()Opens CTInboxActivity to display Inbox Messages with default CTInboxStyleConfig object voidsuspendInAppNotifications()Suspends display of InApp Notifications.The InApp Notifications are queued once this method is calledand will be displayed once resumeInAppNotifications() is called. intgetCustomSdkVersion(String customSdkName)voidsetCustomSdkVersion(String customSdkName, int customSdkVersion)static ArrayList<CleverTapAPI>getAvailableInstances(Context context)static voidsetNotificationHandler(NotificationHandler notificationHandler)static voidsetSignedCallNotificationHandler(NotificationHandler notificationHandler)voidgetCleverTapID(@NonNull() OnInitCleverTapIDListener onInitCleverTapIDListener)Subscribe to receive a unique identifier by which CleverTap identifies this user. voidremoveCleverTapIDListener(@NonNull() OnInitCleverTapIDListener onInitCleverTapIDListener)Remove a previously subscribed OnInitCleverTapIDListener. Future<out Object>renderPushNotification(@NonNull() INotificationRenderer iNotificationRenderer, Context context, Bundle extras)voidrenderPushNotificationOnCallerThread(@NonNull() INotificationRenderer iNotificationRenderer, Context context, Bundle extras)static BitmapgetNotificationBitmapWithTimeoutAndSize(Context context, Bundle bundle, String bitmapSrcUrl, boolean fallbackToAppIcon, long timeoutInMillis, int sizeInBytes)Retrieves a notification bitmap with a specified timeout and size constraint. static BitmapgetNotificationBitmapWithTimeout(Context context, Bundle bundle, String bitmapSrcUrl, boolean fallbackToAppIcon, long timeoutInMillis)Retrieves a notification bitmap with a specified timeout. booleanisDevelopmentMode()Check if your app is in development mode. <T> Var<T>defineVariable(String name, T defaultValue)Defines a new variable. Var<String>defineFileVariable(String name)Defines a new file variable. voidparseVariables(Array<Object> instances)Parses the @Variable annotated fields from a given instance or multiple instances. voidparseVariablesForClasses(Array<Class<out Object>> classes)Parses the @Variable annotated static fields from a given class or multiple classes. ObjectgetVariableValue(String name)Get a copy of the current value of a variable or a group. <T> Var<T>getVariable(String name)Get an instance of a variable or a group. voidfetchVariables()Fetches variable values from server. voidfetchInApps(FetchInAppsCallback callback)Fetches In Apps from server. voidfetchVariables(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. voidsyncVariables()Uploads variables to server. voidaddVariablesChangedCallback(@NonNull() VariablesChangedCallback callback)Adds a callback to be invoked when variables are initialised with server values.Will be called each time new values are fetched. voidaddOneTimeVariablesChangedCallback(@NonNull() VariablesChangedCallback callback)Adds a callback to be invoked when variables are initialised with server values. voidremoveVariablesChangedCallback(@NonNull() VariablesChangedCallback callback)Removes previously registered callback. voidremoveOneTimeVariablesChangedCallback(@NonNull() VariablesChangedCallback callback)Removes previously registered callback. voidonVariablesChangedAndNoDownloadsPending(@NonNull() VariablesChangedCallback callback)Adds a callback to be invoked when variables are initialised with server values and filedownloads are also completed for file type variables (if any) registered with defineFileVariable.Will be called each time new values are fetched. voidonceVariablesChangedAndNoDownloadsPending(@NonNull() VariablesChangedCallback callback)Adds a callback to be invoked when variables are initialised with server values and filedownloads are also completed for file type variables (if any) registered with defineFileVariable.Will be called only once and then removed. voidremoveAllVariablesChangedCallbacks()Removes all previously registered callbacks. voidremoveAllOneTimeVariablesChangedCallbacks()Removes all previously registered one time callbacks. voidsetLocale(String locale)Use this method to set a custom locale for the current CleverTap instance StringgetLocale()Returns the custom locale set for the current CleverTap instance voidclearInAppResources(boolean expiredOnly)Deletes all images and gifs which are preloaded for inapps in cs mode voidclearFileResources(boolean expiredOnly)Deletes all types of files which are preloaded for SDK features like custom in-app templates, app functions andvariables etc. voidpushRegistrationToken(String token, PushType pushType, boolean register)Sends push registration token for the given push type -
-
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)
-
getInstances
static HashMap<String, CleverTapAPI> getInstances()
-
setInstances
static void setInstances(HashMap<String, CleverTapAPI> instances)
-
getCoreState
@RestrictTo(value = Scope.LIBRARY) CoreState getCoreState()
-
setCoreState
void setCoreState(CoreState cleverTapState)
-
setInboxMessageButtonListener
void setInboxMessageButtonListener(InboxMessageButtonListener listener)
-
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 Idtoken- 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 Idtoken- CleverTap Account Tokenregion- 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 Idtoken- CleverTap Account TokenproxyDomain- CleverTap Proxy DomainspikyProxyDomain- 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 Idtoken- CleverTap Account TokenproxyDomain- CleverTap Proxy DomainspikyProxyDomain- CleverTap Spiky Proxy DomaincustomHandshakeDomain- 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 contextextras- The Bundle object received by the broadcast receivernotificationId- A custom id to build a notification
-
getGlobalInstance
@Nullable() static CleverTapAPI getGlobalInstance(Context context, String _accountId)
-
processPushNotification
static void processPushNotification(Context context, Bundle extras)
Pass Push Notification Payload to CleverTap for smooth functioning of Pull Notifications
- Parameters:
context- - Application Contextextras- - 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 contextextras- 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 contextchannelId- A String for setting the id of the notification channelchannelName- A String for setting the name of the notification channelchannelDescription- A String for setting the description of the notification channelimportance- An Integer value setting the importance of the notifications sent in this channelshowBadge- 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 contextchannelId- A String for setting the id of the notification channelchannelName- A String for setting the name of the notification channelchannelDescription- A String for setting the description of the notification channelimportance- An Integer value setting the importance of the notifications sent in thischannelgroupId- A String for setting the notification channel as a part of a notificationgroupshowBadge- 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 contextchannelId- A String for setting the id of the notification channelchannelName- A String for setting the name of the notification channelchannelDescription- A String for setting the description of the notification channelimportance- An Integer value setting the importance of the notifications sent in this channelshowBadge- An boolean value as to whether this channel shows a badgesound- 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 contextchannelId- A String for setting the id of the notification channelchannelName- A String for setting the name of the notification channelchannelDescription- A String for setting the description of the notification channelimportance- An Integer value setting the importance of the notifications sent in thischannelgroupId- A String for setting the notification channel as a part of a notificationgroupshowBadge- An boolean value as to whether this channel shows a badgesound- 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 contextgroupId- A String for setting the id of the notification channel groupgroupName- 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 contextchannelId- 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 contextgroupId- A String for setting the id of the notification channel group
-
fcmTokenRefresh
@RestrictTo(value = Scope.LIBRARY_GROUP)@Deprecated() static void fcmTokenRefresh(Context context, String token)
-
getDefaultInstance
static CleverTapAPI getDefaultInstance(Context context, String cleverTapID)
Returns the default shared instance of the CleverTap SDK.
- Parameters:
context- The Android contextcleverTapID- Custom CleverTapID passed by the app
-
getDefaultInstance
@Nullable() static CleverTapAPI getDefaultInstance(Context context)
Returns the default shared instance of the CleverTap SDK.
- Parameters:
context- The Android context
-
getNotificationInfo
static NotificationInfo getNotificationInfo(Bundle extras)
Checks whether this notification is from CleverTap.
- Parameters:
extras- The payload from the FCM intent
-
handleNotificationClicked
@RestrictTo(value = Scope.LIBRARY) static void handleNotificationClicked(Context context, Bundle notification)
-
instanceWithConfig
static CleverTapAPI instanceWithConfig(Context context, @NonNull() CleverTapInstanceConfig config)
Returns an instance of the CleverTap SDK using CleverTapInstanceConfig.
- Parameters:
context- The Android contextconfig- The CleverTapInstanceConfig object
-
instanceWithConfig
static CleverTapAPI instanceWithConfig(Context context, @NonNull() CleverTapInstanceConfig config, String cleverTapID)
Returns an instance of the CleverTap SDK using CleverTapInstanceConfig.
- Parameters:
context- The Android contextconfig- The CleverTapInstanceConfig object
-
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
-
onActivityPaused
static void onActivityPaused()
-
onActivityResumed
static void onActivityResumed(Activity activity)
-
onActivityResumed
static void onActivityResumed(Activity activity, String cleverTapID)
-
runJobWork
@RestrictTo(value = Scope.LIBRARY) static void runJobWork(Context context)
-
tokenRefresh
@RestrictTo(value = Scope.LIBRARY_GROUP) static void tokenRefresh(Context context, String token, PushType pushType)
-
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:
Kotlin:CleverTapAPI.registerCustomInAppTemplates(ctConfig -> CustomTemplatesExtKt.templatesSet( new CustomTemplate.TemplateBuilder() .name("template") .presenter() .stringArgument("string", "Text") .build()));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".
-
getActiveContextForTemplate
@Nullable() CustomTemplateContext getActiveContextForTemplate(@NonNull() String templateName)
Retrieve a CustomTemplateContext for a template that is currently displaying. If the provided templatename is not of a currently active template this method returns
null.
-
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- Stringvalue- 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- Stringvalues- ArrayList with String values
-
deleteInboxMessage
void deleteInboxMessage(CTInboxMessage message)
Deletes the given CTInboxMessage object
- Parameters:
message- CTInboxMessage public object of inbox message
-
deleteInboxMessage
void deleteInboxMessage(String messageId)
Deletes the CTInboxMessage object for given messageId
- Parameters:
messageId- String - messageId of CTInboxMessage public object of inbox message
-
deleteInboxMessagesForIDs
void deleteInboxMessagesForIDs(ArrayList<String> messageIDs)
Deletes multiple CTInboxMessage objects for given list of messageIDs
- Parameters:
messageIDs- ArrayList with String values - list of messageIDs of CTInboxMessage public object of inbox message
-
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
-
featureFlag
@Deprecated() CTFeatureFlagsController featureFlag()
Note: This method has been deprecated since v5.0.0 and will be removed in the future versions of this SDK.
-
flush
void flush()
Sends all the events in the event queue.
-
setSCDomainListener
@RestrictTo(value = Scope.LIBRARY_GROUP)@WorkerThread() void setSCDomainListener(SCDomainListener scDomainListener)
This method is used to set the SCDomain callback.
Register to handle the domain related events from CleverTapThis is to be used only by clevertap-signedcall-sdk
- Parameters:
scDomainListener- - the SCDomainListener instance
-
getAccountId
String getAccountId()
-
getAllDisplayUnits
@Nullable() ArrayList<CleverTapDisplayUnit> getAllDisplayUnits()
Getter for retrieving all the Display Units.
-
getAllInboxMessages
ArrayList<CTInboxMessage> getAllInboxMessages()
Returns an ArrayList of all CTInboxMessage objects
-
getCTNotificationInboxListener
CTInboxListener getCTNotificationInboxListener()
Returns the CTInboxListener object
-
setCTNotificationInboxListener
void setCTNotificationInboxListener(CTInboxListener notificationInboxListener)
This method sets the CTInboxListener
- Parameters:
notificationInboxListener- An CTInboxListener object
-
getCTPushAmpListener
CTPushAmpListener getCTPushAmpListener()
Returns the CTPushAmpListener object
-
setCTPushAmpListener
void setCTPushAmpListener(CTPushAmpListener pushAmpListener)
This method is used to set the CTPushAmpListener
- Parameters:
pushAmpListener- - TheCTPushAmpListener object
-
getCTPushNotificationListener
CTPushNotificationListener getCTPushNotificationListener()
Returns the CTPushNotificationListener object
-
setCTPushNotificationListener
void setCTPushNotificationListener(CTPushNotificationListener pushNotificationListener)
This method is used to set the CTPushNotificationListener
- Parameters:
pushNotificationListener- - TheCTPushNotificationListener object
-
getCleverTapAttributionIdentifier
@WorkerThread()@Deprecated() String getCleverTapAttributionIdentifier()
Returns a unique CleverTap identifier suitable for use with install attribution providers.
-
getCleverTapID
@WorkerThread() String getCleverTapID()
Returns a unique identifier by which CleverTap identifies this user.
-
decrementValue
void decrementValue(String key, Number value)
This method is used to decrement the given valueNumber should be in positive range
- Parameters:
key- Stringvalue- 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.
-
getDevicePushToken
String getDevicePushToken(PushType type)
Returns the device push token or null
- Parameters:
type- com.clevertap.android.sdk.
-
getDevicePushTokenRefreshListener
CleverTapAPI.DevicePushTokenRefreshListener getDevicePushTokenRefreshListener()
Returns the DevicePushTokenRefreshListener
-
setDevicePushTokenRefreshListener
void setDevicePushTokenRefreshListener(CleverTapAPI.DevicePushTokenRefreshListener tokenRefreshListener)
This method is used to set the DevicePushTokenRefreshListener object
- Parameters:
tokenRefreshListener- The DevicePushTokenRefreshListener object
-
setRequestDevicePushTokenListener
@RestrictTo(value = Scope.LIBRARY_GROUP) void setRequestDevicePushTokenListener(CleverTapAPI.RequestDevicePushTokenListener requestTokenListener)
This method is used to set the RequestDevicePushTokenListener object
- Parameters:
requestTokenListener- The RequestDevicePushTokenListener object
-
getDisplayUnitForId
@Nullable() CleverTapDisplayUnit getDisplayUnitForId(String unitID)
Getter for retrieving Display Unit using the unitID
- Parameters:
unitID- - unitID of the Display Unit getUnitID
-
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
-
getGeofenceCallback
GeofenceCallback getGeofenceCallback()
Returns the GeofenceCallback object
-
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
-
getHistory
@Deprecated(since = 7.1.0) Map<String, EventDetail> getHistory()
Returns a Map of event names and corresponding event details of all the events raised
-
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()
-
getInAppNotificationListener
InAppNotificationListener getInAppNotificationListener()
Returns the InAppNotificationListener object
-
setInAppNotificationListener
void setInAppNotificationListener(InAppNotificationListener inAppNotificationListener)
This method sets the InAppNotificationListener
- Parameters:
inAppNotificationListener- An InAppNotificationListener object
-
unregisterPushPermissionNotificationResponseListener
void unregisterPushPermissionNotificationResponseListener(PushPermissionResponseListener pushPermissionResponseListener)
This method unregisters the given instance of the PushPermissionResponseListener ifpreviously registered.
Use this method to stop observing the push permission result.
- Parameters:
pushPermissionResponseListener- An PushPermissionResponseListener object
-
registerPushPermissionNotificationResponseListener
void registerPushPermissionNotificationResponseListener(PushPermissionResponseListener pushPermissionResponseListener)
This method registers the PushPermissionNotificationResponseListener.
Call this method only from the onCreate() of the activity/fragment and unregister thelistener from the onDestroy() method using the unregisterPushPermissionNotificationResponseListener
- Parameters:
pushPermissionResponseListener- An PushPermissionResponseListener object
-
getInboxMessageCount
int getInboxMessageCount()
Returns the count of all inbox messages for the user
-
getInboxMessageForId
CTInboxMessage getInboxMessageForId(String messageId)
Returns the CTInboxMessage object that belongs to the given message id
- Parameters:
messageId- String - unique id of the inbox message
-
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()
-
setLocation
void setLocation(Location location)
set the user profile location in CleverTaplocation can then be used for geo-segmentation etc.
- Parameters:
location- android.location.
-
getPreviousVisitTime
@Deprecated(since = 7.1.0) int getPreviousVisitTime()
Returns the timestamp of the previous visit
-
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
-
getPushToken
String getPushToken(@NonNull() PushType pushType)
Returns the token for a particular push type
-
getScreenCount
int getScreenCount()
Returns the number of screens which have been displayed by the app
-
getSyncListener
SyncListener getSyncListener()
Returns the SyncListener object
-
setSyncListener
void setSyncListener(SyncListener syncListener)
This method is used to set the SyncListener
- Parameters:
syncListener- The SyncListener object
-
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
-
getUnreadInboxMessages
ArrayList<CTInboxMessage> getUnreadInboxMessages()
Returns an ArrayList of unread CTInboxMessage objects
-
initializeInbox
void initializeInbox()
Initializes the inbox controller and sends a callback to the CTInboxListener This method needs to be called separately for each instance of CleverTapAPI
-
markReadInboxMessage
void markReadInboxMessage(CTInboxMessage message)
Marks the given CTInboxMessage object as read
- Parameters:
message- CTInboxMessage public object of inbox message
-
markReadInboxMessage
void markReadInboxMessage(String messageId)
Marks the given messageId of CTInboxMessage object as read
- Parameters:
messageId- String - messageId of CTInboxMessage public object of inbox message
-
markReadInboxMessagesForIDs
void markReadInboxMessagesForIDs(ArrayList<String> messageIDs)
Marks multiple CTInboxMessage objects as read for given list of messageIDs
- Parameters:
messageIDs- ArrayList with String values - list of messageIDs of CTInboxMessage public object of inbox message
-
messageDidClick
void messageDidClick(CTInboxActivity ctInboxActivity, int contentPageIndex, CTInboxMessage inboxMessage, Bundle data, HashMap<String, String> keyValue, int buttonIndex)
-
messageDidShow
void messageDidShow(CTInboxActivity ctInboxActivity, CTInboxMessage inboxMessage, Bundle data)
-
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 identitycleverTapID- 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.)
-
pushChargedEvent
void pushChargedEvent(HashMap<String, Object> chargeDetails, ArrayList<HashMap<String, Object>> items)
Push Charged event, which describes a purchase made.
-
pushDeepLink
void pushDeepLink(Uri uri)
Use this method to pass the deeplink with UTM parameters to track installs
- Parameters:
uri- URI of the deeplink
-
pushDisplayUnitClickedEventForID
void pushDisplayUnitClickedEventForID(String unitID)
Raises the Display Unit Clicked event
- Parameters:
unitID- - unitID of the Display UnitgetUnitID
-
pushDisplayUnitViewedEventForID
void pushDisplayUnitViewedEventForID(String unitID)
Raises the Display Unit Viewed event
- Parameters:
unitID- - unitID of the Display UnitgetUnitID
-
pushError
void pushError(String errorMessage, int errorCode)
Internally records an "Error Occurred" event, which can be viewed in the dashboard.
- Parameters:
errorMessage- The error messageerrorCode- The error code
-
pushEvent
void pushEvent(String eventName)
Pushes a basic event.
- Parameters:
eventName- The name of the event
-
pushEvent
void pushEvent(String eventName, Map<String, Object> eventActions)
Push an event with a set of attribute pairs.
-
pushFcmRegistrationId
void pushFcmRegistrationId(String fcmId, boolean register)
Sends the FCM registration ID to CleverTap.
- Parameters:
fcmId- The FCM registration IDregister- 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 eventeventProperties- 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 geofenceserrorMessage- - 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
-
pushInboxNotificationClickedEvent
void pushInboxNotificationClickedEvent(String messageId)
Pushes the Notification Clicked event for App Inbox to CleverTap.
- Parameters:
messageId- String - messageId of CTInboxMessage
-
pushInboxNotificationViewedEvent
void pushInboxNotificationViewedEvent(String messageId)
Pushes the Notification Viewed event for App Inbox to CleverTap.
- Parameters:
messageId- String - messageId of CTInboxMessage
-
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 parametermedium- The UTM medium parametercampaign- 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
-
pushProfile
void pushProfile(Map<String, Object> profile)
Push a profile update.
-
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- Stringvalue- 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- Stringvalues- 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.
-
getNotificationHandler
static NotificationHandler getNotificationHandler()
-
getSignedCallNotificationHandler
static NotificationHandler getSignedCallNotificationHandler()
-
incrementValue
void incrementValue(String key, Number value)
This method is used to increment the given value.
Number should be in positive range.
- Parameters:
key- Stringvalue- Number
-
setCTFeatureFlagsListener
@Deprecated() void setCTFeatureFlagsListener(CTFeatureFlagsListener featureFlagsListener)
Note: This method has been deprecated since v5.0.0 and will be removed in the future versions of this SDK.
This method is used to set the CTFeatureFlagsListenerRegister to receive feature flag callbacks- Parameters:
featureFlagsListener- The CTFeatureFlagsListener object
-
setCTProductConfigListener
@Deprecated() void setCTProductConfigListener(CTProductConfigListener listener)
Note: This method has been deprecated since v5.0.0 and will be removed in the future versions of this SDK.
This method is used to set the product config listenerRegister to receive callbacks- Parameters:
listener- The CTProductConfigListener instance
-
setDisplayUnitListener
void setDisplayUnitListener(DisplayUnitListener listener)
Sets the listener to get the list of currently running Display Campaigns via callback
- Parameters:
listener- - DisplayUnitListener
-
setInAppNotificationButtonListener
void setInAppNotificationButtonListener(InAppNotificationButtonListener listener)
-
setCTInboxMessageListener
void setCTInboxMessageListener(InboxMessageListener listener)
-
addNotificationRenderedListener
@RestrictTo(value = Scope.LIBRARY_GROUP) static void addNotificationRenderedListener(String id, NotificationRenderedListener notificationRenderedListener)
-
getNotificationRenderedListener
@RestrictTo(value = Scope.LIBRARY_GROUP) static NotificationRenderedListener getNotificationRenderedListener(String id)
-
removeNotificationRenderedListener
@RestrictTo(value = Scope.LIBRARY_GROUP) static NotificationRenderedListener removeNotificationRenderedListener(String id)
-
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
-
setLocationForGeofences
Future<out Object> setLocationForGeofences(Location location, int sdkVersion)
Sets the location in CleverTap to get updated GeoFences
- Parameters:
location- android.location.
-
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- Stringvalues- 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.
- 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`).
-
showAppInbox
void showAppInbox(CTInboxStyleConfig styleConfig)
Opens CTInboxActivity to display Inbox Messages
- Parameters:
styleConfig- CTInboxStyleConfig configuration of various style parameters for the
-
dismissAppInbox
void dismissAppInbox()
Dismisses the App Inbox Activity if already opened
-
showAppInbox
void showAppInbox()
Opens CTInboxActivity to display Inbox Messages with default CTInboxStyleConfig object
-
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.
-
getCustomSdkVersion
@RestrictTo(value = Scope.LIBRARY_GROUP) int getCustomSdkVersion(String customSdkName)
-
setCustomSdkVersion
@RestrictTo(value = Scope.LIBRARY_GROUP) void setCustomSdkVersion(String customSdkName, int customSdkVersion)
-
getAvailableInstances
@RestrictTo(value = Scope.LIBRARY_GROUP) static ArrayList<CleverTapAPI> getAvailableInstances(Context context)
-
setNotificationHandler
static void setNotificationHandler(NotificationHandler notificationHandler)
-
setSignedCallNotificationHandler
static void setSignedCallNotificationHandler(NotificationHandler notificationHandler)
-
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.
-
removeCleverTapIDListener
void removeCleverTapIDListener(@NonNull() OnInitCleverTapIDListener onInitCleverTapIDListener)
Remove a previously subscribed OnInitCleverTapIDListener.See getCleverTapID
- Parameters:
onInitCleverTapIDListener- The same listener instance passed togetCleverTapID that should be removed.
-
renderPushNotification
Future<out Object> renderPushNotification(@NonNull() INotificationRenderer iNotificationRenderer, Context context, Bundle extras)
-
renderPushNotificationOnCallerThread
@RestrictTo(value = Scope.LIBRARY_GROUP) void renderPushNotificationOnCallerThread(@NonNull() INotificationRenderer iNotificationRenderer, Context context, Bundle extras)
-
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.
-
isDevelopmentMode
boolean isDevelopmentMode()
Check if your app is in development mode. Some functions (like syncVariables and syncRegisteredInAppTemplates)will only work if the app is in development mode and the current user profile is set as a test profile in CTDashboard.
-
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.
-
fetchInApps
void fetchInApps(FetchInAppsCallback callback)
Fetches In Apps from server.
- Parameters:
callback- Callback instance FetchInAppsCallback to be invoked when fetching is done.
-
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.
-
addVariablesChangedCallback
void addVariablesChangedCallback(@NonNull() VariablesChangedCallback callback)
Adds a callback to be invoked when variables are initialised with server values.Will be called each time new values are fetched.
- Parameters:
callback- Callback to register.
-
addOneTimeVariablesChangedCallback
void addOneTimeVariablesChangedCallback(@NonNull() VariablesChangedCallback callback)
Adds a callback to be invoked when variables are initialised with server values. Will becalled only once and then removed.
- Parameters:
callback- Callback to register.
-
removeVariablesChangedCallback
void removeVariablesChangedCallback(@NonNull() VariablesChangedCallback callback)
Removes previously registered callback.
- Parameters:
callback- Callback to remove.
-
removeOneTimeVariablesChangedCallback
void removeOneTimeVariablesChangedCallback(@NonNull() VariablesChangedCallback callback)
Removes previously registered callback.
- Parameters:
callback- Callback to remove.
-
onVariablesChangedAndNoDownloadsPending
void onVariablesChangedAndNoDownloadsPending(@NonNull() VariablesChangedCallback callback)
Adds a callback to be invoked when variables are initialised with server values and filedownloads are also completed for file type variables (if any) registered with defineFileVariable.Will be called each time new values are fetched.
- Parameters:
callback- Callback to register.
-
onceVariablesChangedAndNoDownloadsPending
void onceVariablesChangedAndNoDownloadsPending(@NonNull() VariablesChangedCallback callback)
Adds a callback to be invoked when variables are initialised with server values and filedownloads are also completed for file type variables (if any) registered with defineFileVariable.Will be called only once and then removed.
- Parameters:
callback- Callback to register.
-
removeAllVariablesChangedCallbacks
void removeAllVariablesChangedCallbacks()
Removes all previously registered callbacks.
-
removeAllOneTimeVariablesChangedCallbacks
void removeAllOneTimeVariablesChangedCallbacks()
Removes all previously registered one time callbacks.
-
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
-
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 tokenpushType- Push Provider type for which the token is registeredregister- 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.
-
-
-
-