### Firebase Integration Example Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/web-push-notification.md Full implementation example for sending a Firebase token to InTrack after retrieval. ```javascript import { getMessaging, getToken } from "firebase/messaging"; const messaging = getMessaging(); getToken(messaging, { vapidKey: '' }).then((currentToken) => { if (currentToken) { // Send the token to our server $Intk('sendFireBaseToken', currentToken); //<-- here } else { // ... } }).catch((err) => { console.log('An error occurred while retrieving token. ', err); // ... }); ``` ```javascript import { getMessaging, getToken } from "firebase/messaging"; const messaging = getMessaging(); getToken(messaging, { vapidKey: '' }).then((currentToken) => { if (currentToken) { // Send the token to our server $InTrack.sendFireBaseToken(currentToken); //<-- here } else { // ... } }).catch((err) => { console.log('An error occurred while retrieving token. ', err); // ... }); ``` -------------------------------- ### Install SDK via CocoaPods Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/ios-getting-started.md Command to install the defined dependencies into the project. ```shell $ pod install ``` -------------------------------- ### Install CocoaPods Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/ios-getting-started.md Command to install the CocoaPods dependency manager. ```shell $ sudo gem install cocoapods ``` -------------------------------- ### Initialize inTrack SDK Source: https://github.com/devopssmartech/intrack-doc/blob/main/react-native/react-native-getting-started.md Initialize and start the SDK within the application lifecycle, preferably in componentDidMount. ```javascript if (!(await $InTrack.isInitialized())) { const options = { appKey: 'APP_KEY', iosAuthKey: 'ّAUTH_KEY_FOR_IOS', androidAuthKey: 'AUTH_KEY_FOR_ANDROID', }; await $InTrack.init(options); $InTrack.start(); } ``` -------------------------------- ### SDK Initialization Source: https://github.com/devopssmartech/intrack-doc/blob/main/llms-full.txt Methods to initialize and start the inTrack SDK within the application lifecycle. ```APIDOC ## SDK Initialization ### Description Initializes the inTrack SDK using the provided application and authentication keys. This should be called once, preferably in the componentDidMount method of the main app component. ### Methods - **isInitialized()**: Checks if the SDK has already been initialized. - **init(options)**: Initializes the SDK with an object containing appKey, iosAuthKey, and androidAuthKey. - **start()**: Starts the SDK tracking. ### Example ```javascript if (!(await $InTrack.isInitialized())) { const options = { appKey: 'APP_KEY', iosAuthKey: 'AUTH_KEY_FOR_IOS', androidAuthKey: 'AUTH_KEY_FOR_ANDROID', }; await $InTrack.init(options); $InTrack.start(); } ``` ``` -------------------------------- ### Register InAppDisplayDelegate Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/ios-inapp-messaging.md Assign the delegate to the InTrack configuration before starting the SDK. ```objectivec { `$InTrackConfig* config = $InTrackConfig.new; config.appKey = @"YOUR_APP_KEY"; config.authKey = @"YOUR_AUTH_KEY"; config.enableInAppMessaging = YES; config.inAppDisplayDelegate = self; [$InTrack startWithConfig:config]; ` } ``` ```swift { `let config: $InTrackConfig = $InTrackConfig() config.appKey = @"YOUR_APP_KEY" config.authKey = @"YOUR_AUTH_KEY" config.enableInAppMessaging = true config.inAppDisplayDelegate = self $InTrack.initWith(config) ` } ``` -------------------------------- ### Install iOS CocoaPods Source: https://github.com/devopssmartech/intrack-doc/blob/main/react-native/react-native-getting-started.md Necessary step for iOS projects to ensure auto-linking is configured correctly. ```shell (cd ios && pod install) ``` -------------------------------- ### Login with custom attributes Source: https://github.com/devopssmartech/intrack-doc/blob/main/react-native/tracking-users.md Example of defining custom data and user details before calling the login method. ```javascript const customData = { string: 'string', boolean: true, integer: 100000, double: 19.99, float: 5.75, date: '1989-07-31T09:27:37Z', }; const data = { firstName: 'firstname', lastName: 'lastname', email: 'test@test.com', phone: '+22000000', country: 'Iran', state: 'Tehran', city: 'Tehran', gender: 'male', birthday: '1989-07-31T09:27:37Z', //ISO-8601 company: 'company', userId: 'UID22222222', attributes: customData, }; $InTrack.login(data); ``` -------------------------------- ### Manual Subscription Example Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/web-push-notification.md Registers a service worker and sends the resulting subscription object to InTrack. ```javascript navigator.serviceWorker.register('serviceworker.js'); navigator.serviceWorker.ready.then((serviceWorkerRegistration) => { const options = { userVisibleOnly: true, applicationServerKey, }; serviceWorkerRegistration.pushManager.subscribe(options).then((pushSubscription) => { $Intk('sendPushSubscription', pushSubscription); //<-- here }, (error) => { console.error(error); }); }); ``` -------------------------------- ### Record Login Event with User Details Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/tracking-users.md Use these examples to initialize user details and record a login event. Ensure the mandatory userId field is provided as a string under 100 characters. ```objectivec { `$InTrackUserDetails *userDetails = [[$InTrackUserDetails alloc] init]; userDetails.userId = userId; userDetails.firstName = firstName; userDetails.lastName = lastName; userDetails.phone = phone; userDetails.city = @"Tehran"; userDetails.company = @"xx"; userDetails.country = @"Iran"; userDetails.email = @"xx@xxx.com"; userDetails.gender = MALE; userDetails.hashedEmail = @"xx.ir"; userDetails.hashedPhone = @"09****000"; userDetails.emailOptIn = @"false"; userDetails.smsOptIn = @"false"; userDetails.pushOptIn = @"false"; userDetails.webPushOptIn = @"false"; userDetails.state = @"tehran"; userDetails.userAttributes=@{ @"attr1":@1, @"attr2":@"string", @"attr3":@42, @"attr4":@[@1, @2, @3, @4] }; [$InTrack recordLogin:userDetails]; ` } ``` ```swift { `let userDetails:$InTrackUserDetails = $InTrackUserDetails(); userDetails.userId=userId; userDetails.firstName=firstName userDetails.lastName=lastName userDetails.phone=phone userDetails.city="Tehran" userDetails.company="xx" userDetails.country="Iran" userDetails.email="xx@xxx.com" userDetails.gender = MALE userDetails.hashedEmail="xx****@***.ir" userDetails.hashedPhone="09****000" userDetails.emailOptIn="false" userDetails.smsOptIn="false" userDetails.pushOptIn="false" userDetails.webPushOptIn="false" userDetails.state="tehran" userDetails.userAttributes = [ "attr1" : 1, "attr2" : "string", "attr3" : 42, "attr4" : [1,2,3,4] ] $InTrack.recordLogin(userDetails) ` } ``` -------------------------------- ### Send Custom Event Source: https://github.com/devopssmartech/intrack-doc/blob/main/llms-full.txt Examples of sending custom events using asynchronous and synchronous methods. ```javascript { `$Intk('sendEvent', { eventName: 'my-custom-event', eventData: { count: 1000, label: 'two', accepted: false, date: '1970-01-01', myDetails: { one: 1, myList: ['firstValue', 'secondValue'], }, }, });` } ``` ```javascript { `$InTrack.sendEvent({ eventName: 'my-custom-event', eventData: { count: 1000, label: 'two', accepted: false, date: '1970-01-01', myDetails: { one: 1, myList: ['firstValue', 'secondValue'], }, }, });` } ``` -------------------------------- ### Record a custom event Source: https://github.com/devopssmartech/intrack-doc/blob/main/react-native/tracking-events.md Example of sending a custom event with various attribute data types to the inTrack server. ```javascript { `const date = new Date().toISOString(); // Event with custom event attributes. const customData = { string: 'string', boolean: true, integer: 100000, double: 19.99, date: '1989-07-31T09:27:37Z', //ISO-8601 }; console.log(customData); // Log custom event data // Record custom event $InTrack.sendEvent({ eventName: '$intrack_custom_event', eventData: customData, }); ` } ``` -------------------------------- ### Telegram API Token Format Source: https://github.com/devopssmartech/intrack-doc/blob/main/custom-channel/telegram-provider.md Example of the format for a Telegram API token obtained from BotFather. ```jsx {`4839574812:AAFD39kkdpWt3ywyRZergyOLMaJhac60qc`} ``` -------------------------------- ### System Event Webhook Body Source: https://github.com/devopssmartech/intrack-doc/blob/main/webhook/configuration.md Example JSON payload for a system event webhook. ```json { "licenceCode": "", "userId": "34561", "anonymousId": "2213c9a6-a4ec-4481-a2ba-af8d72793bc0", "eventName": "[INT]_email_sent", "eventTime": "2021-09-21T10:30:00+0430", "type": "SYSTEM_EVENT", "communicationId": 920, "variationId": 1003, "journeyId": 50, "eventData": { // custom attributes of event "customString": "stringValue", "customBoolean": true, "customNumber": 123, "customDate": "2021-09-21T10:30:00+0430" } } ``` -------------------------------- ### Update User Profile with Attributes Source: https://github.com/devopssmartech/intrack-doc/blob/main/react-native/tracking-users.md Example of updating specific user profile fields like first and last name. ```javascript const data = { firstName: 'firstname-changed', lastName: 'lastname-changed', }; $InTrack.updateProfile(data); ``` -------------------------------- ### Login with Custom Attributes Source: https://github.com/devopssmartech/intrack-doc/blob/main/flutter/tracking-users.md Example of calling the login method with a populated user details object including custom attributes. ```dart { `const customData = { 'string': 'string', 'boolean': true, 'integer': 100000, 'double': 19.99, 'float': 5.75, 'date': '1989-07-31T09:27:37Z', }; const data = { 'firstName': 'firstname', 'lastName': 'lastname', 'email': 'test@test.com', 'phone': '+22000000', 'country': 'Iran', 'state': 'Tehran', 'city': 'Tehran', 'gender': 'male', 'birthday': '1989-07-31T09:27:37Z', // ISO-8601 'company': 'company', 'userId': 'UID22222222', 'attributes': customData, }; $InTrack.recordLogin(data); ` } ``` -------------------------------- ### Registering Click Action via REST API Source: https://github.com/devopssmartech/intrack-doc/blob/main/custom-channel/sending-push-notifications-via-custom-channel.md Sends a GET request to the click tracking endpoint, optionally including button index and URL parameters. ```json { `curl -X GET $https://api.intrack.ir/api/sdk/track/clicked?token=ewogICAgImlkIjogIjEyM2U0NTY3LWU4OWItMTJkMy1hNDU2LTQyNjY1MjM0MDAwMCIsCiAgICAicHJvZHVjdElkIjogMSwKICAgICJ1c2VySWQiOiAiMDAwMSIKfQ&button=1&url=https://example.com ` } ``` -------------------------------- ### Update User Profile with Attributes Source: https://github.com/devopssmartech/intrack-doc/blob/main/flutter/tracking-users.md Example of updating specific user attributes such as first and last name. ```dart { `const data = { 'firstName': 'firstname_changed', 'lastName': 'lastname_changed', } $InTrack.updateProfile(data); ` } ``` -------------------------------- ### Install inTrack React Native Library Source: https://github.com/devopssmartech/intrack-doc/blob/main/react-native/react-native-getting-started.md Commands to add the inTrack bridge dependency to your project using npm or Yarn. ```npm npm install --save $intrack-react-native-bridge@3.0.3 ``` ```yarn yarn add $intrack-react-native-bridge@3.0.3 ``` -------------------------------- ### Install inTrack Flutter SDK dependency Source: https://github.com/devopssmartech/intrack-doc/blob/main/flutter/flutter-getting-started.md Use this command to add the inTrack package to your Flutter project dependencies. ```sh flutter pub add $intrack_flutter ``` -------------------------------- ### askForNotificationPermission Source: https://github.com/devopssmartech/intrack-doc/blob/main/llms-full.txt Requests user permission for push notifications. Can be called at any point after the push service is started. ```APIDOC ## askForNotificationPermission ### Description Prompts the user to grant permission for push notifications. This is a helper method provided by the inTrack SDK. ### Method SDK Method ``` -------------------------------- ### Send Custom Event with User ID Source: https://github.com/devopssmartech/intrack-doc/blob/main/llms-full.txt Examples of sending custom events while including a userId for identification. ```javascript { `$Intk('sendEvent', { userId: 'USER_ID', eventName: 'my-custom-event', eventData: { count: 1000, label: 'two', accepted: false, myDetails: { one: 1, myList: ['firstValue', 'secondValue'], }, }, });` } ``` ```javascript { `$InTrack.sendEvent({ userId: 'USER_ID', eventName: 'my-custom-event', eventData: { count: 1000, label: 'two', accepted: false, myDetails: { one: 1, myList: ['firstValue', 'secondValue'], }, }, });` } ``` -------------------------------- ### Initialize inTrack Notification Service Source: https://github.com/devopssmartech/intrack-doc/blob/main/react-native/push-messaging.md Call initNotificationService after initializing the SDK and before starting it to enable push notification support. ```javascript const initIntrack = async () => { if (!(await $InTrack.isInitialized())) { const options = { appKey: 'APP_KEY', iosAuthKey: 'ّAUTH_KEY_FOR_IOS', androidAuthKey: 'AUTH_KEY_FOR_ANDROID', loggingEnabled: true, }; await $InTrack.init(options); $InTrack.initNotificationService(); <-- Here $InTrack.start(); } }; ``` -------------------------------- ### startWithConfig / initWith Source: https://github.com/devopssmartech/intrack-doc/blob/main/llms-full.txt Initializes the InTrack SDK with the provided configuration, including setting the display delegate. ```APIDOC ## Method: startWithConfig / initWith ### Description Initializes the SDK using an $InTrackConfig object. Ensure `inAppDisplayDelegate` is set to receive message callbacks. ``` -------------------------------- ### Initialize Podfile Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/ios-getting-started.md Command to initialize a new Podfile in the project directory. ```shell $ pod init ``` -------------------------------- ### Initialize inTrack SDK Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/web-getting-started.md Choose between asynchronous or synchronous loading methods. Asynchronous loading is recommended to prevent potential event loss or exceptions. ```html ``` ```html ``` -------------------------------- ### Initialize inTrack Web SDK Asynchronously Source: https://github.com/devopssmartech/intrack-doc/blob/main/llms-full.txt Recommended method for loading the SDK to prevent blocking page rendering. Place this snippet within the section of your HTML. ```html ``` -------------------------------- ### Initialize inTrack SDK (Legacy) Source: https://github.com/devopssmartech/intrack-doc/blob/main/react-native/react-native-getting-started.md Initialization method for SDK versions 1.2.1 or older. ```javascript if (!(await $InTrack.isInitialized())) { const appKey = 'APP_KEY'; const authKey = Platform.OS === 'ios' ? 'ّAUTH_KEY_FOR_IOS' : 'AUTH_KEY_FOR_ANDROID'; await $InTrack.init(appKey, authKey); $InTrack.start(); } ``` -------------------------------- ### Journey Webhook Body Source: https://github.com/devopssmartech/intrack-doc/blob/main/webhook/configuration.md Example JSON payload for a journey-related webhook event. ```json { "licenceCode": "", "eventName": "JOURNEY_EVENT_CREATED", "eventTime": "2021-09-21T10:30:00+0430", "type": "JOURNEY", "eventData": { "createdDate": "2021-09-21T10:30:00+0430", "modifiedDate": "2021-09-21T10:30:00+0430", "createdBy": "Hamed Alavi", "modifiedBy": "Hamed Alavi", "name": "Journey 10.2.3", "id": 1023, "status": "DRAFT", // one of: 'DRAFT', 'UPCOMING', 'RUNNING', 'ENDED', 'PAUSED', 'STOPPED' "tags": ["Adservice"] } } ``` -------------------------------- ### GET /api/sdk/track/clicked Source: https://github.com/devopssmartech/intrack-doc/blob/main/custom-channel/sending-push-notifications-via-custom-channel.md Registers a user interaction (click) on a push notification message. ```APIDOC ## GET /api/sdk/track/clicked ### Description Registers that a user has clicked on a link or button within a push notification. ### Method GET ### Endpoint /api/sdk/track/clicked ### Parameters #### Query Parameters - **token** (string) - Required - A base64-encoded JSON string containing: id (UUID), productId (Integer), userId (String), and anonymousId (String). - **button** (integer) - Optional - The index of the button that was clicked. - **url** (string) - Optional - The URL that was clicked. ``` -------------------------------- ### GET /api/sdk/track/delivered Source: https://github.com/devopssmartech/intrack-doc/blob/main/custom-channel/sending-push-notifications-via-custom-channel.md Registers that a push notification message has been successfully delivered to the recipient. ```APIDOC ## GET /api/sdk/track/delivered ### Description Registers the successful delivery of a push notification message. ### Method GET ### Endpoint /api/sdk/track/delivered ### Parameters #### Query Parameters - **token** (string) - Required - A base64-encoded JSON string containing: id (UUID), productId (Integer), userId (String), and anonymousId (String). ``` -------------------------------- ### Initialize WebView with inTrack Query Parameter Source: https://github.com/devopssmartech/intrack-doc/blob/main/llms-full.txt Configure Android WebView settings and load the URL with the required query parameter. ```kotlin val webView = view.findViewById(R.id.webview) // Find the WebView val webSettings = webView.settings // Get WebView settings // Enable JavaScript and DOM storage for the WebView webSettings.javaScriptEnabled = true webSettings.setDomStorageEnabled(true) // Load the URL with the query parameter to notify Web SDK webView.loadUrl("https://yourdomain.com?$intrack_device_id=-1") ``` -------------------------------- ### Initialize inTrack SDK in AppDelegate Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/ios-getting-started.md Configure the SDK using your APP_KEY and AUTH_KEY within the application launch method. ```objective-c - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { $InTrackConfig* config = $InTrackConfig.new; config.appKey = @"YOUR_APP_KEY"; config.authKey = @"YOUR_AUTH_KEY"; [$InTrack startWithConfig:config]; /** YOUR CODE GOES HERE **/ return YES; } ``` ```swift func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { let config: $InTrackConfig = $InTrackConfig() config.appKey = @"YOUR_APP_KEY" config.authKey = @"YOUR_AUTH_KEY" $InTrack.initWith(config); /** YOUR CODE GOES HERE **/ return true } ``` -------------------------------- ### Custom Event Webhook Payload Source: https://github.com/devopssmartech/intrack-doc/blob/main/webhook/configuration.md Example JSON structure for a custom event webhook notification. ```json { `{ "licenceCode": "", "userId": "34561", "anonymousId": "2213c9a6-a4ec-4481-a2ba-af8d72793bc0", "eventName": "update_cart", "eventTime": "2021-09-21T10:30:00+0430", "type": "CUSTOM_EVENT", "communicationId": 920, "variationId": 1003, "journeyId": 50, "eventData": { // custom attributes of event "customString": "stringValue", "customBoolean": true, "customNumber": 123, "customDate": "2021-09-21T10:30:00+0430" } } ` } ``` -------------------------------- ### Initialize inTrack Web SDK Synchronously Source: https://github.com/devopssmartech/intrack-doc/blob/main/llms-full.txt Alternative loading method. Do not use async or defer attributes when loading the script tag to avoid potential event loss or runtime exceptions. ```html ``` -------------------------------- ### InTrack.initWithConfig Source: https://github.com/devopssmartech/intrack-doc/blob/main/llms-full.txt Initializes the inTrack SDK using an InTrackConfig object containing your app and authentication keys. ```APIDOC ## InTrack.initWithConfig ### Description Initializes the inTrack SDK with the provided configuration object. This should be called after checking if the SDK is already initialized. ### Method Dart Method ### Parameters - **config** (InTrackConfig) - Required - Configuration object containing APP_KEY, Android Auth Key, and iOS Auth Key. ``` -------------------------------- ### Enriching Page Data Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/on-site.md Example of calling sendScreenInfo with custom data to trigger conditional messaging. ```javascript { `$Intk('sendScreenInfo', title: 'MY_PRODUCT', data: {price: 10000}, false);` } ``` ```javascript { `$InTrack.sendScreenInfo(title: 'MY_PRODUCT', data: {price: 10000}, false);` } ``` -------------------------------- ### Initialize On-Site Messaging Asynchronously Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/on-site.md Use this method to initialize the service when loading the SDK asynchronously. ```javascript $Intk('initOnSiteMessaging', config); ``` -------------------------------- ### Initialize inTrack SDK Source: https://github.com/devopssmartech/intrack-doc/blob/main/android/android-getting-started.md Initialize the SDK in the onCreate callback of your Application or MainActivity. ```Java $InTrack.init( new $InTrackConfig() .setApplication(this) .setAppKey("APP_KEY") .setAuthKey("AUTH_KEY") ); ``` ```Kotlin $InTrack.init( $InTrackConfig() .setApplication(this) .setAppKey("APP_KEY") .setAuthKey("AUTH_KEY") ) ``` -------------------------------- ### Initialize On-Site Messaging Synchronously Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/on-site.md Use this method to initialize the service when the SDK is available synchronously. ```javascript $InTrack.initOnSiteMessaging(config); ``` -------------------------------- ### Initialize SDK with Crash Reporting Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/ios-getting-started.md Configure the inTrack SDK during application launch with crash reporting enabled. ```c { `-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { $InTrackConfig* config = $InTrackConfig.new; config.appKey = @"YOUR_APP_KEY"; config.authKey = @"YOUR_AUTH_KEY"; config.enableCrashReporting = YES; [$InTrack startWithConfig:config]; /** YOUR CODE GOES HERE **/ return YES; } ` } ``` ```swift { `func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptio [UIApplicationLaunchOptionsKey: Any]?) -> Bool { let config: $InTrackConfig = $InTrackConfig() config.appKey = @"YOUR_APP_KEY" config.authKey = @"YOUR_AUTH_KEY" config.enableCrashReporting = true $InTrack.initWith(config) /** YOUR CODE GOES HERE **/ return true } ` } ``` -------------------------------- ### Record Custom Event in Flutter Source: https://github.com/devopssmartech/intrack-doc/blob/main/flutter/tracking-events.md Example of calling recordEvent with event name and nested event details. ```dart { `$InTrack.recordEvent({ eventName: 'my-custom-event', eventDetails: { count: 1000, label: 'two', accepted: false, date: '1970-01-01', myDetails: { one: 1, myList: ['firstValue', 'secondValue'], }, }, }); ` } ``` -------------------------------- ### Configure Web SDK with Platform Auth Keys Source: https://github.com/devopssmartech/intrack-doc/blob/main/web-view/implementaion-guide.md Add Android and iOS auth keys to the inTrack configuration object to enable cross-platform synchronization. ```javascript var $inTrack_config = { app_key: 'Provided_App_Key', auth_key: 'Provided_Auth_Key_for_Web', public_key: 'Provided_Public_Key', android_auth_key: 'Provided_Auth_key_for_Android', // HERE ios_auth_key: 'Provided_Auth_key_for_iOS' // HERE }; ``` -------------------------------- ### Configure ProGuard Rules Source: https://github.com/devopssmartech/intrack-doc/blob/main/android/android-getting-started.md Add these rules to your proguard-rules.pro file if minify and shrinking are enabled. ```text -dontwarn io.reactivex.** -keep class io.reactivex.** { *; } -keep class ir.intrack.android.sdk.** { *; } -keep class sdk.main.core.** { *; } ``` -------------------------------- ### Communication Webhook Payload Example Source: https://github.com/devopssmartech/intrack-doc/blob/main/webhook/configuration.md Represents the JSON structure sent when a communication event occurs, such as creation or update. ```json { "licenceCode": "", "eventName": "COMMUNICATION_EVENT_CREATED", "eventTime": "2021-09-21T10:30:00+0430", "type": "COMMUNICATION", "eventData": { "createdDate": "2021-09-21T10:30:00+0430", "modifiedDate": "2021-09-21T10:30:00+0430", "createdBy": "Hamed Alavi", "modifiedBy": "Hamed Alavi", "name": "Sending Test SMS", "id": 1023, "type": "ONE_TIME", "channel": "SMS", "status": "DRAFT", "tags": ["Adservice"] } } ``` -------------------------------- ### Configure Podfile Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/ios-getting-started.md Add the inTrack SDK dependency to the project target within the Podfile. ```ruby target 'YourAppTarget' do platform :ios,'9.0' pod '$InTrackSDK', '3.0.3' end ``` -------------------------------- ### Initialize On-Site Messaging Source: https://github.com/devopssmartech/intrack-doc/blob/main/llms-full.txt Use these methods to initialize the messaging service. Ensure the latest SDK is loaded before calling. ```javascript $Intk('initOnSiteMessaging', config); ``` ```javascript $InTrack.initOnSiteMessaging(config); ``` -------------------------------- ### Call onStart in MainActivity Source: https://github.com/devopssmartech/intrack-doc/blob/main/android/android-getting-started.md Add the onStart call to the onStart method of your main activity. ```Java $InTrack.onStart(this); ``` ```Kotlin $InTrack.onStart(this) ``` -------------------------------- ### Initialization Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/ios-inapp-messaging.md Enable in-app messaging during the InTrack SDK initialization process. ```APIDOC ## Initialization ### Description Enable the In-App messaging service by setting the `enableInAppMessaging` property on the `InTrackConfig` object before starting the SDK. ### Objective-C ```objectivec $InTrackConfig* config = $InTrackConfig.new; config.appKey = @"YOUR_APP_KEY"; config.authKey = @"YOUR_AUTH_KEY"; config.enableInAppMessaging = YES; [$InTrack startWithConfig:config]; ``` ### Swift ```swift let config: $InTrackConfig = $InTrackConfig() config.appKey = @"YOUR_APP_KEY" config.authKey = @"YOUR_AUTH_KEY" config.enableInAppMessaging = true $InTrack.initWith(config) ``` ``` -------------------------------- ### Initialize In-app Messaging with Advanced Options Source: https://github.com/devopssmartech/intrack-doc/blob/main/android/inapp-messaging.md Configure auto-tracking and naming preferences for activities and fragments during initialization. ```java $InTrack.init( new $InTrackConfig() .setApplication(this) .setAppKey("APP_KEY") .setAuthKey("AUTH_KEY") .enableInAppMessaging(true, true) // <-- HERE ); ``` ```kotlin $InTrack.init( $InTrackConfig() .setApplication(this) .setAppKey("APP_KEY") .setAuthKey("AUTH_KEY") .enableInAppMessaging( enableAutoTracking: true, useActivityShortName: true ); //<-- HERE ) ``` -------------------------------- ### Registering Message Delivery via REST API Source: https://github.com/devopssmartech/intrack-doc/blob/main/custom-channel/sending-push-notifications-via-custom-channel.md Sends a GET request to the delivery tracking endpoint with a base64-encoded token containing message and user identifiers. ```json { `curl -X GET $https://api.intrack.ir//api/sdk/track/delivered?token=ewogICAgImlkIjogIjEyM2U0NTY3LWU4OWItMTJkMy1hNDU2LTQyNjY1MjM0MDAwMCIsCiAgICAicHJvZHVjdElkIjogMSwKICAgICJ1c2VySWQiOiAiMDAwMSIKfQ ` } ``` -------------------------------- ### Initialize inTrack SDK Source: https://github.com/devopssmartech/intrack-doc/blob/main/flutter/flutter-getting-started.md Initialize the SDK within the initState method of your main application. ```dart $InTrack.isInitialized().then((bool isInitialized) { if (!isInitialized) { $InTrackConfig config = $InTrackConfig("YOUR_APP_KEY") ..setAndroidAuthKey("YOUR_ANDROID_AUTH_KEY") ..setIOSAuthKey("YOUR_IOS_AUTH_KEY") $InTrack.initWithConfig(config).then((value) { print('$inTrack $value'); //you can enable push notification here }); } }); ``` -------------------------------- ### Enable SDK Logging Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/web-getting-started.md Set the debug flag to true in the configuration object to output internal SDK state and errors to the browser console. ```html ``` ```html ``` -------------------------------- ### Initialize Push Notifications Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/push-messaging.md Initializes the inTrack push notification service using a configuration object. ```APIDOC ## [InTrack initPush] ### Description Initializes the push notification service for the inTrack SDK. This method handles device token registration and notification reception automatically. ### Method SDK Method ### Parameters - **pushConfig** (InTrackPushConfig) - Required - Configuration object for push notifications. ``` -------------------------------- ### Configure WebEngage in AppDelegate Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/push-messaging.md Initialize WebEngage and register for remote notifications within the AppDelegate. ```objectivec #import "AppDelegate.h" #import #import "GeneratedPluginRegistrant.h" #import @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [GeneratedPluginRegistrant registerWithRegistry:self]; [WebEngage sharedInstance].pushNotificationDelegate = self.bridge; [[WebEngage sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions notificationDelegate:self.bridge]; [[UIApplication sharedApplication] registerForRemoteNotifications]; [UNUserNotificationCenter currentNotificationCenter].delegate = self; return [super application:application didFinishLaunchingWithOptions:launchOptions]; } @end ``` ```swift override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { GeneratedPluginRegistrant.register(with: self) WebEngage.sharedInstance().pushNotificationDelegate = self.bridge WebEngage.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions, notificationDelegate: self.bridge) UIApplication.shared.registerForRemoteNotifications() UNUserNotificationCenter.current().delegate = self return super.application(application, didFinishLaunchingWithOptions: launchOptions) } ``` -------------------------------- ### Configure Proguard Rules Source: https://github.com/devopssmartech/intrack-doc/blob/main/react-native/react-native-getting-started.md Add these rules to your Proguard configuration file to prevent issues with SDK obfuscation. ```proguard -keep class com.google.android.gms.ads.**{*;} -dontwarn io.reactivex.** -keep class io.reactivex.** { *; } -keep class ir.intrack.android.sdk.** { *; } -keep class sdk.main.core.** { *; } ``` -------------------------------- ### Initialize Push Notification Service Source: https://github.com/devopssmartech/intrack-doc/blob/main/flutter/push-messaging.md Initialize the inTrack SDK and request notification permissions after checking the initialization status. ```dart { `$InTrack.isInitialized().then((bool isInitialized) { if (!isInitialized) { $InTrackConfig config = $InTrackConfig(APP_KEY) ..setAndroidAuthKey(ANDROID_AUTH_KEY) ..setIOSAuthKey(IOS_AUTH_KEY) config.setLoggingEnabled(true); $InTrack.initWithConfig(config).then((value) { // This method will ask for permission, enables push notification channel and send push token to $inTrack server.; $InTrack.askForNotificationPermission(); }); // Initialize the $InTrack SDK. } }); ` } ``` -------------------------------- ### Initialize In-app Messaging Source: https://github.com/devopssmartech/intrack-doc/blob/main/android/inapp-messaging.md Basic initialization of in-app messaging during SDK startup. ```java $InTrack.init( new $InTrackConfig() .setApplication(this) .setAppKey("APP_KEY") .setAuthKey("AUTH_KEY") .enableInAppMessaging() // <-- HERE ); ``` ```kotlin $InTrack.init( $InTrackConfig() .setApplication(this) .setAppKey("APP_KEY") .setAuthKey("AUTH_KEY") .enableInAppMessaging() // <-- HERE ) ``` -------------------------------- ### $InTrack.initNotificationService() Source: https://github.com/devopssmartech/intrack-doc/blob/main/llms-full.txt Initializes the inTrack notification service within the application lifecycle. ```APIDOC ## $InTrack.initNotificationService() ### Description Initializes the notification service. This method must be called after $InTrack.init() and before $InTrack.start(). ``` -------------------------------- ### $Intk('sendEvent', ...) Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/on-site.md Asynchronous method to send an on-site system event. ```APIDOC ## Asynchronous Event Tracking ### Description Sends an asynchronous event to the InTrack system, specifically used for tracking the closing of on-site messages. ### Method $Intk('sendEvent', payload) ### Parameters - **eventName** (string) - Required - The name of the event (e.g., 'ON_SITE_CLOSED') - **eventData** (object) - Required - Contains the 'id' of the message - **isSystem** (boolean) - Required - Must be set to true for system events ### Request Example $Intk('sendEvent', { eventName: 'ON_SITE_CLOSED', eventData: { id: '' }, isSystem: true }); ``` -------------------------------- ### InTrackConfig Configuration Methods Source: https://github.com/devopssmartech/intrack-doc/blob/main/android/android-getting-started.md Methods available on the InTrackConfig object during initialization to control SDK behavior. ```APIDOC ## InTrackConfig Configuration ### Description Configure the SDK behavior during initialization using the InTrackConfig object. ### Methods - **setLoggingEnabled(boolean enabled)**: Enables or disables internal SDK debug logging. - **enableCrashReporting()**: Enables automatic collection of uncaught Java exceptions. - **seCollectAdvertisingId(boolean collect)**: Enables or disables the collection of the Google Advertising ID. ``` -------------------------------- ### Initialize Push Notifications in iOS Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/push-messaging.md Initializes the inTrack SDK and push configuration within the application delegate. Do not manually set the UNUserNotificationCenter delegate as the SDK handles this automatically. ```objectivec - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { $InTrackConfig* config = $InTrackConfig.new; config.appKey = @"YOUR_APP_KEY"; config.authKey = @"YOUR_AUTH_KEY"; config.enableCrashReporting = YES; [$InTrack startWithConfig:config]; $InTrackPushConfig* pushConfig = $InTrackPushConfig.new; // pushConfig.doNotShowAlertForNotifications = NO; [$InTrackPush startWithConfig:pushConfig]; //Ask for user's permission for Push Notifications (not necessarily here) //You can do this later at any point in the app after starting $InTrack push service. [$InTrack askForNotificationPermission]; /** YOUR CODE GOES HERE **/ return YES; } ``` ```swift func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { let config: $InTrackConfig = $InTrackConfig() config.appKey = "YOUR_APP_KEY" config.authKey = "YOUR_AUTH_KEY" $InTrack.initWith(config) // initialize push let pushConfig: $InTrackPushConfig = $InTrackPushConfig() // pushConfig.doNotShowAlertForNotifications = false $InTrack.initPush(pushConfig) //Ask for user's permission for Push Notifications (not necessarily here) //You can do this later at any point in the app after starting $InTrack push service. $InTrack.askForNotificationPermission() /** YOUR CODE GOES HERE **/ return true } ``` -------------------------------- ### Enable Subscription Widget Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/web-push-notification.md Configuration snippet to enable the subscription widget within the webPushConfig object. ```jsx webPushConfig: { ... widget: { enable: true, } } ``` -------------------------------- ### $InTrack.recordLogin(UserDetails details) Source: https://github.com/devopssmartech/intrack-doc/blob/main/android/tracking-users.md Records a login event with associated user details, including custom attributes defined as a HashMap. ```APIDOC ## $InTrack.recordLogin(UserDetails details) ### Description Records a login event for a user. Custom attributes can be attached to the user via the UserDetails object. ### Parameters - **details** (UserDetails) - Required - An object containing the userId and a HashMap of userAttributes (keys must be < 50 characters). ``` -------------------------------- ### initOnSiteMessaging(displayMessage) Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/on-site.md Initialize on-site messaging and provide a custom callback function to handle how messages are displayed to the user. ```APIDOC ## initOnSiteMessaging(displayMessage) ### Description Registers a custom function to handle the display of campaign messages when conditions are met. ### Parameters - **displayMessage** (Function) - Required - A callback function that receives the message data object. ### Usage ```javascript // Asynchronous $Intk('initOnSiteMessaging', { displayMessage: (data) => { console.log('message data', data); } }); // Synchronous $InTrack.initOnSiteMessaging({ displayMessage: (data) => { console.log('message data', data); } }); ``` ``` -------------------------------- ### Configure Proguard rules for inTrack Source: https://github.com/devopssmartech/intrack-doc/blob/main/flutter/flutter-getting-started.md Add these rules to your Proguard configuration file to prevent code shrinking from breaking SDK functionality. ```json -keep class com.google.android.gms.ads.**{*;} -dontwarn io.reactivex.** -keep class io.reactivex.** { *; } -keep class ir.intrack.android.sdk.** { *; } -keep class sdk.main.core.** { *; } ``` -------------------------------- ### $InTrack.recordLogin Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/tracking-users.md Records a login event for a user with the provided user details. ```APIDOC ## $InTrack.recordLogin(userDetails) ### Description Records the login event for the current user session using the configured InTrackUserDetails object. ### Parameters - **userDetails** (InTrackUserDetails) - Required. The object containing user attributes to be tracked. ``` -------------------------------- ### Initialize Web Push Notification Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/web-push-notification.md Call this method after SDK initialization to enable web push functionality. ```jsx { `$Intk('InitWebPush', webPushConfig);` } ```