### Get First Referring Parameters Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Retrieves the parameters associated with the link that originally referred the user upon their first interaction. ```APIDOC ## getFirstReferringParams ### Description Retrieves data from a Branch Deep Link that was used when the user first installed or interacted with the app. This method returns a promise and should ideally be used in conjunction with the `subscribe` listener to prevent race conditions. ### Method `getFirstReferringParams()` ### Endpoint N/A (JavaScript method) ### Parameters None ### Request Example ```javascript import branch from 'react-native-branch'; // Assuming subscribe is set up as shown previously let installParams = await branch.getFirstReferringParams(); // Params from original install console.log('Install Params:', installParams); ``` ### Response #### Success Response - **Promise** - A promise that resolves to a `BranchParams` object containing the referring link data. #### Response Example ```json { "+is_first_session": true, "+clicked_branch_link": true, "campaign": "summer_sale", "~channel": "facebook", "$deeplink_path": "product/123", "$canonical_url": "https://example.com/product/123" } ``` ``` -------------------------------- ### Get Latest Referring Parameters Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Retrieves the parameters from the most recent Branch link that opened the app. ```APIDOC ## getLatestReferringParams ### Description Retrieves the parameters associated with the most recent Branch Deep Link that was used to open the app. Similar to `getFirstReferringParams`, this method returns a promise due to React Native's asynchronous nature. ### Method `getLatestReferringParams()` ### Endpoint N/A (JavaScript method) ### Parameters None ### Request Example ```javascript import branch from 'react-native-branch'; // Assuming subscribe is set up as shown previously let latestParams = await branch.getLatestReferringParams(); // Params from last open console.log('Latest Params:', latestParams); ``` ### Response #### Success Response - **Promise** - A promise that resolves to a `BranchParams` object containing the latest referring link data. #### Response Example ```json { "+is_first_session": false, "+clicked_branch_link": true, "campaign": "winter_promo", "~channel": "twitter", "$deeplink_path": "promo/xyz", "$canonical_url": "https://example.com/promo/xyz" } ``` ``` -------------------------------- ### Get First Referring Params in React Native Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Retrieves the parameters from the Branch Deep Link that the user first used to install or open the app. This method returns a promise that resolves to a BranchParams object, representing the initial referral data. It's best practice to use this alongside the listener to prevent race conditions. ```javascript import branch from 'react-native-branch' // Listener branch.subscribe({ onOpenStart: ({ uri, cachedInitialEvent }) => { console.log( 'subscribe onOpenStart, will open ' + uri + ' cachedInitialEvent is ' + cachedInitialEvent, ); }, onOpenComplete: ({ error, params, uri }) => { if (error) { console.error( 'subscribe onOpenComplete, Error from opening uri: ' + uri + ' error: ' + error, ); return; } else if (params) { if (!params['+clicked_branch_link']) { if (params['+non_branch_link']) { console.log('non_branch_link: ' + uri); // Route based on non-Branch links return; } } else { // Handle params let deepLinkPath = params.$deeplink_path as string; let canonicalUrl = params.$canonical_url as string; // Route based on Branch link data return } } }, }); let installParams = await branch.getFirstReferringParams() // Params from original install ``` -------------------------------- ### Subscribe to Branch Events in React Native Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Sets up a listener to capture Branch deep link events. It handles both the start and completion of opening a URI, differentiating between Branch and non-Branch links, and processing associated parameters. This is crucial for routing users to the correct content within the app upon app launch or background re-engagement. ```javascript import branch from 'react-native-branch' // Listener branch.subscribe({ onOpenStart: ({ uri, cachedInitialEvent }) => { console.log( 'subscribe onOpenStart, will open ' + uri + ' cachedInitialEvent is ' + cachedInitialEvent, ); }, onOpenComplete: ({ error, params, uri }) => { if (error) { console.error( 'subscribe onOpenComplete, Error from opening uri: ' + uri + ' error: ' + error, ); return; } else if (params) { if (!params['+clicked_branch_link']) { if (params['+non_branch_link']) { console.log('non_branch_link: ' + uri); // Route based on non-Branch links return; } } else { // Handle params let deepLinkPath = params.$deeplink_path as string; let canonicalUrl = params.$canonical_url as string; // Route based on Branch link data return } } }, }); let latestParams = await branch.getLatestReferringParams() // Params from last open ``` -------------------------------- ### Add Facebook Partner Parameter - React Native Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Adds a Partner Parameter for Facebook, used for Facebook Advanced Matching by passing hashed information to the SDK. Once set, these parameters persist across INSTALL, OPEN, and other events until cleared or the app restarts. It requires a parameter name and value. ```javascript import branch from 'react-native-branch' branch.addFacebookPartnerParameter("key","value") ``` -------------------------------- ### Get Latest Referring Parameters in React Native Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Retrieves the parameters associated with the link that referred the current app session. Note that due to React Native's limitations, this is an asynchronous operation returning a Promise. It's recommended to use a listener for reliable data retrieval. ```javascript branch.getLatestReferringParams() .then(params => console.log(params)) .catch(error => console.error(error)); ``` -------------------------------- ### Log Custom Events with React Native Branch SDK Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Logs custom events to Branch for tracking and analytics beyond the default events like clicks and installs. This involves creating a `BranchUniversalObject`, `BranchEventParams`, and then a `BranchEvent` instance before calling the `logEvent()` method. The method returns a promise that resolves to `null` upon successful logging. ```javascript import branch from 'react-native-branch'; let buo = await branch.createBranchUniversalObject( "item/12345", { canonicalUrl: "https://branch.io/item/12345", title: "My Item Title", contentMetadata: { quantity: 1, price: 23.20, sku: "1994320302", productName: "my_product_name1", productBrand: "my_prod_Brand1", customMetadata: { custom_key1: "custom_value1", custom_key2: "custom_value2" } } } ); let params = { transaction_id: "tras_Id_1232343434", currency: "USD", revenue: 180.2, shipping: 10.5, tax: 13.5, coupon: "promo-1234", affiliation: "high_fi", description: "Preferred purchase", purchase_loc: "Palo Alto", store_pickup: "unavailable", customData: { "Custom_Event_Property_Key1": "Custom_Event_Property_val1", "Custom_Event_Property_Key2": "Custom_Event_Property_val2" } } let event = new BranchEvent(BranchEvent.Purchase, [buo], params); event.logEvent(); ``` -------------------------------- ### Get Last Attributed Touch Data - React Native Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Retrieves the last attributed touch data. It can optionally take an attribution window in days as a number. It returns a Promise that resolves to a BranchParams object containing the attribution data. The callback function receives the attribution data. ```javascript import branch from 'react-native-branch' const attributionWindow = 365; // `latData` is an object branch.lastAttributedTouchData(attributionWindow, (latData) => { // ... }); ``` -------------------------------- ### setPreInstallPartner Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Sets the pre-install partner name for tracking purposes. This should be called before any other Branch SDK methods if you are using pre-install attribution. ```APIDOC ## setPreInstallPartner ### Description Add the pre-install partner name. ### Method `setPreInstallPartner: (partner: string) => void;` ### Endpoint N/A (Client-side method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None #### Arguments - **partner** (string) - Required - The pre-install partner name. ### Request Example ```javascript import branch from 'react-native-branch' branch.setPreInstallPartner("My Pre-Install Partner") ``` ### Response N/A ``` -------------------------------- ### setPreInstallCampaign Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Sets the pre-install campaign name for tracking purposes. This should be called before any other Branch SDK methods if you are using pre-install attribution. ```APIDOC ## setPreInstallCampaign ### Description Add the pre-install campaign name. ### Method `setPreInstallCampaign: (campaign: string) => void;` ### Endpoint N/A (Client-side method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None #### Arguments - **campaign** (string) - Required - The pre-install campaign name. ### Request Example ```javascript import branch from 'react-native-branch' branch.setPreinstallCampaign("My Pre-Install Campaign") ``` ### Response N/A ``` -------------------------------- ### Set Pre-Install Partner Name - React Native Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Sets the pre-install partner name for tracking. This method takes a single string argument representing the partner name. ```javascript import branch from 'react-native-branch' branch.setPreInstallPartner("My Pre-Install Partner") ``` -------------------------------- ### Create Branch QR Code Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Generates a Branch QR code with customizable settings, associating it with specific content and link properties. ```APIDOC ## getBranchQRCode ### Description Creates a Branch QR code with specified settings. This method allows for customization of the QR code's appearance and the associated Branch link's properties and control parameters. ### Method `getBranchQRCode(settings, branchUniversalObject, linkProperties, controlParams)` ### Endpoint N/A (JavaScript method) ### Parameters #### Request Body - **settings** (`BranchQRCodeSettings`) - Required - Settings for the QR code (e.g., color, width). - **branchUniversalObject** (`BranchUniversalObjectOptions`) - Required - An object describing the content linked by the QR code. - **linkProperties** (`BranchLinkProperties`) - Required - Properties for the Branch link associated with the QR code. See 'Branch Link Properties' below for details. - **controlParams** (`BranchLinkControlParams`) - Optional - Additional link parameters. See 'Branch Link Control Parameters' below for details. #### Branch Link Properties - **alias** (string) - Optional - An alias for the link. - **campaign** (string) - Optional - The campaign name. - **feature** (string) - Optional - The feature associated with the link. - **channel** (string) - Optional - The channel through which the link was shared. - **stage** (string) - Optional - The stage of the link. - **tags** (array of strings) - Optional - Tags associated with the link. #### Branch Link Control Parameters - **$fallback_url** (string) - Optional - URL to use if Branch deep linking fails. - **$desktop_url** (string) - Optional - URL for desktop fallback. - **$ios_url** (string) - Optional - URL for iOS fallback. - **$ipad_url** (string) - Optional - URL for iPad fallback. - **$android_url** (string) - Optional - URL for Android fallback. - **$samsung_url** (string) - Optional - URL for Samsung devices fallback. ### Request Example ```javascript import branch from 'react-native-branch'; const qrCodeSettings = { color: '#000000', width: 200 }; const buo = { title: 'My Awesome Product', contentDescription: 'Check out this amazing product!', contentImageUrl: 'https://example.com/image.png', linkProperties: { tags: ['new_arrival'], feature: 'QR', channel: 'unknown' } }; const linkProperties = { campaign: 'qr_campaign', alias: 'my-qr-link' }; const controlParams = { $desktop_url: 'https://example.com/desktop', $android_url: 'myapp://product/123' }; try { const qrCodeString = await branch.getBranchQRCode(qrCodeSettings, buo, linkProperties, controlParams); console.log('QR Code String:', qrCodeString); // You can now use this string to display the QR code (e.g., using an Image component) } catch (error) { console.error('Error generating QR code:', error); } ``` ### Response #### Success Response - **Promise** - A promise that resolves to a string representing the QR code (often a data URI or similar format that can be used in an image component). #### Response Example ``` data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA... (truncated base64 encoded QR code data) ``` ``` -------------------------------- ### Set Pre-Install Campaign Name - React Native Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Sets the pre-install campaign name for tracking. This method takes a single string argument representing the campaign name. ```javascript import branch from 'react-native-branch' branch.setPreinstallCampaign("My Pre-Install Campaign") ``` -------------------------------- ### getBranchQRCode Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Generates a Branch QR code with customizable settings, content, and control parameters. ```APIDOC ## getBranchQRCode ### Description Generates a Branch QR code with customizable settings, content, and control parameters. ### Method `getBranchQRCode: (qrCodeSettings?: object, buoOptions?: object, lp?: object, controlParams?: object) => Promise` ### Parameters #### Request Body - **qrCodeSettings** (object) - Optional - Settings for the QR code (e.g., width, color, logo). - **buoOptions** (object) - Optional - Branch Universal Object options for the QR code content. - **lp** (object) - Optional - Link properties for the QR code. - **controlParams** (object) - Optional - Control parameters for the QR code generation. ### Request Example ```javascript import branch from 'react-native-branch' var qrCodeSettings = { width: 500, codeColor: "#3b2016", backgroundColor: "#a8e689", centerLogo: "https://cdn.branch.io/branch-assets/159857dsads5682753-og_image.png", margin: 1, imageFormat: "PNG" }; var buoOptions = { title: "A Test Title", contentDescription: "A test content desc", contentMetadata: { price: "200", productName: "QR Code Scanner", customMetadata: { "someKey": "someValue", "anotherKey": "anotherValue" } } }; var lp = { feature: "qrCode", tags: ["test", "working"], channel: "facebook", campaign: "posters" }; var controlParams = { "$desktop_url": "https://www.desktop.com", "$fallback_url": "https://www.fallback.com" }; try { var result = await branch.getBranchQRCode(qrCodeSettings, buoOptions, lp, controlParams); console.log('QR Code Result: ', result); } catch (err) { console.log('QR Code Err: ', err); } ``` ### Response #### Success Response (200) - **qrCodeImage** (string) - A base64 encoded string of the generated QR code image. ``` -------------------------------- ### openURL Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Deep links into your app from within the app itself using a provided URL. ```APIDOC ## openURL ### Description Deep links into your app from within the app itself by opening a specified URL. This can be used to navigate users to specific content or sections within your application. ### Method `openURL: (url: string, options?: { newActivity?: boolean }) => void;` ### Parameters #### Path Parameters - **url** (string) - Required - The URL to deep link to. - **options** (object) - Optional - Additional options for opening the URL. - **newActivity** (boolean) - Optional - If `true`, Branch will allow Android to finish the current activity before opening the link, resulting in a new activity window. Ignored on iOS. ### Request Example ```javascript import branch from 'react-native-branch' // Deep link to a URL branch.openURL("https://example.app.link/u3fzDwyyjF") // Deep link to a URL and force a new activity on Android branch.openURL("https://example.app.link/u3fzDwyyjF", {newActivity: true}) ``` ``` -------------------------------- ### Create Branch Universal Object in React Native Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Creates a BranchUniversalObject instance, which represents a unique piece of content. This method takes an identifier and an options object for properties like title and description. It returns a Promise that resolves to the BranchUniversalObject instance. ```javascript import branch from 'react-native-branch' let buo = await branch.createBranchUniversalObject('content/12345', { title: 'My Content Title', contentDescription: 'My Content Description', contentMetadata: { customMetadata: { key1: 'value1' } } }) ``` -------------------------------- ### addSnapPartnerParameter Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Adds a Partner Parameter for Snap. This allows you to pass additional hashed information to the SDK for Snap's matching capabilities. ```APIDOC ## addSnapPartnerParameter ### Description Add a Partner Parameter for Snap. This allows you to pass additional hashed information to the SDK for Snap's matching capabilities. ### Method `addSnapPartnerParameter: (name: string, value: string) => void;` ### Endpoint N/A (Client-side method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None #### Arguments - **name** (string) - Required - Partner Parameter key name. See Snap's documentation for details on valid parameters. - **value** (string) - Required - Partner Parameter value. See Snap's documentation for details on valid parameters. ### Request Example ```javascript import branch from 'react-native-branch' branch.addSnapPartnerParameter("key", "value") ``` ### Response N/A ``` -------------------------------- ### subscribe Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Subscribes to receive notifications for link opens, handling both initial app launch links and subsequent link opens. This eliminates the need to manually call getLatestReferringParams. ```APIDOC ## subscribe ### Description Receive a notification whenever a link is opened, including at app launch. There is no need to call `getLatestReferringParams()` at app launch to check for an initial link. Use `subscribe()` to handle all link opens. ### Method `subscribe: BranchSubscribe;` ### Parameters #### Request Body - **onOpenComplete** (`BranchSubscribeCallback`) - Required - The callback to this method will return any initial link that launched the app and all subsequent link opens. Related to: `interface BranchSubscriptionEventBase { params: BranchParams | undefined; error: string | null | undefined; uri: string | undefined; }` - **onOpenStart** (`event: BranchOpenStartEvent`) - Optional - Related to: `export interface BranchOpenStartEvent { uri: string; cachedInitialEvent?: boolean; }` ### Request Example ```javascript import branch from 'react-native-branch' branch.subscribe({ onOpenStart: ({ uri, cachedInitialEvent }) => { console.log('subscribe onOpenStart, will open ' + uri + ' cachedInitialEvent is ' + cachedInitialEvent); }, onOpenComplete: ({ error, params, uri }) => { if (error) { console.error('subscribe onOpenComplete, Error from opening uri: ' + uri + ' error: ' + error); return; } else if (params) { if (!params['+clicked_branch_link']) { if (params['+non_branch_link']) { console.log('non_branch_link: ' + uri); // Route based on non-Branch links return; } } else { // Handle params let deepLinkPath = params.$deeplink_path as string; let canonicalUrl = params.$canonical_url as string; // Route based on Branch link data return } } }, }); ``` ### Response #### Success Response (200) - **params** (`BranchParams | undefined`) - The deep link parameters. - **error** (`string | null | undefined`) - An error message if the link could not be processed. - **uri** (`string | undefined`) - The URI that was opened. ``` -------------------------------- ### Subscribe to Link Opens - React Native Branch Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index The `subscribe` method allows you to receive notifications for link opens, including at app launch. It handles all link open events, eliminating the need for manual checks with `getLatestReferringParams()`. ```javascript import branch from 'react-native-branch' branch.subscribe({ onOpenStart: ({ uri, cachedInitialEvent }) => { console.log( 'subscribe onOpenStart, will open ' + uri + ' cachedInitialEvent is ' + cachedInitialEvent, ); }, onOpenComplete: ({ error, params, uri }) => { if (error) { console.error( 'subscribe onOpenComplete, Error from opening uri: ' + uri + ' error: ' + error, ); return; } else if (params) { if (!params['+clicked_branch_link']) { if (params['+non_branch_link']) { console.log('non_branch_link: ' + uri); // Route based on non-Branch links return; } } else { // Handle params let deepLinkPath = params.$deeplink_path; let canonicalUrl = params.$canonical_url; // Route based on Branch link data return } } }, }); ``` -------------------------------- ### Generate Branch QR Code in React Native Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Creates a Branch QR code with customizable settings. This method takes settings for the QR code (like color and width), details about the content associated with the QR code (BranchUniversalObject), link properties, and additional control parameters. It returns a promise that resolves to a string representing the generated QR code. ```javascript getBranchQRCode: (settings: BranchQRCodeSettings, branchUniversalObject: BranchUniversalObjectOptions, linkProperties: BranchLinkProperties, controlParams: BranchLinkControlParams) => Promise; ``` -------------------------------- ### Branch Deep Link Subscription Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Subscribes to Branch deep link events, allowing you to handle link opens and retrieve associated parameters. ```APIDOC ## Subscribe to Deep Links ### Description This method allows you to subscribe to events related to Branch deep link openings. It provides callbacks for when the opening process starts (`onOpenStart`) and when it completes (`onOpenComplete`), enabling you to handle errors, retrieve link parameters, and route users accordingly. ### Method `branch.subscribe(callback: { onOpenStart: Function, onOpenComplete: Function })` ### Parameters #### Request Body - **callback** (object) - Required - An object containing two callback functions: - **onOpenStart**: `({ uri, cachedInitialEvent }) => void` - Called when the deep link opening process begins. - **onOpenComplete**: `({ error, params, uri }) => void` - Called when the deep link opening process completes or fails. ### Request Example ```javascript import branch from 'react-native-branch'; branch.subscribe({ onOpenStart: ({ uri, cachedInitialEvent }) => { console.log('subscribe onOpenStart, will open ' + uri + ' cachedInitialEvent is ' + cachedInitialEvent); }, onOpenComplete: ({ error, params, uri }) => { if (error) { console.error('subscribe onOpenComplete, Error from opening uri: ' + uri + ' error: ' + error); return; } else if (params) { if (!params['+clicked_branch_link']) { if (params['+non_branch_link']) { console.log('non_branch_link: ' + uri); // Route based on non-Branch links return; } } else { // Handle params let deepLinkPath = params.$deeplink_path; let canonicalUrl = params.$canonical_url; // Route based on Branch link data return; } } }, }); ``` ### Response No direct response; events are handled via callbacks. ``` -------------------------------- ### Generate QR Code with React Native Branch SDK Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Generates a QR code using the Branch SDK for React Native. This method allows customization of the QR code's appearance, center logo, and margin. It also accepts options for the Branch Universal Object (BUO) and campaign details, as well as control parameters for desktop and fallback URLs. The function returns a promise that resolves with the QR code data or rejects with an error. ```javascript import branch from 'react-native-branch'; var qrCodeSettings = { width: 500, codeColor: "#3b2016", backgroundColor: "#a8e689", centerLogo: "https://cdn.branch.io/branch-assets/159857dsads5682753-og_image.png", margin: 1, imageFormat: "PNG" }; var buoOptions = { title: "A Test Title", contentDescription: "A test content desc", contentMetadata: { price: "200", productName: "QR Code Scanner", customMetadata: { "someKey": "someValue", "anotherKey": "anotherValue" } } }; var lp = { feature: "qrCode", tags: ["test", "working"], channel: "facebook", campaign: "posters" }; var controlParams = { "$desktop_url": "https://www.desktop.com", "$fallback_url": "https://www.fallback.com" }; try { var result = await branch.getBranchQRCode(qrCodeSettings, buoOptions, lp, controlParams); } catch (err) { console.log('QR Code Err: ', err); } ``` -------------------------------- ### Add Snap Partner Parameter - React Native Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Adds a Partner Parameter for Snap. Similar to Facebook, this allows passing specific parameters to the Snap SDK. It requires a parameter name and value. ```javascript import branch from 'react-native-branch' branch.addSnapPartnerParameter("key","value") ``` -------------------------------- ### createBranchUniversalObject Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Creates a BranchUniversalObject instance, which represents a unique piece of content. This object is used for deep linking and analytics. ```APIDOC ## createBranchUniversalObject ### Description A `BranchUniversalObject` instance represents a unique piece of content, such as an article, video, or item for sale. ### Method `createBranchUniversalObject: (identifier: string, options: BranchUniversalObjectOptions) => Promise` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **identifier** (string) - Required - The unique name for the Branch Universal Object. - **options** (BranchUniversalObjectOptions) - Required - An object describing the properties of the Branch Universal Object. Visit the SDK GitHub repo for more details. ### Request Example ```javascript import branch from 'react-native-branch'; let buo = await branch.createBranchUniversalObject('content/12345', { title: 'My Content Title', contentDescription: 'My Content Description', contentMetadata: { customMetadata: { key1: 'value1' } } }); ``` ### Response #### Success Response (200) - **BranchUniversalObject** - An instance of a `BranchUniversalObject` with your specified properties. #### Response Example ```json { "identifier": "content/12345", "title": "My Content Title", "contentDescription": "My Content Description", "contentMetadata": { "customMetadata": { "key1": "value1" } } } ``` ``` -------------------------------- ### handleATTAuthorizationStatus Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Passes the AppTrackingTransparency (ATT) authorization status to Branch for performance measurement. This helps in understanding the impact of the ATT prompt. ```APIDOC ## handleATTAuthorizationStatus ### Description Pass the AppTrackingTransparency authorization status to Branch to measure ATT prompt performance. ### Method `handleATTAuthorizationStatus: (ATTAuthorizationStatus: ATTAuthorizationStatus) => void;` ### Endpoint N/A (Client-side method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None #### Arguments - **ATTAuthorizationStatus** (ATTAuthorizationStatus) - Required - The AppTrackingTransparency authorization status. Can be: "authorized", "denied", "undetermined", "restricted". ### Request Example ```javascript import branch from 'react-native-branch' // Retrieve ATT authorization status // ... // Pass ATT authorization status to Branch let ATTAuthorizationStatus = "restricted" branch.handleATTAuthorizationStatus(ATTAuthorizationStatus) ``` ### Response N/A ``` -------------------------------- ### setDMAParamsForEEA Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Sets the value of parameters required by Google Conversion APIs for DMA Compliance in the EEA region. It is crucial to include user consent signals to avoid potential degradation in attribution or campaign performance. All three parameters must be set for a successful call. ```APIDOC ## setDMAParamsForEEA ### Description Sets the value of parameters required by Google Conversion APIs for DMA Compliance in the EEA region. Failure to include user consent signals may result in attribution or campaign performance degradation. All three parameters must be set for a successful call. ### Method `setDMAParamsForEEA` ### Parameters #### Arguments - **eeaRegion** (boolean) - Required - Set to `true` if the user is located within the EEA and is within the scope of DMA. Set to `false` if the user is considered excluded from European Union regulations. - **adPersonalizationConsent** (boolean) - Required - Set to `true` if the user has granted consent for ads personalization. Set to `false` if the user has denied consent for ads personalization. - **adUserDataUsageConsent** (boolean) - Required - Set to `true` if the user has granted consent for 3P transmission of user-level data for ads. Set to `false` if the user has denied consent for 3P transmission of user-level data for ads. ### Request Example ```javascript import branch from 'react-native-branch' // Example for an EEA resident who has denied both ad personalization and data usage consent branch.setDMAParamsForEEA(true, false, false) // Example for an EEA resident who has consented to ad personalization but denied data usage consent branch.setDMAParamsForEEA(true, true, false) // Example for an EEA resident who has denied ad personalization but granted data usage consent branch.setDMAParamsForEEA(true, false, true) ``` ### Response This function does not return a value. ``` -------------------------------- ### generateShortUrl Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Generates a short Branch Deep Link URL for a specific BranchUniversalObject instance, with associated link properties and control parameters. ```APIDOC ## generateShortUrl ### Description Create a Branch Deep Link URL with encapsulated data. Create a short URL for a specific `BranchUniversalObject` instance, and associate a `LinkProperties` object with it. ### Method `generateShortUrl: (linkProperties?: BranchLinkProperties, controlParams?: BranchLinkControlParams) => Promise<{ url: string }>;` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **linkProperties** (BranchLinkProperties) - Optional - The link properties to associate with the URL. The `BranchLinkProperties` interface includes fields like `alias`, `campaign`, `feature`, `channel`, `stage`, and `tags`. - **controlParams** (BranchLinkControlParams) - Optional - Additional link parameters. Can include a `$fallback_url`, `$desktop_url`, `$ios_url`, `$ipad_url`, `$android_url`, `$samsung_url`, and a `custom` field. ### Request Example ```javascript import branch from 'react-native-branch'; let buo = await branch.createBranchUniversalObject('content/12345', { title: 'My Content Title', contentDescription: 'My Content Description', contentMetadata: { customMetadata: { key1: 'value1' } } }); let linkProperties = { feature: 'sharing', channel: 'facebook', campaign: 'content 123 launch' }; let controlParams = { $desktop_url: 'https://example.com/home', custom: 'data' }; let {url} = await buo.generateShortUrl(linkProperties, controlParams); ``` ### Response #### Success Response (200) - **url** (string) - The generated short Branch Deep Link URL. #### Response Example ```json { "url": "https://your-branch-domain.app.link/your_short_url" } ``` ``` -------------------------------- ### setRequestMetadata Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Sets custom identifiers before initializing the Branch SDK, which is required by some third-party data integration partners. ```APIDOC ## setRequestMetadata ### Description Some third-party Data Integration Partners require setting certain identifiers before initializing Branch. To do this, add `deferInitForPluginRuntime` to your `branch.json` file and use the `setRequestMetadata()` method to set your identifiers. ### Method `setRequestMetadata: (key: string, value: string) => void;` ### Parameters #### Path Parameters - **key** (`string`) - Required - The key for the particular identifier. - **value** (`string`) - Required - The value for the particular identifier. ### Request Example ```javascript import branch from 'react-native-branch' // Call `setRequestMetadata` before `subscribe` branch.setRequestMetadata('$analytics_visitor_id', '000001') branch.subscribe({ error, params } => { // ... }) ``` ``` -------------------------------- ### logEvent Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Logs a custom event to Branch for tracking and analytics. ```APIDOC ## logEvent ### Description Logs a custom event to Branch for tracking and analytics. This method is used in conjunction with `BranchUniversalObject` and `BranchEventParams` to define the event details. ### Method `logEvent: (event: BranchEvent) => Promise` ### Parameters #### Request Body - **event** (BranchEvent) - Required - An instance of BranchEvent containing event details. ### Request Example ```javascript import branch from 'react-native-branch' let buo = await branch.createBranchUniversalObject( "item/12345", { canonicalUrl: "https://branch.io/item/12345", title: "My Item Title", contentMetadata: { quantity: 1, price: 23.20, sku: "1994320302", productName: "my_product_name1", productBrand: "my_prod_Brand1", customMetadata: { custom_key1: "custom_value1", custom_key2: "custom_value2" } } } ) let params = { transaction_id: "tras_Id_1232343434", currency: "USD", revenue: 180.2, shipping: 10.5, tax: 13.5, coupon: "promo-1234", affiliation: "high_fi", description: "Preferred purchase", purchase_loc: "Palo Alto", store_pickup: "unavailable", customData: { "Custom_Event_Property_Key1": "Custom_Event_Property_val1", "Custom_Event_Property_Key2": "Custom_Event_Property_val2" } } let event = new BranchEvent(BranchEvent.Purchase, [buo], params) event.logEvent() ``` ### Response #### Success Response (200) - **null** (null) - The promise resolves to null upon successful logging. ``` -------------------------------- ### Open URL - React Native Branch Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index The `openURL` method sends push notification data to Branch. It takes a Branch Link URL and an optional configuration object to specify behavior, such as finishing the current Android activity. ```javascript import branch from 'react-native-branch' let data = { "aps": { "alert": "Push notification with a Branch deep link", "badge": "1" }, "branch": "https://example.app.link/u3fzDwyyjF" } branch.openURL(data["branch"],{newActivity: true}) ``` -------------------------------- ### openURL Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Sends push notification data to Branch, typically used to open a Branch link via a push notification payload. ```APIDOC ## openURL ### Description Send push notification data to Branch. ### Method `openURL: (url: string, options?: { newActivity?: boolean }) => void;` ### Parameters #### Path Parameters - **url** (`string`) - Required - The Branch Link to send with the push notification payload data. - **options** (`{ newActivity?: boolean }`) - Optional - If set to `true`, finish the current Android activity before opening the link. Results in a new activity window. Ignored on iOS. ### Request Example ```javascript import branch from 'react-native-branch' let data = { "aps": { "alert": "Push notification with a Branch deep link", "badge": "1" }, "branch": "https://example.app.link/u3fzDwyyjF" } branch.openURL(data["branch"],{newActivity: true}) ``` ``` -------------------------------- ### addFacebookPartnerParameter Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Adds a Partner Parameter for Facebook to enable the passing of additional hashed information for Facebook Advanced Matching. These parameters are attached to events until cleared or the app restarts. ```APIDOC ## addFacebookPartnerParameter ### Description Add a Partner Parameter for Facebook. This allows you to pass additional hashed information to the SDK for Facebook Advanced Matching. Once set, this parameter is attached to INSTALL, OPEN, and other events until they are cleared or the app restarts. ### Method `addFacebookPartnerParameter: (name: string, value: string) => void;` ### Endpoint N/A (Client-side method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None #### Arguments - **name** (string) - Required - Partner Parameter key name. See Facebook's documentation for details on valid parameters. - **value** (string) - Required - Partner Parameter value. See Facebook's documentation for details on valid parameters. ### Request Example ```javascript import branch from 'react-native-branch' branch.addFacebookPartnerParameter("key", "value") ``` ### Response N/A ``` -------------------------------- ### Open URL with React Native Branch SDK Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Opens a specified URL, enabling deep linking into your app. An optional `newActivity` parameter can be provided for Android to finish the current activity before opening the link, resulting in a new activity window. This option is ignored on iOS. Handling a new Branch Deep Link may clear current session data and attribute a new referred 'open'. ```javascript import branch from 'react-native-branch'; branch.openURL("https://example.app.link/u3fzDwyyjF"); // Finish the Android current activity before opening the link // Results in a new activity window // Ignored on iOS branch.openURL("https://example.app.link/u3fzDwyyjF", {newActivity: true}); ``` -------------------------------- ### Clear Partner Parameters - React Native Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Clears all previously set Partner Parameters for advertising integrations. This function takes no arguments and effectively resets any configured partner parameters. ```javascript import branch from 'react-native-branch' branch.clearPartnerParameters() ``` -------------------------------- ### setIdentity Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Identifies the current user to the Branch API by supplying a unique identifier. ```APIDOC ## setIdentity ### Description Identifies the current user to the Branch API by supplying a unique identifier as a string value. This can help persist referral and event data across platforms or uninstall/reinstall scenarios. ### Method `setIdentity: (identity: string) => void;` ### Parameters #### Path Parameters - **identity** (string) - Required - A string value containing the unique identifier of the user. ### Request Example ```javascript import branch from 'react-native-branch' branch.setIdentity('theUserId') ``` ``` -------------------------------- ### Generate Short URL in React Native Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Generates a Branch Deep Link URL for a given BranchUniversalObject. This method accepts optional link properties (like campaign and channel) and control parameters (like fallback URLs). It returns a Promise that resolves to an object containing the short URL. ```javascript import branch from 'react-native-branch' let buo = await branch.createBranchUniversalObject('content/12345', { title: 'My Content Title', contentDescription: 'My Content Description', contentMetadata: { customMetadata: { key1: 'value1' } } }) let linkProperties = { feature: 'sharing', channel: 'facebook', campaign: 'content 123 launch' } let controlParams = { $desktop_url: 'https://example.com/home', custom: 'data' } let {url} = await buo.generateShortUrl(linkProperties, controlParams) ``` -------------------------------- ### Set Request Metadata - React Native Branch Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index The `setRequestMetadata` method is used to set specific identifiers required by third-party Data Integration Partners before initializing the Branch SDK. This is configured by adding `deferInitForPluginRuntime` to your `branch.json` file. ```javascript import branch from 'react-native-branch' // Call `setRequestMetadata` before `subscribe` branch.setRequestMetadata('$analytics_visitor_id', '000001') branch.subscribe({ error, params } => { // ... }) ``` -------------------------------- ### Logout User Session - React Native Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Clears user session data and notifies Branch to create a new user for the device. This is useful when the app is being used by a different person. It clears first and latest parameters, initiating a new session. It takes no arguments and returns void. ```javascript import branch from 'react-native-branch' branch.logout() ``` -------------------------------- ### getLatestReferringParams Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Retrieves data from a Branch Deep Link that referred the current session. This method returns a promise and should be awaited. ```APIDOC ## getLatestReferringParams ### Description Retrieve data from a Branch Deep Link. This method is essentially a synchronous method that retrieves the latest referring link parameters stored by the native SDK. However, React Native does not support synchronous calls to native code from JavaScript, so the method returns a promise. You must `await` the response or use `then` to receive the result. This method is not intended to notify the app when a link has been opened. ### Method `getLatestReferringParams: (synchronous?: boolean) => Promise` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **synchronous** (boolean) - Optional - Set to `true` to allow deferred promise resolution. ### Request Example ```javascript import branch from 'react-native-branch'; // To get parameters without deferring promise resolution let params = await branch.getLatestReferringParams(); // To allow deferred promise resolution (use with caution) // let params = await branch.getLatestReferringParams(true); ``` ### Response #### Success Response (200) - **BranchParams** - An object containing the parameters associated with the link that referred the session. #### Response Example ```json { "+is_first_session": true, "~id": "1234567890", "data": "{\"article_id\": \"123\", \"$deeplink_url\": \"https:\/\/your-branch-domain.app.link\/your_short_url\"}" } ``` ``` -------------------------------- ### clearPartnerParameters Source: https://help.branch.io/developers-hub/docs/react-native-full-reference/index Clears all previously set Partner Parameters. This resets any parameters added via `addFacebookPartnerParameter` or `addSnapPartnerParameter`. ```APIDOC ## clearPartnerParameters ### Description Clear all Partner Parameters that were previously set. ### Method `clearPartnerParameters: () => void;` ### Endpoint N/A (Client-side method) ### Parameters None ### Request Example ```javascript import branch from 'react-native-branch' branch.clearPartnerParameters() ``` ### Response N/A ```