### Example: Start Geofence Tracking Source: https://academy.insiderone.com/docs/react-native-start-tracking-geofence This example demonstrates how to call the `startTrackingGeofence` method to begin tracking user geofences. ```javascript RNInsider.startTrackingGeofence(); ``` -------------------------------- ### Get Smart Recommendation Example (Java) Source: https://academy.insiderone.com/docs/android-smart-recommender Example of calling `getSmartRecommendation` in Java. Requires a recommendation ID, locale, currency, and a callback to handle the recommendation data. ```java Insider.Instance.getSmartRecommendation(1, "en_EN", "currency", new RecommendationEngine.SmartRecommendation() { @Override public void loadRecommendationData(JSONObject recommendation) { // Handle here } }); ``` -------------------------------- ### Get Smart Recommendation Example (Kotlin) Source: https://academy.insiderone.com/docs/android-smart-recommender Example of calling `getSmartRecommendation` in Kotlin. Requires a recommendation ID, locale, and currency, with a lambda for handling the recommendation response. ```kotlin Insider.Instance.getSmartRecommendation(1, "en_US", "USD") { recommendation -> // Handle the response here } ``` -------------------------------- ### Get Recommendations with Product IDs (Swift) Source: https://academy.insiderone.com/docs/ios-smart-recommender This Swift example demonstrates how to retrieve product recommendations using product IDs. It requires the campaign ID and selected algorithms from the InOne panel. Only the first 3 product IDs will be processed if more are provided. ```Swift Insider.getSmartRecommendation(withProductIDs: ["x", "y", "z"], recommendationID: 4, locale: "en_US", currency: "USD", smartRecommendation: { (recommendation) in // Handle here }) ``` -------------------------------- ### Get Message Center Data Example (Java) Source: https://academy.insiderone.com/docs/android-get-message-center-data Example of calling getMessageCenterData in Java to fetch up to 20 messages from a specific start date. Handles the response in the loadMessageCenterData callback. ```java Insider.Instance.getMessageCenterData(20, new Date(1546300800), new Date(), new MessageCenterData() { @Override public void loadMessageCenterData(JSONArray messageCenterData) { // Handle here Log.d("[INSIDER]", "[getMessageCenterData]: " + messageCenterData); } }); ``` -------------------------------- ### Retrieve Overall WhatsApp Campaign Analytics Source: https://academy.insiderone.com/docs/get-overall-whatsapp-campaign-analytics This example demonstrates how to call the API to get overall WhatsApp campaign analytics. You need to provide a start and end time in Unix timestamp format, along with optional campaign filters. ```APIDOC ## GET /v1/statistics/overall ### Description Retrieves overall analytics for WhatsApp campaigns within a specified date range. ### Method GET ### Endpoint https://whatsapp.useinsider.com/v1/statistics/overall ### Query Parameters - **start_time** (integer) - Required - The start of the date range in Unix timestamp format. - **end_time** (integer) - Required - The end of the date range in Unix timestamp format. ### Request Body - **campaign_filter** (object) - Optional - Filters for campaigns. - **campaign_type_ids** (array of strings) - Optional - Filter by campaign types (e.g., ["all"], ["standard"], ["conversational"]). - **statuses** (array of strings) - Optional - Filter by campaign statuses (e.g., ["all"], ["completed"], ["failed"]). ### Request Example ```shell curl --location 'https://whatsapp.useinsider.com/v1/statistics/overall?start_time=1740787200&end_time=1743379200' \ --header 'Content-Type: application/json' \ --header 'x-ins-auth-key: INS.**************************************' \ --data '{ "campaign_filter": { "campaign_type_ids": ["all"], "statuses": ["all"] } }' ``` ### Response #### Success Response (200 OK) Returns an object containing `chart` data (daily statistics) and `summary` data (overall statistics), and `details` (campaign-specific data). - **chart** (object) - Contains daily statistics like dates, sent, delivered, open, click, conversion, etc. - **summary** (object) - Contains overall aggregated statistics. - **details** (array of objects) - Contains detailed statistics for each individual campaign. #### Response Example ```json { "chart": { "dates": ["2025-03-01", "2025-03-02"], "datesAsTimestamp": [1740787200, 1740873600], "sent": [1200, 980], "delivered": [1150, 940], "open": [400, 310], "click": [120, 95], "conversion": [30, 22], "verified": [0, 0], "responses": [0, 0], "clickFromResponses": [0, 0], "conversionFromResponses": [0, 0] }, "summary": { "sent": 2180, "delivered": 2090, "open": 710, "click": 215, "conversion": 52, "revenue": 0, "drop": 45, "targeted": 2225, "unsubscribe": 3, "undelivered": 90, "deliveryPending": 0, "dropDetails": { "frequencyCapped": 10, "duplicates": 5, "invalidPhoneNumbers": 8, "tierLimitation": 0, "templateFailures": 2, "pausedTemplates": 0, "recipientRelatedErrors": 15, "metaTemporaryErrors": 3, "accountIntegrationErrors": 0, "internalErrors": 2, "rateLimits": 0, "policyFailures": 0 }, "undeliveredDetails": { "recipientRelatedErrors": 40, "accountVerificationErrors": 5, "mediaErrors": 0, "heldMessages": 10, "metaExperiment": 0, "metaErrors": 20, "invalidMessages": 5, "metaRecipientLimitsErrors": 10, "deliveryReportMissing": 0 } }, "details": [ { "id": 12345, "status": "completed", "campName": "Spring Campaign", "isConversational": false, "campaignType": "standard", "startsOn": 1740787200, "endsOn": 1741046400, "campaignLastDeliveryDate": 1741046400, "tags": [{ "id": 1, "name": "promo" }], "phoneNumber": "+905xxxxxxxxx", "phoneNumberName": "Main Number", "sent": 1200, "delivered": 1150, "open": 400, "click": 120, "conversion": 30, "revenue": 0, "drop": 25, "targeted": 1225, "unsubscribe": 2, "undelivered": 50, "deliveryPending": 0, "dropDetails": { "frequencyCapped": 10, "duplicates": 5, "invalidPhoneNumbers": 8, "tierLimitation": 0, "templateFailures": 2, "pausedTemplates": 0, "recipientRelatedErrors": 15, "metaTemporaryErrors": 3, "accountIntegrationErrors": 0, "internalErrors": 2, "rateLimits": 0, "policyFailures": 0 }, "undeliveredDetails": { "recipientRelatedErrors": 40, "accountVerificationErrors": 5, "mediaErrors": 0, "heldMessages": 10, "metaExperiment": 0, "metaErrors": 20, "invalidMessages": 5, "metaRecipientLimitsErrors": 10, "deliveryReportMissing": 0 } } ] } ``` #### Conversational Campaign Details For conversational campaigns, each item in the `details` array will additionally contain `responses` and `responseSummary` objects. ```json { "responses": [ { "cardId": 1, "buttonName": "Yes, I\'m interested", "sent": 1200, "delivered": 1150, "open": 400, "click": 120, "conversion": 30, "revenue": 0, "isNoReplyMessage": false } ], "responseSummary": { "sent": 1200, "open": 400, "click": 120, "conversion": 30, "buttonClick": 95 } } ``` ``` -------------------------------- ### Example: Track Sign Up Confirmation (Java) Source: https://academy.insiderone.com/docs/android-default-mobile-events An example of how to call the signUpConfirmation method. ```java Insider.Instance.signUpConfirmation(); ``` -------------------------------- ### Example: Track Sign Up Confirmation (Kotlin) Source: https://academy.insiderone.com/docs/android-default-mobile-events An example of how to call the signUpConfirmation method. ```kotlin Insider.Instance.signUpConfirmation() ``` -------------------------------- ### Get Auto Start Permission Method Source: https://academy.insiderone.com/docs/android-sdk-changelog-1 Method to get auto-start permission for vendors. Removed in version 11.6.0. ```java public void getAutoStartPermission(Vendor[] vendors) ``` -------------------------------- ### Example: Visit Product Detail Page with Custom Parameters Source: https://academy.insiderone.com/docs/react-native-default-mobile-events Example of creating a product and calling visitProductDetailPage with custom parameters. ```javascript const product = RNInsider.createNewProduct( "demo_product_123", "Demo Product", ["Electronics", "Smartphones"], "https://example.com/image.jpg", 99.99, "USD" ); const customParams = { source: "search", campaign_id: "campaign_123", recommendation_id: "rec_456" }; RNInsider.visitProductDetailPage(product, customParams); ``` -------------------------------- ### Get Message Center Data Example Source: https://academy.insiderone.com/docs/react-native-get-message-center-data Example of how to call the getMessageCenterData method to fetch pushes sent in the past three months. ```javascript RNInsider.getMessageCenterData(10, startDate, endDate, function (data) { }) ``` -------------------------------- ### Create New Product Example Source: https://academy.insiderone.com/docs/android-product-object Example demonstrating how to create an InsiderProduct object using the createNewProduct method. Ensure all parameters are correctly formatted. ```java String[] taxonomy = {"taxonomy1", "taxonomy2", "taxonomy3"}; InsiderProduct insiderExampleProduct = Insider.Instance.createNewProduct("productID", "productName", taxonomy, "imageURL", 1000.5, "currency"); ``` -------------------------------- ### Example: Wishlist Page Visit with Custom Parameters Source: https://academy.insiderone.com/docs/expo-events Example of creating a product, defining custom parameters, and calling visitWishlistPage. ```javascript const product = RNInsider.createNewProduct( "demo_product_123", "Demo Product", ["Electronics", "Smartphones"], "https://example.com/image.jpg", 99.99, "USD" ); const products = [product]; const customParams = { wishlist_total_items: 5, wishlist_total_value: 500.0 }; RNInsider.visitWishlistPage(products, customParams); ``` -------------------------------- ### Search API Request Example Source: https://academy.insiderone.com/docs/event-collection-api-payload-field-references Example of a GET request to the Eureka Search API, including query parameters for search, pagination, and user identification. ```APIDOC ## GET https://ineureka.api.useinsider.com/api/web/search ### Description Fetches products based on a search query. ### Method GET ### Endpoint https://ineureka.api.useinsider.com/api/web/search ### Query Parameters - **q** (string) - Required - Search query. - **p** (integer) - Required - Your Partner ID. - **l** (string) - Required - Your Locale (e.g., en_GB). - **c** (string) - Required - Currency (e.g., USD). - **u** (string) - Required - User ID (from localStorage key "spUID"). - **ps** (integer) - Optional - Page size (items per page). - **pf** (integer) - Optional - Page from (0-based offset, for pagination). - **st** (string) - Optional - Sorting type (e.g., Relevancy). ``` -------------------------------- ### Get Message Center Data Example Source: https://academy.insiderone.com/docs/flutter-get-message-center-data Example of how to call the getMessageCenterData method to retrieve notifications. Ensure the dates are valid DateTime objects and the limit is an integer. ```dart // Call in async method. final now = DateTime.now(); final yesterday = new DateTime(now.year, now.month, now.day - 1); List notifications = await FlutterInsider.Instance.getMessageCenterData(yesterday, now, 1); ``` -------------------------------- ### Example: Track Sign-Up Confirmation with Custom Parameters Source: https://academy.insiderone.com/docs/expo-events Shows how to define custom parameters and then call the signUpConfirmation method to track a user sign-up event. ```javascript const customParams = { sign_up_method: "email", referral_source: "campaign_123" }; RNInsider.signUpConfirmation(customParams); ``` -------------------------------- ### Create Utility Template with URL Button Source: https://academy.insiderone.com/docs/create-a-whatsapp-template This example demonstrates creating a utility template that includes a header, body, footer, and a URL button for tracking. Replace 'your-api-key' with your valid API key. ```bash curl --location 'https://whatsapp.useinsider.com/v1/templates' \ --header 'Content-Type: application/json' \ --header 'x-ins-auth-key: your-api-key' \ --data '{ "name": "order_delivery_update", "language": "en_US", "category": "UTILITY", "components": [ { "type": "HEADER", "format": "TEXT", "text": "Order update" }, { "type": "BODY", "text": "Hi {{1}}, your order {{2}} is on the way and will arrive on {{3}}." }, { "type": "FOOTER", "text": "Thank you for shopping with us." }, { "type": "BUTTONS", "buttons": [ { "type": "URL", "text": "Track package", "url": "https://tracking.example.com/orders/{{2}}" } ] } ] }' ``` -------------------------------- ### Full App Cards Integration Example (Java) Source: https://academy.insiderone.com/docs/android-configure-app-cards Demonstrates the complete process of fetching app card campaigns, iterating through them, logging view events, displaying content, handling images and buttons, processing card-level actions, and marking cards as read. Use this for a comprehensive implementation. ```Java InsiderAppCards appCards = Insider.Instance.appCards(); appCards.getCampaigns(new AppCardsCampaignsCallback() { @Override public void onComplete(InsiderAppCardCampaignsResponse responseObject, AppCardsException error) { if (error != null) { Log.e("AppCards", "Failed to get campaigns: " + error.getCode(), error); return; } List cards = responseObject.getAppCards(); for (InsiderAppCard card : cards) { // Log view event card.view(); // Display card content InsiderAppCardContent content = card.getContent(); if (content != null) { displayCard(content.getTitle(), content.getDescription()); } // Display images List images = card.getImages(); if (images != null) { for (InsiderAppCardImage image : images) { loadImage(image.getUrl()); } } // Handle buttons List buttons = card.getButtons(); if (buttons != null) { for (InsiderAppCardButton button : buttons) { addButton(button.getText(), () -> button.click()); } } // Handle card-level action InsiderAppCardDeeplinkAction action = card.getAction(); if (action != null) { String url = action.getUrl(); String urlType = action.getDeeplinkURLType(); Log.d("AppCards", "Action URL: " + url + " Type: " + urlType); } // Mark as read when user views if (!card.isRead()) { card.markAsRead(readError -> { if (readError == null) { Log.d("AppCards", "Marked as read: " + card.getId()); } }); } } } }); ``` -------------------------------- ### Get Message Center Data Example (Kotlin) Source: https://academy.insiderone.com/docs/android-get-message-center-data Example of calling getMessageCenterData in Kotlin to fetch messages. Uses a lambda for the callback and logs the received data. ```kotlin val startDate = Date(1546300800000L) // 1 Jan 2019, in milliseconds val endDate = Date() Insider.Instance.getMessageCenterData(20, startDate, endDate) { messageCenterData -> Log.d("[INSIDER]", "[getMessageCenterData]: $messageCenterData") } ``` -------------------------------- ### Example: Track Item Purchase with Custom Parameters (Java) Source: https://academy.insiderone.com/docs/android-default-mobile-events An example demonstrating how to create an InsiderProduct object and a map of custom parameters to track a purchase event. ```java InsiderProduct product = Insider.Instance.createNewProduct( "demo_product_123", "Demo Product", new String[]{"Electronics", "Smartphones"}, "https://example.com/image.jpg", 99.99, "USD" ); Map customParams = new HashMap<>(); customParams.put("payment_method", "credit_card"); customParams.put("discount_applied", true); customParams.put("shipping_method", "express"); Insider.Instance.itemPurchased("sale_123", product, customParams); ``` -------------------------------- ### Create Copilot Instructions File Source: https://academy.insiderone.com/docs/web-sdk-integration-skill-md Create a .github/copilot-instructions.md file in your project root and paste the SKILL file contents into it for GitHub Copilot. ```plaintext Create the file .github/copilot-instructions.md in your project root. Paste the contents of the SKILL file into this file. ``` -------------------------------- ### Get Message Center Data With Identifiers Example Source: https://academy.insiderone.com/docs/react-native-get-message-center-data Example demonstrating how to retrieve message center data for related users using `RNInsiderIdentifier`. Ensure dates are passed as timestamps. ```javascript const identifiers = new RNInsiderIdentifier() .addEmail('child@insiderone.com') .addPhoneNumber('+905551234567') .addUserID('unique-user-id') .addCustomIdentifier('account_id', 'parent-account-123') const end = new Date() const start = new Date(end.getTime() - 30 * 24 * 60 * 60 * 1000) // 30 days ago RNInsider.getMessageCenterDataWithIdentifiers(50, start, end, identifiers, (messageCenterData) => { // Handle the message center data for the specified user console.log(`Fetched ${messageCenterData.length} messages`) }) ``` -------------------------------- ### Get Message Center Data with Identifiers Example (Kotlin) Source: https://academy.insiderone.com/docs/android-get-message-center-data Example of calling getMessageCenterData in Kotlin with custom identifiers. Uses a lambda for the callback to handle the message center data for the specified user. ```kotlin val identifiers = InsiderIdentifiers() .addEmail("user@example.com") .addPhoneNumber("+905551234567") .addUserID("unique-user-id") .addCustomIdentifier("account_id", "parent-account-123") Insider.Instance.getMessageCenterData(20, startDate, endDate, identifiers) { messageCenterData -> // Handle the message center data for the specified user } ``` -------------------------------- ### Get Message Center Data with Identifiers Example (Java) Source: https://academy.insiderone.com/docs/android-get-message-center-data Example of calling getMessageCenterData in Java with custom identifiers (email, phone, user ID, custom ID). Fetches data for a specific user and handles the response. ```java InsiderIdentifiers identifiers = new InsiderIdentifiers() .addEmail("user@example.com") .addPhoneNumber("+905551234567") .addUserID("unique-user-id") .addCustomIdentifier("account_id", "parent-account-123"); Insider.Instance.getMessageCenterData(20, startDate, endDate, identifiers, new MessageCenterData() { @Override public void loadMessageCenterData(JSONArray messageCenterData) { // Handle the message center data for the specified user } }); ``` -------------------------------- ### Example: Track Item Purchase with Custom Parameters (Kotlin) Source: https://academy.insiderone.com/docs/android-default-mobile-events An example demonstrating how to create an InsiderProduct object and a map of custom parameters to track a purchase event. ```kotlin val product = Insider.Instance.createNewProduct( "demo_product_123", "Demo Product", arrayOf("Electronics", "Smartphones"), "https://example.com/image.jpg", 99.99, "USD" ) val customParams = mapOf( "payment_method" to "credit_card", "discount_applied" to true, "shipping_method" to "express" ) Insider.Instance.itemPurchased("sale_123", product, customParams) ``` -------------------------------- ### Get Message Center Data With Identifiers Example Source: https://academy.insiderone.com/docs/flutter-get-message-center-data Example demonstrating how to retrieve message center data for a specific user by providing their identifiers (email, phone number, user ID). Dates should be DateTime objects and the limit an integer. ```dart final DateTime startDate = DateTime.now().subtract(Duration(days: 7)); final DateTime endDate = DateTime.now(); FlutterInsiderIdentifiers identifiers = new FlutterInsiderIdentifiers(); identifiers.addEmail("example@insiderone.com"); identifiers.addPhoneNumber("+12345678901"); identifiers.addUserID("user_id"); final List messages = await getMessageCenterDataWithIdentifiers( startDate, endDate, identifiers, limit, ); ``` -------------------------------- ### Create Basic Marketing Template with Quick Reply Button Source: https://academy.insiderone.com/docs/create-a-whatsapp-template-with-oauth-2-0 Example of creating a marketing template with a body and a quick reply button. ```APIDOC ## Create Basic Marketing Template with Quick Reply Button ### Description Creates a marketing WhatsApp template that includes a body text and a quick reply button. ### Method `POST` ### Endpoint `https://gw.useinsider.com/api/wa/v2/templates` ### Headers - **Content-Type**: `application/json` - **Authorization**: `Bearer your-oauth2-token` ### Request Body - **name** (String) - Required - The template name. - **language** (String) - Required - The template locale (e.g., `en_US`). - **category** (String) - Required - Template category, must be `MARKETING`. - **components** (Array[Object]) - Required - Array of components, at least one is required. - **type** (String) - Required - Component type, must be `BODY` or `BUTTONS`. - **text** (String) - Required for `BODY` type - The body text content. - **buttons** (Array[Object]) - Required for `BUTTONS` type - Array of buttons. - **type** (String) - Required - Button type, must be `QUICK_REPLY`. - **text** (String) - Required - The text displayed on the button. ### Request Example ```json { "name": "spring_campaign_template", "language": "en_US", "category": "MARKETING", "components": [ { "type": "BODY", "text": "Hi {{1}}, our new spring collection is live now. Tap below to explore best sellers picked for you." }, { "type": "BUTTONS", "buttons": [ { "type": "QUICK_REPLY", "text": "Show products" } ] } ] } ``` ``` -------------------------------- ### Android Device Token Example Source: https://academy.insiderone.com/docs/mobile-app-device-token Android push tokens can vary in length, often exceeding 255 characters, and typically start with 'APA91b' or a colon-separated prefix. ```text APA91bFoi3lMMre9G3XzR1LrF4ZT82_15MsMdEICogXSLB8-MrdkRuRQFwNI5u8Dh0cI90ABD3BOKnxkEla8cGdisbDHl5cVIkZah5QUhSAxzx4Roa7b4xy9tvx9iNSYweXBYYd8k1XKf8Q_Qq1X9-x-U-Y79vdPq ``` -------------------------------- ### Create Basic Marketing Template with Quick Reply Source: https://academy.insiderone.com/docs/create-a-whatsapp-template Use this to create a marketing template with a body and a quick reply button. Ensure the 'x-ins-auth-key' is replaced with your actual API key. ```bash curl --location 'https://whatsapp.useinsider.com/v1/templates' \ --header 'Content-Type: application/json' \ --header 'x-ins-auth-key: your-api-key' \ --data '{ "name": "spring_campaign_template", "language": "en_US", "category": "MARKETING", "components": [ { "type": "BODY", "text": "Hi {{1}}, our new spring collection is live now. Tap below to explore best sellers picked for you." }, { "type": "BUTTONS", "buttons": [ { "type": "QUICK_REPLY", "text": "Show products" } ] } ] }' ``` -------------------------------- ### Get Message Center Data for Logged-in Users (Swift) Source: https://academy.insiderone.com/docs/ios-get-message-center-data Retrieve messages for logged-in users in Swift. The start and end dates are derived from the current date. ```Swift let today = Date() var oneDayBefore = DateComponents() oneDayBefore.setValue(-1, for: .day) let yesterday = Calendar.current.date(byAdding: oneDayBefore, to: today) Insider.getMessageCenterData(withLimit: 20, start: yesterday, end: today) { (messageCenterData) in // Handle here } ``` -------------------------------- ### Sample Mixed Strategy API Request Source: https://academy.insiderone.com/docs/recommendation-api-mixed-strategy-algorithm Example of a GET request to the Mixed Strategy algorithm endpoint. Replace placeholders like {Locale} and {PartnerName} with actual values. ```http https://recommendation.api.useinsider.com/v2/mixed?locale={Locale}&partnerName={PartnerName}&strategy=[{"recommendationType":"hdop","size":2}] ``` -------------------------------- ### Example: Visit Product Detail Page Source: https://academy.insiderone.com/docs/react-native-default-mobile-events Example of calling the visitProductDetailPage method with a product object. ```javascript RNInsider.visitProductDetailPage(insiderExampleProduct); ```