Skip to content

Latest commit

 

History

History
397 lines (274 loc) · 7.61 KB

usage.md

File metadata and controls

397 lines (274 loc) · 7.61 KB

Example Usage

Grab a reference

const CleverTap = require('clevertap-react-native');

User Profiles

Update User Profile(Push Profile)

CleverTap.profileSet({"Identity":11102008, "Name":"React-Test Profile","Email":"[email protected]","Gender":"Male","DOB":"1995-10-14", "custom":1.73});

Set Multi Values For Key

CleverTap.profileSetMultiValuesForKey(['a', 'b', 'c'], 'letters');

Remove Multi Value For Key

CleverTap.profileRemoveMultiValueForKey('b', 'letters');

Add Multi Value For Key

CleverTap.profileAddMultiValueForKey('d', 'letters');

Create a User profile when user logs in (On User Login)

CleverTap.onUserLogin({'Name': 'React-Test', 'Identity': '11102008', 'Email': '[email protected]', 'custom1': 43});

Get CleverTap Reference id

CleverTap.profileGetCleverTapID((err, res) => {
         console.log('CleverTapID', res, err);
});

Set Location to User Profile

CleverTap.setLocation(34.15, -118.20);

Increment a User Profile property

CleverTap.profileIncrementValueForKey(1, "score");

Decrement a User Profile property

CleverTap.profileDecrementValueForKey(1, "score");

User Events

Record an event

CleverTap.recordEvent('testEvent');

Record Charged event

CleverTap.recordChargedEvent({'totalValue': 20, 'category': 'books'}, [{'title': 'book1'}, {'title': 'book2'}, {'title': 'book3'}]);

App Inbox

Initialize the CleverTap App Inbox Method

CleverTap.initializeInbox();

Show the App Inbox

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'});

Get Total message count

CleverTap.getInboxMessageCount((err, res) => {
	console.log('Total Messages: ', res, err);
});	

Get Total message count

CleverTap.getInboxMessageUnreadCount((err, res) => {
	console.log('Unread Messages: ', res, err);
});	

Get All Inbox Messages

CleverTap.getAllInboxMessages((err, res) => {
	console.log('All Inbox Messages: ', res, err);
});	

Get all Inbox unread messages

CleverTap.getUnreadInboxMessages((err, res) => {
	console.log('Unread Inbox Messages: ', res, err);
});	

Get inbox Id

CleverTap.getInboxMessageForId('Message Id',(err, res) => {
        console.log("marking message read = "+res);
});			

Delete message with id

CleverTap.deleteInboxMessageForId('Message Id');		

Mark a message as Read for inbox Id

CleverTap.markReadInboxMessageForId('Message Id');		

pushInbox Notification Viewed Event For Id

CleverTap.pushInboxNotificationViewedEventForId('Message Id');		

push Inbox Notification Clicked Event For Id

CleverTap.pushInboxNotificationClickedEventForId('Message Id');			

Push Notifications

Creating Notification Channel

CleverTap.createNotificationChannel("CtRNS", "Clever Tap React Native Testing", "CT React Native Testing", 1, true);			

Delete Notification Channel

CleverTap.deleteNotificationChannel("RNTesting");		

Creating a group notification channel

CleverTap.createNotificationChannelGroup(String groupId, String groupName);		

Delete a group notification channel

CleverTap.deleteNotificationChannelGroup(String groupId);			

Registering Fcm Token

CleverTap.setPushToken("<Replace with FCM Token value>", CleverTap.FCM);

Native Display

Get Display Unit for Id

CleverTap.getDisplayUnitForId('Unit Id', (err, res) => {
        console.log('Get Display Unit for Id:', res, err);
});

Get All Display Units

CleverTap.getAllDisplayUnits((err, res) => {
        console.log('All Display Units: ', res, err);
});

Product Config

Set Product Configuration to default

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

Fetching product configs

CleverTap.fetch();

Activate the most recently fetched product config

CleverTap.activate();

Fetch And Activate product config

CleverTap.fetchAndActivate();

Fetch Minimum Time Interval

CleverTap.fetchWithMinimumIntervalInSeconds(60);

Set Minimum Time Interval for Fetch

CleverTap.setMinimumFetchIntervalInSeconds(60);

Get Boolean key

CleverTap.getProductConfigBoolean('is_shown', (err, res) => {
	console.log('PC is_shown val in boolean :', res, err);
});

Get Long

CleverTap.getNumber('msg_count', (err, res) => {
	console.log('PC is_shown val in number(long)  :', res, err);
});

Get Double

CleverTap.getNumber('price', (err, res) => {
	console.log('PC price val in number :', res, err);
});		

Get String

CleverTap.getProductConfigString('text_color', (err, res) => {
        console.log('PC text_color val in string :', res, err);
});	

Get String (JSON)

CleverTap.getProductConfigString('json', (err, res) => {
	console.log('PC json val in string :', res, err);
});	

Delete all activated, fetched and defaults configs

CleverTap.resetProductConfig();

Get last fetched timestamp in millis

CleverTap.getLastFetchTimeStampInMillis((err, res) => {
        console.log('LastFetchTimeStampInMillis in string: ', res, err);
});		

Feature Flag

Get Feature Flag

CleverTap.getFeatureFlag('is_dark_mode', false, (err, res) => {
	console.log('FF is_dark_mode val in boolean :', res, err);
});

CleverTap ID

Get CleverTap ID

CleverTap.getCleverTapID((err, res) => {
        console.log('CleverTapID', res, err);
});

App Personalisation

Enable Personalization

CleverTap.enablePersonalization();		

Disable Personalization

CleverTap.disablePersonalization();

Get Profile Name

CleverTap.profileGetProperty('Name', (err, res) => {
	console.log('CleverTap Profile Name: ', res, err);
});

Debugging

CleverTap.setDebugLevel(3);

Attributions

Get CleverTap Attribution Identifier

CleverTap.profileGetCleverTapAttributionIdentifier((err, res) => {
         console.log('CleverTapAttributionIdentifier', res, err);
});

InApp Notification Controls

Suspend InApp Notifications

CleverTap.suspendInAppNotifications();

Discard InApp Notifications

CleverTap.discardInAppNotifications();

Resume InApp Notifications

CleverTap.resumeInAppNotifications();

For more information,