### Firebase Integration Example (Synchronous) Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/web-push-notification.md Example demonstrating how to get a Firebase token and send it to inTrack synchronously. Requires Firebase JS SDK setup. ```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); // ... });`} ``` -------------------------------- ### Firebase Integration Example (Asynchronous) Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/web-push-notification.md Example demonstrating how to get a Firebase token and send it to inTrack asynchronously. Requires Firebase JS SDK setup. ```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); // ... });`} ``` -------------------------------- ### Install iOS Pods Source: https://github.com/devopssmartech/intrack-doc/blob/main/react-native/react-native-getting-started.md After installing the library, navigate to the ios directory and install CocoaPods dependencies. ```bash (cd ios && pod install) ``` -------------------------------- ### Manual Subscription Example (Asynchronous) Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/web-push-notification.md Example demonstrating how to manually subscribe a user to push notifications using browser APIs and send the resulting PushSubscription object to inTrack asynchronously. ```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); }); });`} ``` -------------------------------- ### Install CocoaPods Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/ios-getting-started.md Use this command to install the CocoaPods dependency manager on your system. ```shell $ sudo gem install cocoapods ``` -------------------------------- ### Install inTrack SDK via CocoaPods Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/ios-getting-started.md Execute this command in your Xcode project directory after updating your Podfile to install the inTrack SDK. ```shell $ pod install ``` -------------------------------- ### Android MainActivity Setup (Kotlin) Source: https://github.com/devopssmartech/intrack-doc/blob/main/flutter/inapp-messaging.md For Android, ensure your `MainActivity` extends `FlutterFragmentActivity` or an activity that has set `ViewTreeLifeCycleOwner` on its `decorView`. ```kotlin import io.flutter.embedding.android.FlutterFragmentActivity public class MainActivity : FlutterFragmentActivity { } ``` -------------------------------- ### Android MainActivity Setup Source: https://github.com/devopssmartech/intrack-doc/blob/main/flutter/inapp-messaging.md For Android, ensure your `MainActivity` extends `FlutterFragmentActivity` or an activity that has set `ViewTreeLifeCycleOwner` on its `decorView`. ```java import io.flutter.embedding.android.FlutterFragmentActivity; public class MainActivity extends FlutterFragmentActivity { } ``` -------------------------------- ### Initialize inTrack SDK with Configuration Source: https://github.com/devopssmartech/intrack-doc/blob/main/flutter/flutter-getting-started.md Initialize the inTrack SDK in your main application file using your app and authentication keys. This example checks if the SDK is already initialized before proceeding. ```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 }); } }); ``` -------------------------------- ### Sample Profile Update Event Source: https://github.com/devopssmartech/intrack-doc/blob/main/react-native/tracking-users.md An example of the data object structure for the updateProfile method, demonstrating how to change first and last names. ```javascript const data = { firstName: 'firstname-changed', lastName: 'lastname-changed', }; $InTrack.updateProfile(data); ``` -------------------------------- ### Sample Profile Update Event Source: https://github.com/devopssmartech/intrack-doc/blob/main/flutter/tracking-users.md Example of a profile update event with specific attributes like first name and last name. ```dart {`const data = { 'firstName': 'firstname_changed', 'lastName': 'lastname_changed', } $InTrack.updateProfile(data);`} ``` -------------------------------- ### Sample Login Event with Custom Attributes Source: https://github.com/devopssmartech/intrack-doc/blob/main/flutter/tracking-users.md An example demonstrating how to populate the UserDetails object with both standard and custom attributes for the recordLogin event. This showcases how to include various data types for user profiling. ```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); ``` -------------------------------- ### Initialize inTrack Notification Service Source: https://github.com/devopssmartech/intrack-doc/blob/main/react-native/push-messaging.md Initialize the inTrack SDK with your app credentials and then call initNotificationService. This should be done before calling start() and after init(). ```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(); } }; ``` -------------------------------- ### Initialize InTrack SDK and Push Service (Objective-C) Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/push-messaging.md Initialize the InTrack SDK and its push notification service in your application's delegate. This snippet shows the basic setup for app key, auth key, and enabling crash reporting. ```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; } } ``` -------------------------------- ### Sample Login Event with Custom Attributes Source: https://github.com/devopssmartech/intrack-doc/blob/main/react-native/tracking-users.md Provides a practical example of calling the `login` method with a populated `userDetails` object, including various custom attributes like strings, booleans, numbers, and dates. ```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); } ``` -------------------------------- ### Install inTrack React Native Library with npm Source: https://github.com/devopssmartech/intrack-doc/blob/main/react-native/react-native-getting-started.md Use this command to add the inTrack React Native bridge to your project via npm. ```npm npm install --save $intrack-react-native-bridge@3.0.3 ``` -------------------------------- ### Send Custom Page Info (Synchronous) Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/on-site.md Example of sending custom page information synchronously, including a product title and price data. ```javascript { `$InTrack.sendScreenInfo(title: 'MY_PRODUCT', data: {price: 10000}, false); }` } ``` -------------------------------- ### Send Custom Page Info (Asynchronous) Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/on-site.md Example of sending custom page information asynchronously, including a product title and price data. ```javascript { `$Intk('sendScreenInfo', title: 'MY_PRODUCT', data: {price: 10000}, false); }` } ``` -------------------------------- ### Install inTrack React Native Library with Yarn Source: https://github.com/devopssmartech/intrack-doc/blob/main/react-native/react-native-getting-started.md Use this command to add the inTrack React Native bridge to your project via Yarn. ```yarn yarn add $intrack-react-native-bridge@3.0.3 ``` -------------------------------- ### Example Transactional Campaign API Request Source: https://github.com/devopssmartech/intrack-doc/blob/main/rest-api/transactional-campaign-api.md Use this cURL command to send a POST request to the Transactional Campaign API. Ensure your API key, license code, and request details are correctly formatted. The API triggers campaigns that are in the 'Running' state on the inTrack dashboard. ```bash curl -X POST /api/sdk/accounts//transactionCommunication \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "communicationId": 5, "userId": "userId", "anonymousId": null, "variationTokens": { "someMessageToken": "desired value" }, "overrideData": { "email": "12@3", "phone": "09379897845", "queueMinutes": 2 } }' ``` -------------------------------- ### Initialize inTrack SDK with Options Source: https://github.com/devopssmartech/intrack-doc/blob/main/react-native/react-native-getting-started.md Initialize the inTrack SDK with your app and authentication keys. This method should be called early in your application's lifecycle. ```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(); } ``` -------------------------------- ### Asynchronous inTrack SDK Initialization Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/web-getting-started.md Use this snippet to asynchronously load and initialize the inTrack SDK. It's the recommended method for better performance. Ensure the configuration object contains your app, auth, and public keys. ```html ``` -------------------------------- ### Get Subscription Status (Synchronous) Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/web-push-notification.md Call this function to get the current web push notification subscription status. The status is returned directly. ```jsx {`$InTrack.SubscriptionWebPushInfo(callBack);`} ``` -------------------------------- ### Initialize inTrack SDK in Swift Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/ios-getting-started.md Initialize the inTrack SDK with your APP_KEY and AUTH_KEY in the application:didFinishLaunchingWithOptions: method of your AppDelegate. ```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 } ``` -------------------------------- ### Get User ID Source: https://github.com/devopssmartech/intrack-doc/blob/main/flutter/tracking-users.md Retrieves the user ID for tracking known users. ```APIDOC ## Get User ID ### Description Retrieves the user identifier for tracking known users. ### Method `$InTrack.getUserId()` ### Parameters None ### Request Example ```dart String? userId = await $InTrack.getUserId(); ``` ### Response - **userId** (String?) - The user identifier. ``` -------------------------------- ### Initialize inTrack SDK in Objective-C Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/ios-getting-started.md Initialize the inTrack SDK with your APP_KEY and AUTH_KEY in the application:didFinishLaunchingWithOptions: method of your AppDelegate. ```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; } ``` -------------------------------- ### Get User ID (Kotlin) Source: https://github.com/devopssmartech/intrack-doc/blob/main/android/tracking-users.md Retrieve the user ID for tracking known users. ```kotlin val deviceId: String = $InTrack.getUserId() ``` -------------------------------- ### Get User ID (Java) Source: https://github.com/devopssmartech/intrack-doc/blob/main/android/tracking-users.md Retrieve the user ID for tracking known users. ```java String deviceId = $InTrack.getUserId(); ``` -------------------------------- ### Get User ID (Swift) Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/tracking-users.md Retrieve the user ID for tracking known users in Swift. ```Swift let userId = $InTrack.getUserId(); ``` -------------------------------- ### Initialize inTrack SDK (Kotlin) Source: https://github.com/devopssmartech/intrack-doc/blob/main/android/android-getting-started.md Initialize the inTrack SDK in your Application or MainActivity's onCreate callback using your APP_KEY and AUTH_KEY. This is a required step for SDK functionality. ```Kotlin $InTrack.init( $InTrackConfig() .setApplication(this) .setAppKey("APP_KEY") .setAuthKey("AUTH_KEY") ) ``` -------------------------------- ### Get User ID (Objective-C) Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/tracking-users.md Retrieve the user ID for tracking known users in Objective-C. ```Objective-C NSString *_Nullable userId = [$InTrack getUserId]; ``` -------------------------------- ### Create Podfile Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/ios-getting-started.md Run this command in your Xcode project directory to create a Podfile for managing dependencies. ```shell $ pod init ``` -------------------------------- ### Call onStart for inTrack SDK (Java) Source: https://github.com/devopssmartech/intrack-doc/blob/main/android/android-getting-started.md Add the $InTrack.onStart(this) call in the onStart method of your main activity to ensure proper SDK operation. ```Java $InTrack.onStart(this); ``` -------------------------------- ### Unsubscribe Button (Synchronous) Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/web-push-notification.md An example of an HTML button that triggers the synchronous unsubscription process when clicked. ```jsx {``} ``` -------------------------------- ### Unsubscribe Button (Asynchronous) Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/web-push-notification.md An example of an HTML button that triggers the asynchronous unsubscription process when clicked. ```jsx {``} ``` -------------------------------- ### Initialize inTrack SDK (Java) Source: https://github.com/devopssmartech/intrack-doc/blob/main/android/android-getting-started.md Initialize the inTrack SDK in your Application or MainActivity's onCreate callback using your APP_KEY and AUTH_KEY. This is a required step for SDK functionality. ```Java $InTrack.init( new $InTrackConfig() .setApplication(this) .setAppKey("APP_KEY") .setAuthKey("AUTH_KEY") ); ``` -------------------------------- ### Call onStart for inTrack SDK (Kotlin) Source: https://github.com/devopssmartech/intrack-doc/blob/main/android/android-getting-started.md Add the $InTrack.onStart(this) call in the onStart method of your main activity to ensure proper SDK operation. ```Kotlin $InTrack.onStart(this) ``` -------------------------------- ### Get Device ID Source: https://github.com/devopssmartech/intrack-doc/blob/main/flutter/tracking-users.md Retrieves the automatically generated device or anonymous ID for tracking unknown users. ```APIDOC ## Get Device ID ### Description Retrieves the unique device identifier (anonymousId) generated by the inTrack SDK for tracking unknown users. ### Method `$InTrack.getDeviceId()` ### Parameters None ### Request Example ```dart String? deviceId = await $InTrack.getDeviceId(); ``` ### Response - **deviceId** (String?) - The unique device identifier. ``` -------------------------------- ### Synchronous inTrack SDK Initialization Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/web-getting-started.md Use this snippet for synchronous initialization of the inTrack SDK. This method requires placing the script tag in the head and the init call immediately after. Avoid async or defer attributes with this method. ```html ``` -------------------------------- ### Add inTrack Flutter SDK Dependency Source: https://github.com/devopssmartech/intrack-doc/blob/main/flutter/flutter-getting-started.md Install the inTrack Flutter SDK using the Flutter package manager. ```sh flutter pub add $intrack_flutter ``` -------------------------------- ### Initialize WebEngage SDK and Register for Push Notifications (Objective-C) Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/push-messaging.md Set up the WebEngage SDK and register for remote notifications in your AppDelegate. Ensure the push notification delegate is correctly assigned. ```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 ``` -------------------------------- ### Get Device/Anonymous ID (Synchronous) Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/tracking-users.md Retrieve the device or anonymous ID synchronously. This method directly returns the ID. ```javascript const deviceId = $InTrack.getDeviceId(); console.log("Device a.k.a. Anonymous id: ", deviceId); ``` -------------------------------- ### Initialize InTrack SDK and Push Service (Swift) Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/push-messaging.md Initialize the InTrack SDK and its push notification service in your application's delegate using Swift. This includes setting up app key, auth key, and the push configuration. ```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 } } ``` -------------------------------- ### Get User ID Source: https://github.com/devopssmartech/intrack-doc/blob/main/react-native/tracking-users.md Retrieve the userId for tracking known users. The callback function receives the user ID. ```javascript $InTrack.getUserId(userId => { console.log('$inTrack userId', userId); }); ``` -------------------------------- ### Initialize inTrack SDK and Ask for Notification Permission Source: https://github.com/devopssmartech/intrack-doc/blob/main/flutter/push-messaging.md Initialize the inTrack SDK with your configuration and then call askForNotificationPermission(). This function requests user permission, sets up the notification channel, and sends the push token to the inTrack server. ```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. } }); ``` -------------------------------- ### Get Device ID (Swift) Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/tracking-users.md Retrieve the automatically generated device ID for tracking anonymous users in Swift. ```Swift let deviceId = $InTrack.getDeviceId(); ``` -------------------------------- ### Get Device ID (Objective-C) Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/tracking-users.md Retrieve the automatically generated device ID for tracking anonymous users in Objective-C. ```Objective-C NSString *_Nullable deviceId = [$InTrack getDeviceId]; ``` -------------------------------- ### Get Device/Anonymous ID (Kotlin) Source: https://github.com/devopssmartech/intrack-doc/blob/main/android/tracking-users.md Retrieve the automatically generated random ID for each device, referred to as deviceId or anonymousId. ```kotlin val deviceId: String = $InTrack.getDeviceId() ``` -------------------------------- ### Get Device/Anonymous ID (Java) Source: https://github.com/devopssmartech/intrack-doc/blob/main/android/tracking-users.md Retrieve the automatically generated random ID for each device, referred to as deviceId or anonymousId. ```java String deviceId = $InTrack.getDeviceId(); ``` -------------------------------- ### Initialize inTrack SDK (Older Versions) Source: https://github.com/devopssmartech/intrack-doc/blob/main/react-native/react-native-getting-started.md For inTrack SDK versions 1.2.1 or older, initialize using separate appKey and authKey parameters, with authKey conditionally set based on the platform. ```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(); } ``` -------------------------------- ### Get User ID (Synchronous) Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/tracking-users.md Retrieve the user ID for a known user synchronously. This method directly returns the ID. ```javascript const userId = $InTrack.getUserId(); console.log("userId : ", userId); ``` -------------------------------- ### Get User ID for Known Users Source: https://github.com/devopssmartech/intrack-doc/blob/main/flutter/tracking-users.md Retrieve the user ID for tracking known users by calling the getUserId method. ```dart {`String? userId = await $InTrack.getUserId();`} ``` -------------------------------- ### Record Login with User Details (Swift) Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/tracking-users.md This Swift snippet demonstrates how to record a login event, setting various user details and custom attributes. It's essential to provide a valid `userId` and other required information. ```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) ``` -------------------------------- ### Initialize WebEngage SDK and Register for Push Notifications (Swift) Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/push-messaging.md Configure the WebEngage SDK and initiate the device registration for remote notifications within your AppDelegate. The push notification delegate must be set. ```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) } ``` -------------------------------- ### Get User ID (Asynchronous) Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/tracking-users.md Retrieve the user ID for a known user after they have logged in. This method is asynchronous and uses a callback function. ```javascript $Intk('getUserId', (userId) => { console.log("userId : ", userId) }); ``` -------------------------------- ### Initialize inTrack SDK with Logging Enabled Source: https://github.com/devopssmartech/intrack-doc/blob/main/react-native/react-native-getting-started.md Enable internal logging for the inTrack SDK during initialization to aid in troubleshooting and monitoring. ```javascript if (!(await $InTrack.isInitialized())) { const options = { appKey: 'APP_KEY', iosAuthKey: 'ّAUTH_KEY_FOR_IOS', androidAuthKey: 'AUTH_KEY_FOR_ANDROID', loggingEnabled: true, // <-- HERE }; await $InTrack.init(options); $InTrack.start(); } ``` -------------------------------- ### Example Telegram Bot API Token Source: https://github.com/devopssmartech/intrack-doc/blob/main/custom-channel/telegram-provider.md This snippet shows the format of a Telegram Bot API token. Obtain this token from @BotFather. ```jsx {`4839574812:AAFD39kkdpWt3ywyRZergyOLMaJhac60qc`} ``` -------------------------------- ### Initialize On-Site Messaging (Asynchronous) Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/on-site.md Use this method to initialize the On-Site messaging service asynchronously. It accepts an optional configuration object. ```javascript {`$Intk('initOnSiteMessaging', config); }`} ``` -------------------------------- ### Add inTrack SDK to Podfile Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/ios-getting-started.md Specify the inTrack SDK and its version in your Podfile to include it as a project dependency. ```ruby target 'YourAppTarget' do platform :ios,'9.0' pod '$InTrackSDK', '3.0.3' end ``` -------------------------------- ### Synchronous inTrack SDK Initialization with Debugging Enabled Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/web-getting-started.md Initialize the inTrack SDK synchronously with debugging enabled. This logs debug messages to the console. Ensure the script is placed in the head and the init call follows immediately, without async or defer attributes. ```html ``` -------------------------------- ### Initialize On-Site Messaging (Synchronous) Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/on-site.md Use this method to initialize the On-Site messaging service synchronously. It accepts an optional configuration object. ```javascript {`$InTrack.initOnSiteMessaging(config); }`} ``` -------------------------------- ### Get Device ID Source: https://github.com/devopssmartech/intrack-doc/blob/main/react-native/tracking-users.md Retrieve the automatically generated deviceId or anonymousId for tracking unknown users. The callback function receives the device ID. ```javascript $InTrack.getDeviceId(deviceId => { console.log('$inTrack deviceId', deviceId); }); ``` -------------------------------- ### Initialize Web Push Asynchronously Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/web-push-notification.md Call the $Intk('InitWebPush', webPushConfig) method to initialize the inTrack notification service asynchronously. This should be done after importing $inTrack.js and calling $InTrack.init(). ```jsx { `$Intk('InitWebPush', webPushConfig);` } ``` -------------------------------- ### Initialize InTrack SDK with In-App Messaging (Swift) Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/ios-inapp-messaging.md Initialize the InTrack SDK with your application's configuration, including enabling In-App Messaging and setting a display delegate. Ensure you replace placeholder values with your actual app and auth keys. ```swift { `let config: $InTrackConfig = $InTrackConfig() config.appKey = @"YOUR_APP_KEY" config.authKey = @"YOUR_AUTH_KEY" config.enableInAppMessaging = true config.inAppDisplayDelegate = self $InTrack.initWith(config) ` } ``` -------------------------------- ### Example Batch Webhook Response Source: https://github.com/devopssmartech/intrack-doc/blob/main/webhook/configuration.md This JSON structure represents a batch webhook response, which is an array containing multiple communication event objects. ```json [ { // same objects as above } ] ``` -------------------------------- ### Configure SDK for Ad Network Syncing Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/web-getting-started.md Add these properties to your SDK configuration object to enable syncing user IDs with YektaNet and MediaAD. ```javascript var $intrack_config = { app_key: 'Provided_App_Key', auth_key: 'Provided_Auth_Key', public_key: 'Provided_Public_Key', environment: 'production', yektanet_syncing: true, //<-- sync $intrack user id with yektaNet mediaad_syncing: true, //<-- sync $intrack user id with mediaAD } ``` -------------------------------- ### Update iOS Podfile for SDK V3 Source: https://github.com/devopssmartech/intrack-doc/blob/main/migration/migration-v2-to-v3.md Starting from SDK v3.0, the SDK is renamed from InTrack to InTrackSDK. Update your Podfile to reflect this change. ```ruby { `pod '$InTrackSDK'` } ``` -------------------------------- ### Get Device/Anonymous ID (Asynchronous) Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/tracking-users.md Retrieve the automatically generated device or anonymous ID for unknown users. This method is asynchronous and uses a callback function. ```javascript $Intk('getDeviceId', (deviceId) => { console.log("Device a.k.a. Anonymous id: ", deviceId) }); ``` -------------------------------- ### Get Device ID for Anonymous Tracking Source: https://github.com/devopssmartech/intrack-doc/blob/main/flutter/tracking-users.md Retrieve the automatically generated random ID for each device, referred to as deviceId or anonymousId, used for tracking unknown users. ```dart {`String? deviceId = await $InTrack.getDeviceId();`} ``` -------------------------------- ### Batch User Creation API Request Source: https://github.com/devopssmartech/intrack-doc/blob/main/rest-api/tracking-users.md Use this endpoint to create or update multiple users in a single request. Ensure you replace placeholders like , , and with your actual credentials. ```bash curl -X POST "/api/sdk/accounts//usersBatch" \ --header "Authorization: Bearer " \ --header "Content-Type: application/json" \ --data '{ \ "list": [ \ { \ "userId": "str", \ "anonymousId": "str", \ "firstName": "str", \ "lastName": "str", \ "birthday": "1980-07-09T03:28:38+04:30", \ "gender": "male", \ "email": "user@email.com", \ "emailOptIn": false, \ "phone": "+989121234567", \ "hashedPhone": "+98********67", \ "hashedEmail": "u1******.com", \ "smsOptIn": false, \ "pushOptIn": false, \ "webPushOptIn": false, \ "company": "str", \ "country": "str", \ "city": "str", \ "state": "str", \ "attributes": { \ "additionalProp1": "value1", \ "additionalProp2": 123.4, \ "additionalProp3": "1988-11-11T00:00:00+0000", \ "field4": true \ } \ }, \ { \ "userId": "str", \ "anonymousId": "str", \ "firstName": "str", \ "lastName": "str", \ "birthday": "1980-07-09T03:28:38+04:30", \ "gender": "male", \ "email": "user@email.com", \ "emailOptIn": false, \ "phone": "+989121234567", \ "hashedPhone": "+98********67", \ "hashedEmail": "u1******.com", \ "smsOptIn": false, \ "pushOptIn": false, \ "webPushOptIn": false, \ "company": "str", \ "country": "str", \ "city": "str", \ "state": "str", \ "attributes": { \ "additionalProp1": "value1", \ "additionalProp2": 123.4, \ "additionalProp3": "1988-11-11T00:00:00+0000", \ "field4": true \ } \ } \ ] \ }' ``` -------------------------------- ### Registering Delivery of Message Source: https://github.com/devopssmartech/intrack-doc/blob/main/custom-channel/sending-push-notifications-via-custom-channel.md Register a message as successfully delivered to the recipient by sending a GET request to the /api/sdk/track/delivered endpoint. The request requires a base64-encoded token containing message details. ```APIDOC ## GET /api/sdk/track/delivered ### Description Registers a message as successfully delivered to the recipient. ### Method GET ### Endpoint /api/sdk/track/delivered ### Parameters #### Query Parameters - **token** (string) - Required - A base64-encoded string representing a JSON object with message details (id, productId, userId, anonymousId). ### Request Example ```json { `curl -X GET $https://api.intrack.ir//api/sdk/track/delivered?token=ewogICAgImlkIjogIjEyM2U0NTY3LWU4OWItMTJkMy1hNDU2LTQyNjY1MjM0MDAwMCIsCiAgICAicHJvZHVjdElkIjogMSwKICAgICJ1c2VySWQiOiAiMDAwMSIKfQ ` } ``` ### Response #### Success Response (200) (No specific response schema provided in the source text) #### Response Example (No specific response example provided in the source text) ``` -------------------------------- ### Asynchronous inTrack SDK Initialization with Debugging Enabled Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/web-getting-started.md Initialize the inTrack SDK asynchronously with the debug flag set to true. This will enable logging of debug messages in the browser's console, useful for troubleshooting. Ensure your configuration object includes the debug: true setting. ```html ``` -------------------------------- ### Handle inTrack Messages in Service Worker Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/web-push-notification.md Example of how to prevent inTrack's service worker from handling messages not intended for it within the Firebase SDK's onBackgroundMessage handler. ```javascript {`onBackgroundMessage((payload) => { if (payload?.data?.source === "$inTrack") return //... });`} ``` -------------------------------- ### Custom Screen Tracking (Java) Source: https://github.com/devopssmartech/intrack-doc/blob/main/android/inapp-messaging.md Manually inform InTrack about user navigation to a screen by calling the `customNavigatedTo` method with a screen name. ```java InTrack.customNavigatedTo("YOUR_SCREEN_NAME"); ``` -------------------------------- ### Initialize InTrack SDK with Crash Reporting (Swift) Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/ios-getting-started.md Configure the InTrackConfig object with your app and auth keys, and enable crash reporting for your iOS application in Swift. ```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 } ``` -------------------------------- ### Remove In-App Messaging Theme Configuration in Flutter Source: https://github.com/devopssmartech/intrack-doc/blob/main/migration/migration-v2-to-v3.md Starting from SDK v3.0, remove the `defaultTheme` configuration when enabling In-App Messaging in Flutter. This configuration is no longer handled by the SDK. ```dart $InTrack.isInitialized().then((bool isInitialized) { if (!isInitialized) { $InTrackConfig config = $InTrackConfig("YOUR_APP_KEY") ..setAndroidAuthKey("YOUR_ANDROID_AUTH_KEY") ..setIOSAuthKey("YOUR_IOS_AUTH_KEY") ..enableInAppMessaging( defaultTheme: { //<========= Remove this 'titleColor': '#fc0330', 'descriptionColor': '#000000', 'bgColor': '#ffffff', 'actionLabelColor': '#000000', 'actionBgColor': '#ffffff' }); $InTrack.initWithConfig(config).then((value) { print('$inTrack $value'); //you can enable push notification here }); } }); ``` -------------------------------- ### Initialize inTrack Push Service (Kotlin) Source: https://github.com/devopssmartech/intrack-doc/blob/main/android/push-messaging/push-messaging.md Initialize the inTrack notification service by calling initPush() after the inTrack SDK initialization. This is for Kotlin. ```kotlin $InTrack.initPush(Application()) ``` -------------------------------- ### Retrieve Subscription Status Asynchronously Source: https://github.com/devopssmartech/intrack-doc/blob/main/web/web-push-notification.md Get the user's web push subscription status using the `$InTrack.SubscriptionWebPushInfo()` method. This method accepts a callback function to handle the subscription information. ```javascript `$Intk('SubscriptionWebPushInfo', callBack);` ``` -------------------------------- ### Initialize inTrack Push Service (Java) Source: https://github.com/devopssmartech/intrack-doc/blob/main/android/push-messaging/push-messaging.md Initialize the inTrack notification service by calling initPush() after the inTrack SDK initialization. This is for Java. ```java $InTrack.initPush(Application application) ``` -------------------------------- ### Record Login with User Details (Objective-C) Source: https://github.com/devopssmartech/intrack-doc/blob/main/iOS/tracking-users.md Use this snippet to record a login event with comprehensive user details, including system and custom attributes. Ensure all mandatory fields like `userId` are provided. ```Objective-C NSDictionary *userAttributes = @{ @"attr1":@1, @"attr2":@"string", @"attr3":@42, @"attr4":@[@1, @2, @3, @4] }; $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=userAttributes; [$InTrack recordLogin:userDetails]; ```