const CleverTap = require('clevertap-react-native');
CleverTap.profileSet({"Identity":11102008, "Name":"React-Test Profile","Email":"[email protected]","Gender":"Male","DOB":"1995-10-14", "custom":1.73});
CleverTap.profileSetMultiValuesForKey(['a', 'b', 'c'], 'letters');
CleverTap.profileRemoveMultiValueForKey('b', 'letters');
CleverTap.profileAddMultiValueForKey('d', 'letters');
CleverTap.onUserLogin({'Name': 'React-Test', 'Identity': '11102008', 'Email': '[email protected]', 'custom1': 43});
CleverTap.profileGetCleverTapID((err, res) => {
console.log('CleverTapID', res, err);
});
CleverTap.setLocation(34.15, -118.20);
CleverTap.profileIncrementValueForKey(1, "score");
CleverTap.profileDecrementValueForKey(1, "score");
The custom proxy domain feature allows to proxy all events raised from the CleverTap SDK through your required domain, ideal for handling or relaying CleverTap events and Push Impression events with your application server. Refer following steps to configure the custom proxy domain(s) in the manifest file:
- Add your CleverTap Account credentials in the Manifest file against the
CLEVERTAP_ACCOUNT_ID
andCLEVERTAP_TOKEN
keys. - Add the CLEVERTAP_PROXY_DOMAIN key with the proxy domain value for handling events through the custom proxy domain.
- Add the CLEVERTAP_SPIKY_PROXY_DOMAIN key with proxy domain value for handling push impression events.
<meta-data
android:name="CLEVERTAP_ACCOUNT_ID"
android:value="YOUR ACCOUNT ID" />
<meta-data
android:name="CLEVERTAP_TOKEN"
android:value="YOUR ACCOUNT TOKEN" />
<meta-data
android:name="CLEVERTAP_PROXY_DOMAIN"
android:value="YOUR PROXY DOMAIN"/> <!-- e.g., analytics.sdktesting.xyz -->
<meta-data
android:name="CLEVERTAP_SPIKY_PROXY_DOMAIN"
android:value="YOUR SPIKY PROXY DOMAIN"/> <!-- e.g., spiky-analytics.sdktesting.xyz -->
- Add your CleverTap Account credentials in the Info.plist file against the
CleverTapAccountID
andCleverTapToken
keys. - Add the
CleverTapProxyDomain
key with the proxy domain value for handling events through the custom proxy domain e.g., analytics.sdktesting.xyz. - Add the
CleverTapSpikyProxyDomain
key with proxy domain value for handling push impression events e.g., spiky-analytics.sdktesting.xyz. - Import the CleverTap SDK in your AppDelegate file and call the following method in the
didFinishLaunchingWithOptions:
method.CleverTap.autoIntegrate()
CleverTap.recordEvent('testEvent');
CleverTap.recordEvent('Product Viewed', {'Product Name': 'Dairy Milk','Category': 'Chocolate','Amount': 20.00});
CleverTap.recordChargedEvent({'totalValue': 20, 'category': 'books'}, [{'title': 'book1'}, {'title': 'book2'}, {'title': 'book3'}]);
PII data is stored across the SDK and could be sensitive information. From CleverTap SDK v5.2.0 onwards, you can enable encryption for PII data wiz. Email, Identity, Name and Phone.
Currently 2 levels of encryption are supported i.e None(0) and Medium(1). Encryption level is None by default. None - All stored data is in plaintext Medium - PII data is encrypted completely.
Add encryption level in the AndroidManifest.xml
as following:
<meta-data
android:name="CLEVERTAP_ENCRYPTION_LEVEL"
android:value="1" />
Add the CleverTapEncryptionLevel
String key to info.plist
file where value 1 means Medium and 0 means None. Encryption Level will be None if any other value is provided.
CleverTap.initializeInbox();
CleverTap.showInbox({'tabs':['Offers','Promotions'],'navBarTitle':'My App Inbox','navBarTitleColor':'#FF0000','navBarColor':'#FFFFFF','inboxBackgroundColor':'#AED6F1','backButtonColor':'#00FF00'
,'unselectedTabColor':'#0000FF','selectedTabColor':'#FF0000','selectedTabIndicatorColor':'#000000',
'noMessageText':'No message(s)','noMessageTextColor':'#FF0000','firstTabTitle':'First Tab' });
CleverTap.addListener(CleverTap.CleverTapInboxMessageTapped, (event) => {
console.log("App Inbox item: ", event.data);
//following contentPageIndex and buttonIndex fields are available from CleverTap React Native SDK v0.9.6 onwards and below v1.0.0
console.log("Content Page index: " + event.contentPageIndex);
console.log("Button index: " + event.buttonIndex);
});
CleverTap.addListener(CleverTap.CleverTapInboxMessageButtonTapped, (event) => {/*consume the payload*/});
CleverTap.dismissInbox();
CleverTap.markReadInboxMessagesForIDs(['1', '2', '3']);
CleverTap.deleteInboxMessagesForIDs(['1', '2', '3']);
CleverTap.getInboxMessageCount((err, res) => {
console.log('Total Messages: ', res, err);
});
CleverTap.getInboxMessageUnreadCount((err, res) => {
console.log('Unread Messages: ', res, err);
});
CleverTap.getAllInboxMessages((err, res) => {
console.log('All Inbox Messages: ', res, err);
});
CleverTap.getUnreadInboxMessages((err, res) => {
console.log('Unread Inbox Messages: ', res, err);
});
CleverTap.getInboxMessageForId('Message Id',(err, res) => {
console.log("marking message read = "+res);
});
CleverTap.deleteInboxMessageForId('Message Id');
CleverTap.markReadInboxMessageForId('Message Id');
CleverTap.pushInboxNotificationViewedEventForId('Message Id');
CleverTap.pushInboxNotificationClickedEventForId('Message Id');
Follow the Push Primer integration doc.
CleverTap.createNotificationChannel("CtRNS", "Clever Tap React Native Testing", "CT React Native Testing", 1, true);
Starting from CleverTap React Native SDK v1.2.0, we have introduced a new feature that allows developers to define a default notification channel for their app. This feature provides flexibility in handling push notifications. Please note that this is only supported for clevertap core notifications. Support for push templates will be released soon. To specify the default notification channel ID, you can add the following metadata in your app's manifest file:
<meta-data android:name="CLEVERTAP_DEFAULT_CHANNEL_ID" android:value="your_default_channel_id" />
By including this metadata, you can define a specific notification channel that CleverTap will use if the channel provided in push payload is not registered by your app. This ensures that push notifications are displayed consistently even if the app's notification channels are not set up.
In case the SDK does not find the default channel ID specified in the manifest, it will automatically fallback to using a default channel called "Miscellaneous". This ensures that push notifications are still delivered, even if no specific default channel is specified in the manifest.
This enhancement provides developers with greater control over the default notification channel used by CleverTap for push notifications, ensuring a seamless and customizable user experience.
CleverTap.deleteNotificationChannel("RNTesting");
CleverTap.createNotificationChannelGroup(String groupId, String groupName);
CleverTap.deleteNotificationChannelGroup(String groupId);
CleverTap.setPushToken("<Replace with FCM Token value>", CleverTap.FCM);
CleverTap.getDisplayUnitForId('Unit Id', (err, res) => {
console.log('Get Display Unit for Id:', res, err);
});
CleverTap.getAllDisplayUnits((err, res) => {
console.log('All Display Units: ', res, err);
});
CleverTap.setDefaultsMap({'text_color': 'red', 'msg_count': 100, 'price': 100.50, 'is_shown': true, 'json': '{"key":"val"}'});
CleverTap.fetch();
CleverTap.activate();
CleverTap.fetchAndActivate();
CleverTap.fetchWithMinimumIntervalInSeconds(60);
CleverTap.setMinimumFetchIntervalInSeconds(60);
CleverTap.getProductConfigBoolean('is_shown', (err, res) => {
console.log('PC is_shown val in boolean :', res, err);
});
CleverTap.getNumber('msg_count', (err, res) => {
console.log('PC is_shown val in number(long) :', res, err);
});
CleverTap.getNumber('price', (err, res) => {
console.log('PC price val in number :', res, err);
});
CleverTap.getProductConfigString('text_color', (err, res) => {
console.log('PC text_color val in string :', res, err);
});
CleverTap.getProductConfigString('json', (err, res) => {
console.log('PC json val in string :', res, err);
});
CleverTap.resetProductConfig();
CleverTap.getLastFetchTimeStampInMillis((err, res) => {
console.log('LastFetchTimeStampInMillis in string: ', res, err);
});
CleverTap.getFeatureFlag('is_dark_mode', false, (err, res) => {
console.log('FF is_dark_mode val in boolean :', res, err);
});
CleverTap.getCleverTapID((err, res) => {
console.log('CleverTapID', res, err);
});
CleverTap.enablePersonalization();
CleverTap.disablePersonalization();
CleverTap.profileGetProperty('Name', (err, res) => {
console.log('CleverTap Profile Name: ', res, err);
});
CleverTap.setDebugLevel(3);
CleverTap.profileGetCleverTapAttributionIdentifier((err, res) => {
console.log('CleverTapAttributionIdentifier', res, err);
});
CleverTap.suspendInAppNotifications();
CleverTap.discardInAppNotifications();
CleverTap.resumeInAppNotifications();