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

# Cordova-Ionic SDK (Deprecated)

![NPM Version](https://img.shields.io/npm/v/airbridge-cordova-sdk/sdk-v2?label=airbridge-cordova-sdk)

## SDK Installation

***

### Package Installation

###### `plugin add`

Cordova: `cordova plugin add airbridge-cordova-sdk`

Ionic: `ionic cordova plugin add airbridge-cordova-sdk`

PhoneGap: `phonegap plugin add airbridge-cordova-sdk`

For Ionic projects, please add the following code to the `.ts` files that will be using the Airbridge SDK.

```Ionic theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
import ...
...
declare let Airbridge: any;

...
```

### Project Setup (Android)

###### MainApplication.java

Initialize the Airbridge SDK in the [Android Application class](https://developer.android.com/reference/android/app/Application).

1. Create an Application class. Add the `platforms/android/app/src/main/java/[PACKAGE NAME]/MainApplication.java` file.

If you already have the Application class, proceed to step 3.

<CodeGroup>
  ```kotlin Kotlin lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  import android.app.Application

  class AndroidApplication: Application() {

      override fun onCreate() {
          super.onCreate()
      }
  }
  ```

  ```java Java lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  import android.app.Application;

  public class AndroidApplication extends Application {

      @Override
      public void onCreate() {
          super.onCreate();
      }
  }
  ```
</CodeGroup>

2. Set the created Application in the `AndroidManifest.xml.`

```xml AndroidManifest.xml lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
 <application
        android:name=".AndroidApplication"
        ...>
```

3. Add the following initialization code to the Application class.

'YOUR\_APP\_NAME' is your app name. You can find app name in the Airbridge dashboard under \[Settings]>\[App Settings]. 'YOUR\_APP\_SDK\_TOKEN' is App SDK token. You can find your App SDK token under \[Settings] > \[Tokens].

<CodeGroup>
  ```java Java lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  package [PACKAGE NAME];

  import android.app.Application;

  import co.ab180.airbridge.cordova.AirbridgeCO;

  public class AndroidApplication extends Application {
      @Override
      public void onCreate() {
          super.onCreate();
          AirbridgeCO.init(this, "YOUR_APP_NAME", "YOUR_APP_TOKEN");
      }
  }
  ```

  ```kotlin Kotlin lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  package [PACKAGE NAME]

  import android.app.Application

  import co.ab180.airbridge.cordova.AirbridgeCO

  class AndroidApplication : Application() {
      override fun onCreate() {
          super.onCreate()
          AirbridgeCO.init(this, "YOUR_APP_NAME", "YOUR_APP_TOKEN")
      }
  }
  ```
</CodeGroup>

### Project Setup (iOS)

###### `AppDelegate.m`

Add the following code to the import section of the file `ios/[Project Name]/AppDelegate.m`.

<CodeGroup>
  ```objective-c Objective-C lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  #import "AirbridgeCO.h"
  ```

  ```swift Swift lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  // Bridge Header

  #import "AirbridgeCO.h"
  ```
</CodeGroup>

Add the following code to the `application:idFinishLaunchingWithOptions:` function within the `ios/[Project Name]/AppDelegate.m` file.

<CodeGroup>
  ```objective-c Objective-C lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      [AirbridgeCO getInstance:@"YOUR_APP_TOKEN" appName:@"YOUR_APP_NAME" withLaunchOptions:launchOptions];
      ...
  }
  ```

  ```swift Swift lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
      AirbridgeCO.getInstance("YOUR_APP_TOKEN", appName:"YOUR_APP_NAME", withLaunchOptions:launchOptions)
      ...
  }
  ```
</CodeGroup>

`APP_NAME` can be found on the dashboard at **`Settings → Tokens → App Name`**.

`APP_TOKEN` can be found on the dashboard at **`Settings → Tokens → App SDK Token`**.

### Common Settings

###### airbridge.json

1. Add an `airbridge.json`file to the project folder.
2. Configure settings in JSON format.

```json lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
{
    "sessionTimeoutSeconds": 300,
    "autoStartTrackingEnabled": true,
    "userInfoHashEnabled": true,
    "trackAirbridgeLinkOnly": false,
    "facebookDeferredAppLinkEnabled": false,
    "locationCollectionEnabled": false,
    "trackingAuthorizeTimeoutSeconds": 30,
    "sdkSignatureSecretID": "YOUR_SDK_SIGNATURE_SECRET_ID",
    "sdkSignatureSecret": "YOUR_SDK_SIGNATURE_SECRET",
    "logLevel": "warning"
}
```

<Danger>
  **Attention**

  `trackingAuthorizeTimeoutSeconds` in the above code is the default value (0). Please adjust accordingly depending on your user experience and ATT prompt settings. Refer to ]Tracking Authorize Timeout Settings for more details.
</Danger>

| Name                            | Type    | Default | Description                                                                                                                                                                                                                     |
| ------------------------------- | ------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| sessionTimeoutSeconds           | Number  | 300     | An app open event will not be sent when the app is reopened within the designated period.                                                                                                                                       |
| autoStartTrackingEnabled        | Boolean | true    | When set to false, no events will be sent until `Airbridge.state.startTracking()`is called.                                                                                                                                     |
| userInfoHashEnabled             | Boolean | true    | When set to false, user email and user phone information are sent without being hashed.                                                                                                                                         |
| trackAirbridgeLinkOnly          | Boolean | false   | When set to true, deep link events are sent only when app is opened with an Airbridge deep link.                                                                                                                                |
| facebookDeferredAppLinkEnabled  | Boolean | false   | When set to true and the Facebook SDK is installed, Facebook Deferred App Link data is collected.                                                                                                                               |
| locationCollectionEnabled       | Boolean | false   | When set to true, location information is collected. (Android Only)<br />Two permissions must be allowed in AndroidManifest.xml<br />android.permission.ACCESS\_FINE\_LOCATION<br />android.permission.ACCESS\_COARSE\_LOCATION |
| trackingAuthorizeTimeoutSeconds | Number  | 0       | When timeout is set, Install event is delayed until `Request tracking authorization alert` is clicked. (iOS only)                                                                                                               |
| sdkSignatureSecretID            | String  | null    | Protects against SDK spoofing. Both sdkSignatureSecretID and sdkSignatureSecret values must be applied.                                                                                                                         |
| sdkSignatureSecret              | String  | null    | Protects against SDK spoofing. Both sdkSignatureSecretID and sdkSignatureSecret values must be applied.                                                                                                                         |
| logLevel                        | String  | warning | Adjusts the log record level for Airbridge.<br />logLevel: "debug" \| "info" \| "warning" \| "error" \| "fault"                                                                                                                 |

### Testing the SDK

Check if install events are sent when the application is installed and opened.

#### Check in the Airbridge Dashboard

Events from the Airbridge SDK are shown at the "Airbridge Dashboard → Raw Data → App Real-time Logs".

1. Go to `Airbridge Dashboard → Raw Data → App Real-time Logs`.
2. Search for the device's ADID (IDFA, IDFV, GAID).

Logs may be delayed for up to 5 minutes.

## Deep Link Setup

***

### Dashboard Setup

Please refer to the following guides for setting up deep links in the Airbridge dashboard.

* [Deep link setup for Android](/en/developers/deprecated-android-sdk-v2#dashboard-setup)
* [Deep link setup for iOS](/en/developers/deprecated-ios-sdk-v1#dashboard-setup)

### Project Setup (Android)

##### `setDeeplinkListener`

Register a function that will be called whenever a "deep link" or a "deferred deep link" opens the application.

```javascript lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
Airbridge.deeplink.setDeeplinkListener((deeplink) => {
    // Code to be executed when a `Deeplink` or `Deferred Deeplink` occurs
    // deeplink = YOUR_SCHEME://...

    console.log(deeplink);
});
```

All deep links that open apps are sent to `DeeplinkCallback`

Of those deep links, "Airbridge deep links" will be sent using the URI Scheme (`YOUR_SCHEME://...`) that was set in the Airbridge dashboard.

###### AndroidManifest.xml

In the `MainActivity` section of the `android/app/src/main/AndroidManifest.xml` file, add `intent-filter` parameters as below.

```xml lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data android:scheme="http" android:host="YOUR_APP_NAME.deeplink.page" />
    <data android:scheme="https" android:host="YOUR_APP_NAME.deeplink.page" />
</intent-filter>
<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data android:scheme="http" android:host="YOUR_APP_NAME.airbridge.io" />
    <data android:scheme="https" android:host="YOUR_APP_NAME.airbridge.io" />
</intent-filter>
<intent-filter>
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data android:scheme="EXAMPLE_SCHEME" />
</intent-filter>
```

Enter your app name at `APP_NAME`.

Enter your scheme value set in the Airbridge dashboard at `YOUR_SCHEME`.

###### MainActivity.java

Insert the following code in the `android/app/src/main/java/.../MainActivity.java` file.

<CodeGroup>
  ```java Java lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  @Override
  protected void onResume() {
      super.onResume();

      AirbridgeCO.processDeeplinkData(getIntent());
  }

  @Override
  public void onNewIntent(Intent intent) {
      super.onNewIntent(intent);
      setIntent(intent);
  }
  ```

  ```kotlin Kotlin lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  override fun onResume() {
      super.onResume()
      AirbridgeCO.processDeeplinkData(intent)
  }

  override fun onNewIntent(intent: Intent) {
      super.onNewIntent(intent)
      setIntent(intent)
  }
  ```
</CodeGroup>

### Project Setup (iOS)

###### Scheme

1. Go to "Xcode → Project file → Info → URL Types".
2. From the Airbridge dashboard, copy "iOS URI Scheme" to Xcode's "URL Schemes". (Do not include`://`)

<Frame>
  <img src="https://mintcdn.com/airbridge-help-center/yb7Ud8MfVkimM8iI/asset/image/xcode-url-scheme-field.png?fit=max&auto=format&n=yb7Ud8MfVkimM8iI&q=85&s=90fb7ff0d4103416ab30d49e0dcce627" alt="01-en-dev-cordova-SDK" width="768" height="325" data-path="asset/image/xcode-url-scheme-field.png" />
</Frame>

#### Universal Link

1. Go to "Xcode → Project file → Signing & Capabilities".
2. Click "+ Capability" and add "Associated Domains".
3. Add `applinks:YOUR_APP_NAME.airbridge.io`to "Associated Domains".
4. Add  `applinks:YOUR_APP_NAME.deeplink.page`to "Associated Domains".

`YOUR_APP_NAME` can be found at the "Airbridge dashboard → Settings → Tokens → App Name".

Please refer to [Troubleshooting → Webcredentials](/en/developers/deprecated-ios-sdk-v1#webcredentials) if you want to use the autofill feature.

###### Send deeplink information to SDK

1. Open `ios/[Project name]/AppDelegate`.
2. Send deeplink information to the SDK when the application is opened through schemes by calling the `handleURLSchemeDeeplink`method at the beginning of the following function.

<CodeGroup>
  ```objective-c Objective-C lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  - (BOOL)application:(UIApplication *)application
              openURL:(NSURL *)url
              options:(NSDictionary<UIApplicationOpenURLOptionsKey, id>*)options
  {
      NSLog(@"openURL : %@", url);

      [AirbridgeCO.deeplink handleURLSchemeDeeplink:url];

      return YES;
  }
  ```

  ```swift Swift lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  func application(_ app: UIApplication,
                   open url: URL,
                   options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool
  {
      NSLog(@"openURL : %@", url)

      AirbridgeCO.deeplink().handleURLSchemeDeeplink(url)
      
      return true
  }
  ```
</CodeGroup>

3. When targeting iOS 8.x or earlier, also call the `handleURLSchemeDeeplink`method at the beginning of the following function.

<CodeGroup>
  ```objective-c Objective-C lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  - (BOOL)application:(UIApplication*)application
              openURL:(NSURL*)url
    sourceApplication:(NSString*)sourceApplication 
           annotation:(id)annotation
  {
      NSLog(@"openURL : %@", url);

      [AirbridgeCO.deeplink handleURLSchemeDeeplink:url];

      return YES;
  }
  ```

  ```swift Swift lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  func application(_ application: UIApplication,
                   open url: URL,
                   sourceApplication: String?,
                   annotation: Any) -> Bool
  {
      NSLog(@"openURL : %@", url)

      AirbridgeCO.deeplink().handleURLSchemeDeeplink(url);
      
      return true;
  }
  ```
</CodeGroup>

4. Send deeplink information to the SDK when the application is opened through an universal link by calling the `handleUserActivity`method at the beginning of the following function.

<CodeGroup>
  ```objective-c Objective-C lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  -  (BOOL)application:(UIApplication*)application
  continueUserActivity:(NSUserActivity*)userActivity
    restorationHandler:(void (^)(NSArray* _Nullable))restorationHandler
  {
      NSLog(@"continueUserActivity : %@", userActivity.webpageURL);

      [AirbridgeCO.deeplink handleUserActivity:userActivity];

      return YES;
  }
  ```

  ```swift Swift lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
  func application(_ application: UIApplication,
                   continue userActivity: NSUserActivity,
                   restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool
  {
      if let webpageURL = userActivity.webpageURL {
          NSLog("continueUserActivity : %@", webpageURL)   
      }

      AirbridgeCO.deeplink().handle(userActivity)
      
      return true
  }
  ```
</CodeGroup>

### Custom Domain Setup (Optional)

Please refer to the below guides to setup your custom domain with Airbridge.

* [iOS deep link dashboard setup](/en/developers/deprecated-ios-sdk-v1#custom-domain-setting-optional)
* [Android deep link dashboard setup](/en/developers/deprecated-android-sdk-v2#custom-domain-setup)

### Test Deep Link

Click on your URI scheme to test if your deep link has been properly set up in the Airbridge SDK.

* `YOUR_APP_URI_SCHEME://`

The results will show on the "Airbridge dashboard → Row Data → App Real-time Log" tab if everything is working.

## User Setup

***

### User Identifier Setup

Once a user identifier information is sent to the SDK, all events thereafter will contain the corresponding user identifier information.

| 이름         | 설명                | 제한                                                                                                                                                                                                                                |
| ---------- | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id         | User ID           | -                                                                                                                                                                                                                                 |
| email      | User Email        | Hashed by default<br />(SHA256, can be disabled)                                                                                                                                                                                  |
| phone      | User phone number | Hashed by default<br />(SHA256, can be disabled)                                                                                                                                                                                  |
| attributes | User attributes   | - Maximum 100 attributes<br />- "key" type is string, maximum 128 characters<br />- "key" must satisfy `^[a-z_][a-z0-9_]*$`regex<br />- "value" type is primitive or string<br />- Maximum 1024 characters when "value" is string |
| alias      | Another User ID   | - Maximum 10 aliases<br />- `"key"`type is String, maximum 128 characters<br />- `"key"`must satisfy `^[a-z_][a-z0-9_]*$`regex<br />- \`"value" type is String, maximum 1024 characters                                           |

###### Example

```javascript lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
Airbridge.state.setUser({
    ID: 'test1',
    email: 'test1@ab180.co',
});
Airbridge.state.setUser({
    email: 'test2@ab180.co',
    phone: '222-2222-2222',
});
Airbridge.state.updateUser({
    ID: 'test3',
});
```

The above code operates in the following order.

1. User = \{ ID: 'personID1', email: 'persondoe1<span>@</span>airbridge.io' }
2. User = \{ ID: 'personID1', email: 'persondoe1<span>@</span>airbridge.io', phone: '1(123)123-1234' }
3. User = \{ ID: 'personID3', email: 'persondoe2<span>@</span>airbridge.io', phone: '1(123)123-1234)' }

### Testing

Make sure that your user information settings are being properly sent through the SDK.

1. Configure user identifier information.
2. Send an event using the SDK.
3. Click the event at "Airbridge dashboard → Raw Data → App Real-time Logs"
4. Check if the user information is correctly sent under the `user`block.

## Device Setup

***

### Setup Device Alias

Setup a device alias through the Airbridge SDK. The alias will be sustained even after the app closes, unless otherwise deleted.j

```javascript lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
Airbridge.setDeviceAlias("ADD_YOUR_KEY", "AND_YOUR_VALUE");
Airbridge.removeDeviceAlias("DELETE_THIS_KEY");
Airbridge.clearDeviceAlias();
```

| `setDeviceAlias(key: string, value: string)` | Add the key value pair to the device identifier. |
| -------------------------------------------- | ------------------------------------------------ |
| `removeDeviceAlias(key: string)`             | Delete the corresponding device alias.           |
| `clearDeviceAlias()`                         | Delete all device aliases.                       |

## Event Setup

***

When important user actions occur, in-app events can be sent to measure performance by channel.

All event parameters are optional. However, more information about the event will help provide a more accurate analysis.

`action`, `label`, `value`, `customAttributes` and `semanticAttributes` can be used for event options.

```javascript lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
/**
 * Send Goal-Event to server.
 * @param {string} category event name
 * @param {EventOption} [option={}] event options
 */
trackEvent(category: string, option?: EventOption): void;
```

### User Events

Send standard user events with the SDK.

`action`, `label`, `value`, `customAttributes` and `semanticAttributes` can be used for user events.

###### Sign Up

User identifiers are set with `setUser` and then sent with `AirbridgeCategory.SIGN_UP` for user sign ups.

```javascript lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
Airbridge.state.setUser({
    ID: 'test',
    email: 'test@ab180.co',
    phone: '000-0000-0000',
});
Airbridge.trackEvent(AirbridgeCategory.SIGN_UP);
```

###### Sign In

User identifiers are set with `setUser` and then sent with `AirbridgeCategory.SIGN_IN` for user logins.

```javascript lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
Airbridge.state.setUser({
    ID: 'test',
    email: 'test@ab180.co',
    phone: '000-0000-0000',
});
Airbridge.trackEvent(AirbridgeCategory.SIGN_IN);
```

###### Sign Out

Send the sign out event with `AirbridgeCategory.SIGN_OUT`, and then reset the user identifiers with `Airbridge.state.setUser({})`.

```javascript lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
Airbridge.trackEvent(AirbridgeCategory.SIGN_OUT);
Airbridge.state.setUser({});
```

### E-commerce Events

###### Send e-commerce events with the SDK.

`action`, `label`, `value`, `customAttributes` and `semanticAttributes` can be used for e-commerce events.

It is possible to include product information using `semanticAttributes`. Custom key values can be used along with the pre-defined values.

###### View Home Screen

```javascript lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
Airbridge.trackEvent(AirbridgeCategory.HOME_VIEW);
```

###### View Product Detail

```javascript lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
Airbridge.trackEvent(AirbridgeCategory.PRODUCT_DETAILS_VIEW, {
    semanticAttributes: {
        [AirbridgeAttributes.PRODUCTS]: [
            {
                [AirbridgeProduct.PRODUCT_ID]: 'coke_zero',
                [AirbridgeProduct.NAME]: 'Coke Zero',
                [AirbridgeProduct.PRICE]: 1.99,
                [AirbridgeProduct.CURRENCY]: 'USD',
                [AirbridgeProduct.POSITION]: 1,
                [AirbridgeProduct.QUANTITY]: 1,
            },
        ]
    }
});
```

###### View Product List

```javascript lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
Airbridge.trackEvent(AirbridgeCategory.PRODUCT_LIST_VIEW, {
    semanticAttributes: {
        [AirbridgeAttributes.PRODUCT_LIST_ID]: 'ID-1234567890'
        [AirbridgeAttributes.PRODUCTS]: [
            {
                [AirbridgeProduct.PRODUCT_ID]: 'coke_zero',
                [AirbridgeProduct.NAME]: 'Coke Zero',
                [AirbridgeProduct.PRICE]: 1.99,
                [AirbridgeProduct.CURRENCY]: 'USD',
                [AirbridgeProduct.POSITION]: 1,
                [AirbridgeProduct.QUANTITY]: 1,
            },
            {
                [AirbridgeProduct.PRODUCT_ID]: 'burger_cheese_double',
                [AirbridgeProduct.NAME]: 'Double Cheeseburger',
                [AirbridgeProduct.PRICE]: 3.99,
                [AirbridgeProduct.CURRENCY]: 'USD',
                [AirbridgeProduct.POSITION]: 2,
                [AirbridgeProduct.QUANTITY]: 1,
            },
        ]
    }
});
```

###### View Search Result

```javascript lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
Airbridge.trackEvent(AirbridgeCategory.SEARCH_RESULT_VIEW, {
    semanticAttributes: {
        [AirbridgeAttributes.QUERY]: 'product'
        [AirbridgeAttributes.PRODUCTS]: [
            {
                [AirbridgeProduct.PRODUCT_ID]: 'coke_zero',
                [AirbridgeProduct.NAME]: 'Coke Zero',
                [AirbridgeProduct.PRICE]: 1.99,
                [AirbridgeProduct.CURRENCY]: 'USD',
                [AirbridgeProduct.POSITION]: 1,
                [AirbridgeProduct.QUANTITY]: 1,
            },
            {
                [AirbridgeProduct.PRODUCT_ID]: 'burger_cheese_double',
                [AirbridgeProduct.NAME]: 'Double Cheeseburger',
                [AirbridgeProduct.PRICE]: 3.99,
                [AirbridgeProduct.CURRENCY]: 'USD',
                [AirbridgeProduct.POSITION]: 2,
                [AirbridgeProduct.QUANTITY]: 1,
            },
        ]
    }
});
```

###### Add to Cart

```javascript lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
Airbridge.trackEvent(AirbridgeCategory.ADD_TO_CART, {
    value: 5.98,
    semanticAttributes: {
        [AirbridgeAttributes.CART_ID]: 'ID-1234567890',
        [AirbridgeAttributes.CURRENCY]: 'USD',
        [AirbridgeAttributes.PRODUCTS]: [
            {
                [AirbridgeProduct.PRODUCT_ID]: 'coke_zero',
                [AirbridgeProduct.NAME]: 'Coke Zero',
                [AirbridgeProduct.PRICE]: 1.99,
                [AirbridgeProduct.CURRENCY]: 'USD',
                [AirbridgeProduct.POSITION]: 1,
                [AirbridgeProduct.QUANTITY]: 1,
            },
            {
                [AirbridgeProduct.PRODUCT_ID]: 'burger_cheese_double',
                [AirbridgeProduct.NAME]: 'Double Cheeseburger',
                [AirbridgeProduct.PRICE]: 3.99,
                [AirbridgeProduct.CURRENCY]: 'USD',
                [AirbridgeProduct.POSITION]: 2,
                [AirbridgeProduct.QUANTITY]: 1,
            },
        ]
    }
});
```

###### Purchase

```javascript lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
Airbridge.trackEvent(AirbridgeCategory.ORDER_COMPLETED, {
    value: 5.98,
    semanticAttributes: {
        [AirbridgeAttributes.TRANSACTION_ID]: 'transactionID-purchase',
        [AirbridgeAttributes.CURRENCY]: 'USD',
        [AirbridgeAttributes.IN_APP_PURCHASED]: true,
        [AirbridgeAttributes.PRODUCTS]: [
            {
                [AirbridgeProduct.PRODUCT_ID]: 'coke_zero',
                [AirbridgeProduct.NAME]: 'Coke Zero',
                [AirbridgeProduct.PRICE]: 1.99,
                [AirbridgeProduct.CURRENCY]: 'USD',
                [AirbridgeProduct.POSITION]: 1,
                [AirbridgeProduct.QUANTITY]: 1,
            },
            {
                [AirbridgeProduct.PRODUCT_ID]: 'burger_cheese_double',
                [AirbridgeProduct.NAME]: 'Double Cheeseburger',
                [AirbridgeProduct.PRICE]: 3.99,
                [AirbridgeProduct.CURRENCY]: 'USD',
                [AirbridgeProduct.POSITION]: 2,
                [AirbridgeProduct.QUANTITY]: 1,
            },
        ]
    }
});
```

### Verify Event Transmission

Make sure that the events are being properly sent through the SDK.

1. Send an event with the SDK.
2. Check if the event shows up at "Airbridge dashboard → Raw Data → App Real-time Logs".

## Advanced Setup

***

Please refer to the below guides for advanced settings.

* [Advanced Setup Guide](/en/developers/deprecated-react-native-sdk-v2#advanced-setup)

### SDK Signature Setup

Protection against SDK spoofing is possible once you set your SDK Signature.

This feature is available for the Airbridge Cordova SDK v2.2.0 and above.

* Add the following lines in the airbridge.json file.

```json lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
{
    "sdkSignatureSecretID": "YOUR_SDK_SIGNATURE_SECRET_ID",
    "sdkSignatureSecret": "YOUR_SDK_SIGNATURE_SECRET"
}
```

<Note>
  Please ask your CSM for the "SDK Signature Secret ID" and "SDK Signature Secret" values.
</Note>

### Braze Integration

Use the SDK to SDK method to automatically send Airbridge attribution information to Braze.

Please refer to the [Braze integration guide](/en/developers/braze) for more details.

###### iOS

Modify `ios/[Project name]/AppDelegate.m` as below.

```objective-c lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
#import <AirBridge/AirBridge.h>
...

@interface AppDelegate () <ABTrackingDelegate>

@end

@implementation AppDelegate

...

- (void)airbridgeUserAttributed:(ABAttribution *)attribution {
    /* convert airbridge-attribution to braze-attribution */
    ABKAttributionData *abkAttributionData = [[ABKAttributionData alloc] initWithNetwork:attribution.source
                                                                                campaign:attribution.campaign
                                                                                 adGroup:attribution.adgroup
                                                                                creative:attribution.adcreative];

    /* add attribution-data to user */
    [[[Appboy sharedInstance] user] setAttributionData:abkAttributionData];

    [[[Appboy sharedInstance] user] setCustomAttributeWithKey:@"airbridge_medium"
                                               andStringValue:attribution.medium];
    [[[Appboy sharedInstance] user] setCustomAttributeWithKey:@"airbridge_ad_content"
                                               andStringValue:attribution.adcontent];
    [[[Appboy sharedInstance] user] setCustomAttributeWithKey:@"airbridge_search_keyword"
                                               andStringValue:attribution.searchKeyword];

    /* send event to Braze */
    [[Appboy sharedInstance] flushDataAndProcessRequestQueue];
}

...

@end
```

###### Android

Modify `android/app/src/main/java/.../MainApplication.java` as below.

```java lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
import io.airbridge.AirBridge;
...

@Override
public void onCreate() {
    super.onCreate();

    ...
    /* Braze init */
    registerActivityLifecycleCallbacks(new AppboyLifecycleCallbackListener(...));
    ...

    /* Airbridge-Cordova-SDK init */
    AirbridgeCO.init(this, "YOUR_APP_NAME", "YOUR_APP_SDK_TOKEN");

    /* Braze integration with Airbridge-Android-SDK */
    AirBridge.turnOnIntegration(new AppBoyIntegrator());
}
```

The code related to the Airbridge-Braze integration should be written under `Braze init`.

### Uninstall Tracking

<Note>
  This feature is available only for Codova Ionic PhoneGap SDK v2.1.0+.

  * Airbridge Android SDK v2.6.0+
  * Airbridge iOS SDK v1.28.2+
</Note>

Please refer to [Android Guide](/en/developers/uninstall-tracking-deprecated-android-sdk-v2) and [iOS Guide](/en/developers/uninstall-tracking-deprecated-ios-sdk-v1) for details.

###### Send Push Token

```javascript lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
Airbridge.registerPushToken(token);
```

Forward the push token to Airbridge using the `registerPushToken` method.

Make sure the notification is not shown on the device if the remote message value is `airbridge-uninstall-tracking`.

## Troubleshooting

***

### Update 1.X.X → 2.X.X

The event API has been replaced to the below.

```javascript lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
/**
 * Send event to server.
 * @param {string} category event name
 * @param {EventOption} [option={}] event options
 */
trackEvent(category: string, option?: EventOption): void;
```

Refer to the [Cordova 2.X.X migration](https://airbridge.readme.io/v1.1-en/page/cordova-2xx-migration-guide-1) guide for details.

### Bitcode Compile Error

An error like below may occur when creating iOS builds with Cordova Ionic PhoneGap SDK v2.0.1+.

```text theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
ld: XCFrameworkIntermediates/AirBridge/AirBridge.framework/AirBridge(AirBridge-arm64-master.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE)
```

Since Cordova Ionic PhoneGap SDK v2.0.1+ uses Airbridge iOS SDK v1.28.0+, Bitcode is no longer supported. Please refer to the [Bitcode compile error guide](/en/developers/deprecated-ios-sdk-v1#bitcode-compile-error) for more details.

### Update 1.1.X → 1.2.X

Uninstall the old version of the Airbridge SDK.

Cordova: `cordova plugin remove airbridge-cordova-sdk`

Ionic: `ionic cordova plugin remove airbridge-cordova-sdk`

PhoneGap: `phonegap plugin remove airbridge-cordova-sdk`

Install the new version of the Airbridge SDK.

Cordova: `cordova plugin add airbridge-cordova-sdk`

Ionic: `ionic cordova plugin add airbridge-cordova-sdk`

PhoneGap: `phonegap plugin add airbridge-cordova-sdk`

###### Android

Modify `android/app/src/main/java/.../MainActivity` as below.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
-     AirbridgeCO.getDeeplink().fetch(getIntent())
+     AirbridgeCO.processDeeplinkData(getIntent())
```

###### iOS

Modify `ios/[Project Name]/AppDelegate` as below.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
-     AirbridgeCO.deeplink()?.handleURLSchemeDeeplink(url, withSourceBundle: sourceApplication)
+     AirbridgeCO.deeplink()?.handleURLSchemeDeeplink(url)
```

###### Settings

1. Add an `airbridge.json`file to the project folder.
2. Add the parameters shown in the example below in JSON format.

###### Example

```json lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
{
    "sessionTimeoutSeconds": 300,
    "autoStartTrackingEnabled": true,
    "userInfoHashEnabled": true,
    "trackAirbridgeLinkOnly": false,
    "facebookDeferredAppLinkEnabled": false,
    "locationCollectionEnabled": false
    "trackingAuthorizeTimeoutSeconds": 0
}
```

###### Description

| Name                            | Type    | Default | Description                                                                                                                                                                                                                 |
| ------------------------------- | ------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| sessionTimeoutSeconds           | number  | 300     | An app open event will not be sent when the app is reopened within the designated period.                                                                                                                                   |
| autoStartTrackingEnabled        | boolean | true    | When set to false, no events will be sent until `airbridge.state.startTracking()` is called.                                                                                                                                |
| userInfoHashEnabled             | boolean | true    | When set to false, user email and user phone information are sent without being hashed.                                                                                                                                     |
| trackAirbridgeLinkOnly          | boolean | false   | When set to true, deep link events are sent only when app is opened with an Airbridge deep link.                                                                                                                            |
| facebookDeferredAppLinkEnabled  | boolean | false   | When set to true and the Facebook SDK is installed, Facebook Deferred App Link data is collected.                                                                                                                           |
| locationCollectionEnabled       | boolean | false   | When set to true, location information is collected. (Android Only)<br />Two permissions must be allowed in `AndroidManifest.xml`android.permission.ACCESS\_FINE\_LOCATION<br />android.permission.ACCESS\_COARSE\_LOCATION |
| trackingAuthorizeTimeoutSeconds | number  | 0       | When set timeout, Install event is delayed until Request tracking authorization alert is clicked. (iOS only)                                                                                                                |

### Update 1.0.X → 1.1.X

###### Install

Uninstall the old version of the Airbridge SDK.

Cordova: `cordova plugin remove airbridge-cordova-sdk`

Ionic: `ionic cordova plugin remove airbridge-cordova-sdk`

PhoneGap: `phonegap plugin remove airbridge-cordova-sdk`

Install the new version of the Airbridge SDK.

Cordova: `cordova plugin add airbridge-cordova-sdk`

Ionic: `ionic cordova plugin add airbridge-cordova-sdk`

PhoneGap: `phonegap plugin add airbridge-cordova-sdk`

`setDeeplinkListener`

Remove the `getInitialDeeplink` function and use the `setDeeplinkListener` function only.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
- Airbridge.deeplink.getInitialDeeplink().then((deeplink) => {
-
- });
. 
. Airbridge.deeplink.setDeeplinkListner((deeplink) => {
. 
. });
```

###### Android

`AndroidManifest.xml`

In the `MainActivity` section of the `android/app/src/main/AndroidManifest.xml` file, add `intent-filter` parameters as below.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
+ <intent-filter android:autoVerify="true">
+     <action android:name="android.intent.action.VIEW" />
+
+     <category android:name="android.intent.category.DEFAULT" />
+     <category android:name="android.intent.category.BROWSABLE" />
+
+     <data android:scheme="http" android:host="YOUR_APP_NAME.deeplink.page" />
+     <data android:scheme="https" android:host="YOUR_APP_NAME.deeplink.page" />
+ </intent-filter>
. <intent-filter android:autoVerify="true">
.     <action android:name="android.intent.action.VIEW" />
. 
.     <category android:name="android.intent.category.DEFAULT" />
.     <category android:name="android.intent.category.BROWSABLE" />
. 
.     <data android:scheme="http" android:host="YOUR_APP_NAME.airbridge.io" />
.     <data android:scheme="https" android:host="YOUR_APP_NAME.airbridge.io" />
. </intent-filter>
. <intent-filter>
.     <action android:name="android.intent.action.VIEW" />
. 
.     <category android:name="android.intent.category.DEFAULT" />
.     <category android:name="android.intent.category.BROWSABLE" />
. 
.     <data android:scheme="EXAMPLE_SCHEME" />
. </intent-filter>
```

###### `MainActivity.java`

Modify `android/app/src/main/java/.../MainActivity.java` as below.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
. import co.ab180.airbridge.cordova.AirbridgeCO;
. 
. public class MainActivity extends ReactActivity {
+     @Override
+     protected void onResume() {
+         super.onResume();
+ 
+         AirbridgeCO.getDeeplink().fetch(getIntent());
+     }
+  
.     @Override
.     public void onNewIntent(Intent intent) {
.         super.onNewIntent(intent);
.         setIntent(intent);
.     }
. }
```

###### iOS

###### Universal Link

1. Go to "Xcode → Project file → Signing & Capabilities".
2. Click "+ Capability" and add "Associated Domains".
3. Add `applinks:YOUR_APP_NAME.deeplink.page`to "Associated Domains".

`YOUR_APP_NAME` can be found at the "Airbridge dashboard → Settings → Tokens → App Name". `AppDelegate.m`

Modify `ios/.../AppDelegate.m` as below.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
. - (BOOL)application:(UIApplication *)application
.             openURL:(NSURL *)url
.             options:(NSDictionary<UIApplicationOpenURLOptionsKey, id>*)options
. {
-     [AirbridgeCO.instance handleURLSchemeDeeplink:url
-                                withSourceBundle:options[UIApplicationOpenURLOptionsSourceApplicationKey]];
+     [AirbridgeCO.deeplink handleURLSchemeDeeplink:url
+                                withSourceBundle:options[UIApplicationOpenURLOptionsSourceApplicationKey]];
. 
.     return YES;
. }
. 
. - (BOOL)application:(UIApplication*)application
.             openURL:(NSURL*)url
.   sourceApplication:(NSString*)sourceApplication 
.          annotation:(id)annotation
. {
-     [AirbridgeCO.instance handleURLSchemeDeeplink:url
-                                withSourceBundle:sourceApplication];
+     [AirbridgeCO.deeplink handleURLSchemeDeeplink:url
+                                withSourceBundle:sourceApplication];
. 
.     return YES;
. }
```

When targeting iOS 8.x or earlier, also make the following changes.

```diff lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
. -  (BOOL)application:(UIApplication*)application
. continueUserActivity:(NSUserActivity*)userActivity
.   restorationHandler:(void (^)(NSArray* _Nullable))restorationHandler
. {
-     [AirbridgeCO.instance handleUniversalDeeplink:userActivity.webpageURL];
+     [AirbridgeCO.deeplink handleUniversalLink:userActivity.webpageURL];
. 
.     return YES;
. }
```

<link rel="alternate" hrefLang="en" href="https://help.airbridge.io/en/developers/deprecated-cordova-ionic-sdk-v2" />

<link rel="alternate" hrefLang="ko" href="https://help.airbridge.io/ko/developers/deprecated-cordova-ionic-sdk-v2" />
