> ## Documentation Index
> Fetch the complete documentation index at: https://docs.suprsend.com/llms.txt
> Use this file to discover all available pages before exploring further.

# iOS Integration

> This document will cover integration steps for iOS side of your ReactNative application.

## Installation

<Steps>
  <Step title="Install Package.">
    <CodeGroup>
      ```javascript npm theme={"system"}
      npm install @suprsend/react-native-sdk@latest
      ```

      ```javascript yarn theme={"system"}
      yarn add @suprsend/react-native-sdk@latest
      ```
    </CodeGroup>

    <Note>
      If you are upgrading the SDK version, run `pod update` inside **ios** folder.
    </Note>
  </Step>

  <Step title="Adding Swift support and Bridge header">
    This step is needed only if your react native project iOS side doesn't support swift language.

    To check for swift support in Xcode, open `Project Settings --> Build Settings --> Swift Language Version` (attached image). If entry is present, you already have swift support in your project.

    <Frame>
      <img src="https://mintcdn.com/suprsend/09Y8zJBSaqwwb23r/images/docs/6382d706-e2f8-41dc-b166-613e46a5b5ac.png?fit=max&auto=format&n=09Y8zJBSaqwwb23r&q=85&s=91166dbbd8b68f1944a5a827d9933d04" alt="2880" width="1566" height="468" data-path="images/docs/6382d706-e2f8-41dc-b166-613e46a5b5ac.png" />
    </Frame>

    If your project doesn't support swift then its mandatory to add Swift support in your project by following the steps below.

    * Open "xcodeworkspace" file inside iOS folder. This will open Xcode.

    * Add Swift file to project like shown below.

          <Frame>
            <img src="https://mintcdn.com/suprsend/3ix_OjxB_ZGM-pa-/images/docs/2dadcb0-Screenshot_2022-05-19_at_5.47.31_PM.png?fit=max&auto=format&n=3ix_OjxB_ZGM-pa-&q=85&s=d39ff743f3eb226d7d1973fbd43a9e07" alt="2880" width="2880" height="1800" data-path="images/docs/2dadcb0-Screenshot_2022-05-19_at_5.47.31_PM.png" />
          </Frame>

    * Select **Swift File** and click on **`Next`** button.

    * Now give a suitable name to your file and click Create.

    * After that popup will be shown asking to configure Objective-C bridge header. Click on **`Create Bridge Header`**.

          <Frame>
            <img src="https://files.readme.io/4e4d8ea-Screenshot_2022-05-19_at_6.02.20_PM.png" />
          </Frame>

    Thats it! your React native iOS project can now understand code written in Swift language.
  </Step>

  <Step title="Inside PodFile change iOS platform version to 13 or greater if it's less than 13.">
    <CodeGroup>
      ```ruby PodFile theme={"system"}
      platform :ios, '13.0' // this version has to be 13 or greater
      ```
    </CodeGroup>
  </Step>

  <Step title="Run pod install from inside iOS folder.">
    ```
    pod install
    ```
  </Step>

  <Step title="Update the Target">
    SuprSend SDK needs an iOS deployment target of 11 or above, update the target as given in below image if needed.

    <Frame>
      <img src="https://mintcdn.com/suprsend/3ix_OjxB_ZGM-pa-/images/docs/18650ad-Screenshot_2022-07-27_at_12.36.03_PM.png?fit=max&auto=format&n=3ix_OjxB_ZGM-pa-&q=85&s=4dd9f96245ceb0f9a11881fdd90cc925" width="1822" height="794" data-path="images/docs/18650ad-Screenshot_2022-07-27_at_12.36.03_PM.png" />
    </Frame>
  </Step>
</Steps>

## Initialization

<Steps>
  <Step title="AppDelegate changes">
    In **AppDelegate** add the below code inside `didFinishLaunchingWithOptions` method, just before last returning line. Refer any one of code snippet below based on your projects AppDelegate file language.

    <CodeGroup>
      ```objectivec AppDelegate.m theme={"system"}
      #import <SuprSendSdk/SuprSendSdk-Swift.h> //add this

      ...

      - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
      {
        ...
        SuprSendSDKConfiguration* configuration = [[SuprSendSDKConfiguration alloc] initWithKey:@workspace_key secret:@workspace_secret]; // add this line
        [SuprSend.shared configureWithConfiguration:configuration launchOptions:launchOptions]; // add this line
        return YES;
      ```

      ```swift AppDelegate.swift theme={"system"}
      import SuprSendSdk // Add this

      ...

      override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
       ......

       // Add below 2 lines
       let suprSendConfiguration = SuprSendSDKConfiguration(withKey: "your_workspace_key", secret:"your_workspace_secret")
       SuprSend.shared.configureWith(configuration: suprSendConfiguration, launchOptions: launchOptions)

       return super.application(application, didFinishLaunchingWithOptions: launchOptions)
      }
      ```
    </CodeGroup>
  </Step>

  <Step title="Replace workspace_key and workspace_secret">
    Replace the **`workspace_key`** and **`workspace_secret`** with your workspace values. You will get both the tokens from **Settings -> API Keys** in [SuprSend dashboard](https://app.suprsend.com/).
  </Step>
</Steps>

## Logging

By default the logs of SuprSend SDK are disabled. You can enable the logs just in debug mode while in development by the below condition.

<CodeGroup>
  ```javascript javascript theme={"system"}
  suprsend.enableLogging(); // available from v2.0.2

  // deprecated from v2.0.2
  suprsend.setLogLevel(level)
  suprsend.setLogLevel("VERBOSE")
  suprsend.setLogLevel("DEBUG")
  suprsend.setLogLevel("INFO")
  suprsend.setLogLevel("ERROR")
  suprsend.setLogLevel("OFF")
  ```
</CodeGroup>

***
