Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

CleverTap

Improve this doc

Cordova Plugin that wraps CleverTap SDK for Android and iOS

Repo: https://github.com/CleverTap/clevertap-cordova

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add clevertap-cordova
    $ npm install --save @ionic-native/clevertap@4
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { CleverTap } from '@ionic-native/clevertap';

constructor(private clevertap: CleverTap) { }

Instance Members

notifyDeviceReady()

notify device ready NOTE: in iOS use to be notified of launch Push Notification or Deep Link in Android use only in android phonegap build projects

Returns: Promise<any>

enablePersonalization()


Personalization ****** Personalization Enables the Personalization API

Returns: Promise<any>

setOptOut(optOut)

Enables tracking opt out for the currently active user.

Param Type Details
optOut boolean

Returns: Promise<any>

enableDeviceNetworkInfoReporting(enable)

Enables the reporting of device network related information, including IP address. This reporting is disabled by default.

Param Type Details
enable boolean

Returns: Promise<any>

registerPush()


Push ****** Registers for push notifications

Returns: Promise<any>

setPushToken(token)

Sets the device’s push token

Param Type Details
token string

Returns: Promise<any>

createNotificationChannel(channelID, channelName, channelDescription, importance, showBadge)

Create Notification Channel for Android O+

Param Type Details
channelID string
channelName string
channelDescription string
importance number
showBadge boolean

Returns: Promise<any>

createNotificationChannelWithSound(channelID, channelName, channelDescription, importance, showBadge, sound)

Create Notification Channel for Android O+

Param Type Details
channelID string
channelName string
channelDescription string
importance number
showBadge boolean
sound string

Returns: Promise<any>

createNotificationChannelWithGroupId(channelID, channelName, channelDescription, importance, groupId, showBadge, sound)

Create Notification Channel with Group ID for Android O+

Param Type Details
channelID string
channelName string
channelDescription string
importance number
groupId string
showBadge boolean
sound string

Returns: Promise<any>

createNotificationChannelWithGroupIdAndSound(channelID, channelName, channelDescription, importance, groupId, showBadge)

Create Notification Channel with Group ID for Android O+

Param Type Details
channelID string
channelName string
channelDescription string
importance number
groupId string
showBadge boolean

Returns: Promise<any>

createNotificationChannelGroup(groupID, groupName)

Create Notification Channel Group for Android O+

Param Type Details
groupID string
groupName string

Returns: Promise<any>

deleteNotificationChannel(channelID)

Delete Notification Channel for Android O+

Param Type Details
channelID string

Returns: Promise<any>

deleteNotificationChannelGroup(groupID)

Delete Notification Group for Android O+

Param Type Details
groupID string

Returns: Promise<any>

recordScreenView(screenName)


Events ****** Record Screen View

Param Type Details
screenName string

Returns: Promise<any>

recordEventWithName(eventName)

Record Event with Name

Param Type Details
eventName string

Returns: Promise<any>

recordEventWithNameAndProps(eventName, eventProps)

Record Event with Name and Event properties

Param Type Details
eventName string
eventProps any

Returns: Promise<any>

recordChargedEventWithDetailsAndItems(details, items)

Record Charged Event with Details and Items

Param Type Details
details any

object with transaction details

items any

array of items purchased

Returns: Promise<any>

eventGetFirstTime(eventName)

Get Event First Time

Param Type Details
eventName string

callback returns epoch seconds or -1

Returns: Promise<any>

eventGetLastTime(eventName)

Get Event Last Time

Param Type Details
eventName string

callback returns epoch seconds or -1

Returns: Promise<any>

eventGetOccurrences(eventName)

Get Event Number of Occurrences

Param Type Details
eventName string

calls back with int or -1

Returns: Promise<any>

eventGetDetails(eventName)

Get Event Details

Param Type Details
eventName string

calls back with object {"eventName": , "firstTime":, "lastTime": , "count": } or empty object</p> </td> </tr> </tbody> </table>

Returns: Promise<any>

getEventHistory()

Get Event History calls back with object {"eventName1":, "eventName2":}

Returns: Promise<any>

getLocation()

**************** Profiles **************** Get the device location if available. On iOS: Calling this will prompt the user location permissions dialog. Please be sure to include the NSLocationWhenInUseUsageDescription key in your Info.plist. Uses desired accuracy of kCLLocationAccuracyHundredMeters. If you need background location updates or finer accuracy please implement your own location handling. On Android: Requires Location Permission in AndroidManifest e.g. "android.permission.ACCESS_COARSE_LOCATION" You can use location to pass it to CleverTap via the setLocation API for, among other things, more fine-grained geo-targeting and segmentation purposes. Note: on iOS the call to CleverTapSDK must be made on the main thread due to LocationManager restrictions, but the CleverTapSDK method itself is non-blocking. calls back with {lat:lat, lon:lon} lat and lon are floats

Returns: Promise<any>

setLocation(lat, lon)

Set location
Param Type Details
lat number
lon number

Returns: Promise<any>

onUserLogin(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 dictionary. If your app is used by multiple users, you can use this method to assign them each a unique profile to track them separately. If instead you wish to assign multiple Identity, Email, FBID and/or GPID values to the same user profile, use profileSet rather than this method. If none of Identity, Email, FBID or GPID is included in the profile dictionary, all properties 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 profileSet), 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 operation in that the current session for the previous user is automatically closed and data relating to the old user removed, and a new session is started for 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.
Param Type Details
profile any

object

Returns: Promise<any>

profileSet(profile)

Set profile attributes
Param Type Details
profile any

object

Returns: Promise<any>

profileSetGraphUser(profile)

Set profile attributes from facebook user
Param Type Details
profile any

facebook graph user object

Returns: Promise<any>

profileGooglePlusUser(profile)

Set profile attributes rom google plus user
Param Type Details
profile any

google plus user object

Returns: Promise<any>

profileGetProperty(propertyName)

Get User Profile Property
Param Type Details
propertyName string

calls back with value of propertyName or false

Returns: Promise<any>

profileGetCleverTapAttributionIdentifier()

Get a unique CleverTap identifier suitable for use with install attribution providers. calls back with unique CleverTap attribution identifier

Returns: Promise<any>

profileGetCleverTapID()

Get User Profile CleverTapID calls back with CleverTapID or false

Returns: Promise<any>

profileRemoveValueForKey(key)

Remove the property specified by key from the user profile
Param Type Details
key string

Returns: Promise<any>

profileSetMultiValues(key, values)

Method for setting a multi-value user profile property
Param Type Details
key string
values any

array of strings

Returns: Promise<any>

profileAddMultiValue(key, value)

Method for adding a value to a multi-value user profile property
Param Type Details
key string
value string

Returns: Promise<any>

profileAddMultiValues(key, values)

Method for adding values to a multi-value user profile property
Param Type Details
key string
values any

array of strings

Returns: Promise<any>

profileRemoveMultiValue(key, value)

Method for removing a value from a multi-value user profile property
Param Type Details
key string
value string

Returns: Promise<any>

profileRemoveMultiValues(key, values)

Method for removing a value from a multi-value user profile property
Param Type Details
key string
values any

array of strings

Returns: Promise<any>

sessionGetTimeElapsed()

**************** Session **************** Get Session Elapsed Time calls back with seconds

Returns: Promise<any>

sessionGetTotalVisits()

Get Session Total Visits calls back with with int or -1

Returns: Promise<any>

sessionGetScreenCount()

Get Session Screen Count calls back with with int

Returns: Promise<any>

sessionGetPreviousVisitTime()

Get Session Previous Visit Time calls back with with epoch seconds or -1

Returns: Promise<any>

sessionGetUTMDetails()

Get Sesssion Referrer UTM details object {"source": , "medium": , "campaign": } or empty object

Returns: Promise<any>

pushInstallReferrer(source, medium, campaign)

Call this to manually track the utm details for an incoming install referrer
Param Type Details
source string
medium string
campaign string

Returns: Promise<any>

setDebugLevel(level)

**************** Developer Options **************** 0 is off, 1 is info, 2 is debug, default is 1
Param Type Details
level number

Returns: Promise<any>

API

Native

General