import { CleverTap } from '@ionic-native/clevertap/ngx';
export class HomePage {
constructor(public clevertap: CleverTap, <other parameters>)
{
//constructor code
}
//function calls
}
All calls to the CleverTap SDK should be made from your Javascript.
document.addEventListener('onCleverTapPushPermissionResponse', this.onCleverTapPushPermissionResponse,false);
document.addEventListener('onCleverTapInAppNotificationShow', this.onCleverTapInAppNotificationShow,false);// Only for Android, NO-OP for iOS
document.addEventListener('deviceready', this.onDeviceReady, false);
document.addEventListener('onCleverTapProfileSync', this.onCleverTapProfileSync, false); // optional: to be notified of CleverTap user profile synchronization updates
document.addEventListener('onCleverTapProfileDidInitialize', this.onCleverTapProfileDidInitialize, false); // optional, to be notified when the CleverTap user profile is initialized
document.addEventListener('onCleverTapInAppNotificationDismissed', this.onCleverTapInAppNotificationDismissed, false); // optional, to be receive a callback with custom in-app notification click data
document.addEventListener('onDeepLink', this.onDeepLink, false); // optional, register to receive deep links.
document.addEventListener('onPushNotification', this.onPushNotification, false); // optional, register to receive push notification payloads.
document.addEventListener('onCleverTapInboxDidInitialize', this.onCleverTapInboxDidInitialize, false); // optional, to check if CleverTap Inbox intialized
document.addEventListener('onCleverTapInboxMessagesDidUpdate', this.onCleverTapInboxMessagesDidUpdate, false); // optional, to check if CleverTap Inbox Messages were updated
document.addEventListener('onCleverTapInboxButtonClick', this.onCleverTapInboxButtonClick, false); // optional, to check if Inbox button was clicked with custom payload
document.addEventListener('onCleverTapInboxItemClick', this.onCleverTapInboxItemClick, false); // optional, to check if Inbox message was clicked
document.addEventListener('onCleverTapInAppButtonClick', this.onCleverTapInAppButtonClick, false); // optional, to check if InApp button was clicked with custom payload
document.addEventListener('onCleverTapFeatureFlagsDidUpdate', this.onCleverTapFeatureFlagsDidUpdate, false); // optional, to check if Feature Flags were updated
document.addEventListener('onCleverTapProductConfigDidInitialize', this.onCleverTapProductConfigDidInitialize, false); // optional, to check if Product Config was initialized
document.addEventListener('onCleverTapProductConfigDidFetch', this.onCleverTapProductConfigDidFetch, false); // optional, to check if Product Configs were updated
document.addEventListener('onCleverTapProductConfigDidActivate', this.onCleverTapProductConfigDidActivate, false); // optional, to check if Product Configs were activated
document.addEventListener('onCleverTapExperimentsUpdated', this.onCleverTapExperimentsUpdated, false); // optional, to check if Dynamic Variable Experiments were updated
document.addEventListener('onCleverTapDisplayUnitsLoaded', this.onCleverTapDisplayUnitsLoaded, false); // optional, to check if Native Display units were loaded
// Push Permission
onCleverTapPushPermissionResponse: function(e) {
console.log(e.accepted)
},
// on inapp displayed, Only for Android, NO-OP for iOS
onCleverTapInAppNotificationShow: function(e) {
log("onCleverTapInAppNotificationShow")
log(e.customExtras)
},
// deep link handling
onDeepLink: function(e) {
console.log(e.deeplink);
},
// push notification data handling
onPushNotification: function(e) {
console.log(JSON.stringify(e.notification));
},
onCleverTapInboxDidInitialize: function() {
CleverTap.showInbox({"navBarTitle":"My App Inbox","tabs": ["tag1", "tag2"],"navBarColor":"#FF0000"});
},
onCleverTapInboxMessagesDidUpdate: function() {
CleverTap.getInboxMessageUnreadCount(function(val) {console.log("Inbox unread message count"+val);})
CleverTap.getInboxMessageCount(function(val) {console.log("Inbox read message count"+val);});
},
onCleverTapInAppButtonClick: function(e) {
console.log("onCleverTapInAppButtonClick");
console.log(e.customExtras);
},
onCleverTapInboxButtonClick: function(e) {
console.log("onCleverTapInboxButtonClick");
console.log(e.customExtras);
},
onCleverTapFeatureFlagsDidUpdate: function() {
console.log("onCleverTapFeatureFlagsDidUpdate");
},
onCleverTapProductConfigDidInitialize: function() {
console.log("onCleverTapProductConfigDidInitialize");
},
onCleverTapProductConfigDidFetch: function() {
console.log("onCleverTapProductConfigDidFetch");
},
onCleverTapProductConfigDidActivate: function() {
console.log("onCleverTapProductConfigDidActivate");
},
onCleverTapExperimentsUpdated: function() {
console.log("onCleverTapExperimentsUpdated");
},
onCleverTapDisplayUnitsLoaded: function(e) {
console.log("onCleverTapDisplayUnitsLoaded");
console.log(e.units);
},
this.clevertap.profileSet({Name: 'Test-Name', Identity: 'android098768', custom: 122211});
this.clevertap.profileSetMultiValues('colors', ['red', 'blue']);
this.clevertap.profileRemoveMultiValue('colors', 'green');
this.clevertap.profileAddMultiValue('colors', 'green');
this.clevertap.profileIncrementValueBy('score', 15);
this.clevertap.profileDecrementValueBy('score', 10);
this.clevertap.onUserLogin({Name: 'Test-Name', Identity: 'android098768', Email: '[email protected]', custom: 122211});
this.clevertap.profileGetCleverTapID().then(r => {
console.log('profileGetCleverTapID: ' + r);
});
this.clevertap.setLocation(38.89, -77.04);
this.clevertap.recordEventWithName('Test Event');
this.clevertap.recordChargedEventWithDetailsAndItems({amount: 200, 'Charged ID': 5678},
[{
Category: 'Food',
Quantity: 2,
Title: 'Eggs (Dozen)'
}]);
this.clevertap.initializeInbox();
this.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'});
this.clevertap.getInboxMessageCount().then(r => {
console.log('getInboxMessageCount: ' + r);
});
this.clevertap.getUnreadInboxMessageCount().then(r => {
console.log('getUnreadInboxMessageCount: ' + r);
});
this.clevertap.getAllInboxMessage().then(r => {
console.log('getAllInboxMessage: ' + r);
});
this.clevertap.getUnreadInboxMessage().then(r => {
console.log('getUnreadInboxMessage: ' + r);
});
this.clevertap.getInboxMessageForId('message_ID_1234').then(r => {
console.log('getInboxMessageForId: ' + r);
});
this.clevertap.deleteInboxMessageForId('message_ID_1234');
Delete bulk messages with Ids - Only for iOS, NO-OP for Android [v2.7.0 onwards Android adds support for this method].
this.clevertap.deleteInboxMessagesForIds(['message_ID_1234','message_ID_xyz']);
this.clevertap.markReadInboxMessageForId('message_ID_1234');
this.clevertap.markReadInboxMessagesForIds(['message_ID_1234','message_ID_xyz']);
this.clevertap.dismissInbox();
this.clevertap.pushInboxNotificationViewedEventForId('message_ID_1234');
this.clevertap.pushInboxNotificationClickedEventForId('message_ID_1234');
this.clevertap.createNotificationChannel('channelID_1234', 'Notification Channel', 'channelDescription', 1, true);
this.clevertap.deleteNotificationChannel('channelID_1234');
this.clevertap.createNotificationChannelGroup('groupID_5678', 'Channel Group Name');
this.clevertap.deleteNotificationChannelGroup('groupID_5678');
this.clevertap.setPushToken('<Token Value>');
this.clevertap.suspendInAppNotifications();
this.clevertap.discardInAppNotifications();
this.clevertap.resumeInAppNotifications();
this.clevertap.getDisplayUnitForId('Test Display Unit').then(r => {
console.log('getDisplayUnitForId: ' + r);
});
this.clevertap.getAllDisplayUnits('Test Display Unit').then(r => {
console.log('getAllDisplayUnits: ' + r);
});
this.clevertap.setDefaultsMap({
key_long: 123, key_double: 3.14, key_string: 'sensible', key_bool: true
});
this.clevertap.fetch();
this.clevertap.activate();
this.clevertap.fetchAndActivate();
this.clevertap.fetchWithMinimumFetchIntervalInSeconds(60);
this.clevertap.setMinimumFetchIntervalInSeconds(60 * 10);
this.clevertap.getBoolean('key_string').then(r => {
console.log('getBoolean: ' + r);
});
this.clevertap.getLong('key_string').then(r => {
console.log('getLong: ' + r);
});
this.clevertap.getDouble('key_string').then(r => {
console.log('getDouble: ' + r);
});
this.clevertap.getString('key_string').then(r => {
console.log('getString: ' + r);
});
this.clevertap.reset();
this.clevertap.getLastFetchTimeStampInMillis().then(r => {
console.log('getLastFetchTimeStampInMillis: ' + r);
});
this.clevertap.getFeatureFlag('key_string', 'defaultString').then(r => {
console.log('getFeatureFlag: ' + r);
});
this.clevertap.enablePersonalization();
this.clevertap.profileGetProperty('Name').then(r => {
console.log('profileGetProperty' + r);
});
this.clevertap.getCleverTapID().then(r => {
console.log('getCleverTapID: ' + r);
});