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

# Initialization

Run Link via the Web, iOS, Android, React Native, or Flutter.

## Overview

The platform-specific guides below discuss how to initialize Link for first time implementations, or adjust your existing implementation to add new functionalities. For steps on how to update an existing Link implementation to a newer version, visit our [Upgrade Guide](/link/upgrade) instead.

<Note>
  For iOS, Android, and React Native implementations, Link SDKs are maintained and updated through Argyle's public [GitHub repository](https://github.com/argyle-systems). For Flutter implementations, follow the steps in our [Flutter initialization guide](/link/initialization/mobile-sdks#flutter).
</Note>

Link initializations must be configured using the parameters below. There are two required parameters, in addition to a number of optional parameters that are used to add customizations and additional Link features.

### Required initialization parameters

<table>
  <thead>
    <tr>
      <th>Parameter</th>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><code>sandbox</code></td>
      <td>boolean</td>
      <td>Determines Link's environment — <code>true</code> for Sandbox, <code>false</code> for Production.</td>
    </tr>

    <tr>
      <td><code>userToken</code></td>
      <td>string</td>
      <td>Argyle utilizes user tokens to identify and authenticate users. See our dedicated <a href="/link/user-tokens">User Tokens Guide</a> for more information.</td>
    </tr>
  </tbody>
</table>

### Optional initialization parameters

<table>
  <thead>
    <tr>
      <th>Parameter</th>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><code>flowId</code></td>
      <td>string</td>

      <td>
        ID used to <a href="/console/flows/embedded-experiences">customize</a> the Link flow. Saved IDs can be found in the <a href="https://console.argyle.com/flows" target="_blank">Flows</a> section of Console.

        <Note>
          Flow IDs are not environment-specific. The same Flow ID will apply consistent behavior across both Sandbox and Production.
        </Note>
      </td>
    </tr>

    <tr>
      <td><code>ddsConfig</code></td>
      <td>string</td>
      <td>Used to initialize a <a href="/workflows/deposit-switching">deposit switch</a>.</td>
    </tr>

    <tr>
      <td><code>items</code></td>
      <td>array of strings</td>
      <td>Limits Link search to the provided list of Items. <em>Providing a single Item in the array will skip Link search and take the user directly to that Item's login screen.</em></td>
    </tr>

    <tr>
      <td><code>accountId</code></td>
      <td>string</td>
      <td>Used for <a href="/workflows/account-connections#direct-login">direct logins</a> to an account that the user has previously connected or attempted to connect.</td>
    </tr>

    <tr>
      <td><code>\<Callback Name></code></td>
      <td>string</td>
      <td><a href="/link/reference/callbacks">Callbacks</a> are activated by specific events in Link.</td>
    </tr>

    <tr>
      <td><code>language</code></td>
      <td>string</td>

      <td>
        Specifies the display language in Link.

        <ul>
          <li><code>EN</code> and <code>ES</code> are available across all platforms and employers</li>
          <li><code>RU</code> and <code>ZH</code> currently limited to <a href="/overview/data-structure/items#types-of-items">gig platforms</a></li>
          <li>Can be used in combination with other optional initialization parameters including <code>flowId</code></li>
          <li>Certain platform-generated messages (such as multi-factor authentication prompts) will be shown as-received, and depend on the user's language preferences selected within their platform's settings.</li>
          <li>In Console, you can test Spanish in Sandbox mode by changing the **Language** dropdown when previewing an **Embedded Experiences** Link Flow.</li>
        </ul>

        <Note>
          <strong>Possible values</strong>: <code>EN</code> (English), <code>ES</code> (Spanish), <code>RU</code> (Russian), <code>ZH</code> (Chinese).<br /><em>\*Flutter uses lowercase <code>en</code>, <code>es</code>, <code>ru</code>, <code>zh</code>.</em>
        </Note>
      </td>
    </tr>
  </tbody>
</table>

## Web

<div className="argyle-divider" />

### Before you start

1. When using a webview component, make sure `localStorage` is always enabled, and set `domStorageEnabled` to `true`
   and `incognito` to `false`.
2. If your security policy limits outgoing traffic, allow API calls by whitelisting outgoing traffic from Link by including these two content sources at minimum:

```html theme={}
<meta http-equiv="Content-Security-Policy" content="connect-src https://*.argyle.com; worker-src 'self' blob:" />
```

### Implementing Link for web

Create a [user token](/link/user-tokens):

<Tabs>
  <Tab title="New users">
    1. Create a new user by sending a **POST** request to the API's [`/users`](/api-reference/users#create) endpoint.
    2. The response payload will include an `id` and `user_token`.
    3. Save the `id` for quickly creating user tokens for this user in the future.
    4. Pass the `user_token` as the value for the `userToken` parameter in your Link initialization.
  </Tab>

  <Tab title="Returning users">
    1. Send a POST request to the API's [`/user-tokens`](/api-reference/user-tokens#create) endpoint. Include the `id` of the user in the request body as a JSON object in the format `{"user": "<id>"}`.
    2. A `user_token` will be included in the response payload.
    3. Pass the `user_token` as the value for the `userToken` parameter in your Link initialization.
  </Tab>
</Tabs>

Initialize Link using the HTML below, replacing the user token.

<Tabs>
  <Tab title="Web">
    ```html theme={}
    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="utf-8" />
        <!-- This is needed in order to apply proper scaling on mobile devices -->
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
      </head>

      <body>
        <script src="https://plugin.argyle.com/argyle.web.v5.js"></script>
        <script type="text/javascript">
          const linkInstance = Argyle.create({
              userToken: 'USER_TOKEN',
              sandbox: true, // Set to false for production environment.
              // (Optional) Add a Link flow customization created in Console:
              //    flowId: '<ID of the Link flow>',
              // (Optional) Add a deposit switch flow:
              //    ddsConfig: '<Encrypted target deposit destination value>',
              // (Optional) Limit Link search to specific Items:
              //    items: ['item_000000001', 'item_000000002'],
              // (Optional) Connect directly to an existing account:
              //    accountId: '<ID of the account>',
              // (Optional) Set a language. Options: EN, ES, RU, ZH
              //    language: 'EN',
              // (Optional) A few recommended callbacks:
              onAccountConnected: payload => console.log('onAccountConnected', payload),
              onAccountError: payload => console.log('onAccountError', payload),
              onDDSSuccess: payload => console.log('onDDSSuccess', payload),
              onDDSError: payload => console.log('onDDSError', payload),
              onTokenExpired: updateToken => {
                  console.log('onTokenExpired')
                  // Generate a new user token.
                  // updateToken(newToken)
              }
          })
          linkInstance.open()
          // linkInstance.close() // Manually close Link (typically the user closes Link).
        </script>
      </body>
    </html>
    ```
  </Tab>
</Tabs>

## iOS

Argyle's [iOS Link SDK](https://github.com/argyle-systems/argyle-link-ios) provides a way to integrate Link into your iOS app. First-time installation instructions are below. To update versions, visit our [iOS Link upgrade guide](/link/upgrade#ios).

### Requirements - iOS SDK

iOS 14.0+, Xcode 14.0+, Swift 5.5+

### Installing the iOS SDK

<Tabs>
  <Tab title="CocoaPods">
    **If using [Cocoapods](https://cocoapods.org/):**

    1. In the `Podfile` of your Xcode project, add `pod 'Argyle', '<Version Number>'`
    2. Run `pod install` to install the Argyle pod
    3. Run `pod update` to ensure the most recent Argyle pod is installed
  </Tab>

  <Tab title="Swift Package Manager">
    **If using [Swift Package Manager](https://www.swift.org/package-manager/):**

    1. Within your Xcode project, select File > Swift Packages > Add Package Dependency
    2. Find `argyle-link-ios` by searching with URL of the [iOS SDK Github repo](https://github.com/argyle-systems/argyle-link-ios)

    See [adding Swift package dependencies in Xcode](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app#Add-a-package-dependency) for more information.
  </Tab>
</Tabs>

### Directly opening email clients

To enhance the multi-factor authentication (MFA) experience of users, the iOS Link SDK supports directly opening the user's email client.

To enable this feature, add the following property to your `Info.plist` file:

```text theme={}
<key>LSApplicationQueriesSchemes</key>
<array>
    <string>googlegmail</string>
    <string>ymail</string>
    <string>ms-outlook</string>
</array>
```

### Implementing Link for iOS

Create a user token:

<Tabs>
  <Tab title="New users">
    1. Create a new user by sending a **POST** request to the API's [`/users`](/api-reference/users#create) endpoint.
    2. The response payload will include an `id` and `user_token`.
    3. Save the `id` for quickly creating user tokens for this user in the future.
    4. Pass the `user_token` as the value for the `userToken` parameter in your Link initialization.
  </Tab>

  <Tab title="Returning users">
    1. Send a POST request to the API's [`/user-tokens`](/api-reference/user-tokens#create) endpoint. Include the `id` of the user in the request body as a JSON object in the format `{"user": "<id>"}`.
    2. A `user_token` will be included in the response payload.
    3. Pass the `user_token` as the value for the `userToken` parameter in your Link initialization.
  </Tab>
</Tabs>

Initialize Link using the configuration below, replacing the user token.

<Tabs>
  <Tab title="iOS">
    ```swift theme={}
    var config = LinkConfig(
        userToken: "USER_TOKEN",
        sandbox: true // Set to false for production environment.
    )
    // (Optional) Add a Link flow customization created in Console:
    //    config.flowId = "<ID of the Link flow>"
    // (Optional) Add a deposit switch flow:
    //    config.ddsConfig = "<Encrypted target deposit destination value>"
    // (Optional) Limit Link search to specific Items:
    //    config.items = ["item_000000001", "item_000000002"]
    // (Optional) Connect directly to an existing account:
    //    config.accountId = "<ID of the account>"
    // (Optional) Set a language. Options: EN, ES, RU, ZH
    //    config.language = .EN
    // (Optional) A few recommended callbacks:
    config.onAccountConnected = { data in
        print("Result: onAccountConnected \(data)")
    }
    config.onAccountError = { data in
        print("Result: onAccountError \(data)")
    }
    config.onDDSSuccess = { data in
        print("Result: onDDSSuccess \(data)")
    }
    config.onDDSError = { data in
        print("Result: onDDSError \(data)")
    }
    config.onTokenExpired = { handler in
    		print("onTokenExpired")
    		// Generate a new user token.
        // handler(newToken)
    }

    ArgyleLink.start(from: viewController, config: config)
    // ArgyleLink.close()   // Manually close Link (typically the user closes Link).
    ```
  </Tab>
</Tabs>

## Android

Argyle's [Android Link SDK](https://github.com/argyle-systems/argyle-link-android) provides a way to integrate Link into your Android app. First-time installation instructions are below. To update versions, visit our [Android Link upgrade guide](/link/upgrade#android).

### Requirements - Android SDK

* Android 8.0 (minSdk/API level 26) and above
* compileSdk 34 and above

### Installing the Android SDK

1. Add the line below within the dependencies of your `build.gradle` [configuration file](https://developer.android.com/studio/build#top-level).
2. [Sync your Android project](https://developer.android.com/studio/build#sync-files) to import the build configuration changes.

```text theme={}
dependencies {
    implementation 'com.argyle:argyle-link-android:5.x.x'
}
```

<Accordion title="If you are using tools like ProGuard to obfuscate your code...">
  Make sure to exclude the Link SDK package `com.argyle.*`. For example, add the following line to the `proguard-rules.pro` file of your ProGuard configuration:

  ```text theme={}
  -keep class com.argyle. { *; }
  ```
</Accordion>

### Implementing Link for Android

Create a user token:

<Tabs>
  <Tab title="New users">
    1. Create a new user by sending a **POST** request to the API's [`/users`](/api-reference/users#create) endpoint.
    2. The response payload will include an `id` and `user_token`.
    3. Save the `id` for quickly creating user tokens for this user in the future.
    4. Pass the `user_token` as the value for the `userToken` parameter in your Link initialization.
  </Tab>

  <Tab title="Returning users">
    1. Send a POST request to the API's [`/user-tokens`](/api-reference/user-tokens#create) endpoint. Include the `id` of the user in the request body as a JSON object in the format `{"user": "<id>"}`.
    2. A `user_token` will be included in the response payload.
    3. Pass the `user_token` as the value for the `userToken` parameter in your Link initialization.
  </Tab>
</Tabs>

Initialize Link using the configuration below, replacing the user token.

<Tabs>
  <Tab title="Android">
    ```kotlin theme={}
    val config = LinkConfig(
        userToken = "USER_TOKEN",
        sandbox = true // Set to false for production environment.
    )
    // (Optional) Add a Link flow customization created in Console:
    //    config.flowId = "<ID of the Link flow>"
    // (Optional) Add a deposit switch flow:
    //    config.ddsConfig = "<Encrypted target deposit destination value>"
    // (Optional) Limit Link search to specific Items:
    //    config.items = listOf("item_000000001", "item_000000002")
    // (Optional) Connect directly to an existing account:
    //    config.accountId = "<ID of the account>"
    // (Optional) Set a language. Options: EN, ES, RU, ZH
    //    config.language = Language.EN,
    // (Optional) A few recommended callbacks:
    config.onAccountConnected = { data ->
        Log.d("Result", "onAccountConnected $data")
    }
    config.onAccountError = { data ->
        Log.d("Result", "onAccountError $data")
    }
    config.onDDSSuccess = { data ->
        Log.d("Result", "onDDSSuccess $data")
    }
    config.onDDSError = { data ->
        Log.d("Result", "onDDSError $data")
    }
    config.onTokenExpired = { handler ->
    		// Generate a new user token.
        // handler(newToken)
    }

    ArgyleLink.start(context, config)
    // ArgyleLink.close()   // Manually close Link (typically the user closes Link).
    ```
  </Tab>
</Tabs>

## React Native

Argyle's [React Native Link SDK](https://github.com/argyle-systems/argyle-link-react-native) provides a way to integrate Link into your React Native application. First-time installation instructions are below. To update versions, visit our [React Native Link upgrade guide](/link/upgrade#react-native).

### Requirements - React Native SDK

* React Native version 0.73.0 or higher

* *iOS-specific* — iOS 14.0+

* *Android-specific*:

* Android 8.0 (minSdk/API level 26) and above

* compileSdk 34 and above

<Tabs>
  <Tab title="If using ProGuard-like tools to obfuscate code...">
    <Accordion title="If you are using tools like ProGuard to obfuscate your code...">
      Make sure to exclude the Link SDK package `com.argyle.*`. For example, add the following line to the bottom of your ProGuard configuration:
    </Accordion>

    ```text theme={}
    -keep class com.argyle. { *; }
    ```
  </Tab>

  <Tab title="In case of runtime issues related to the okhttp3 library...">
    The Link SDK package currently has a dependency of `okhttp3:4.9.2`. If your dependencies use an older version (e.g. `okhttp3.3.xx`) they may need updating to a version that uses `okhttp3.4.x.x`.

    Alternatively, you can attempt to force the Link SDK dependency as follows:

    ```text theme={}
    configurations.all {
        resolutionStrategy.force 'com.squareup.okhttp3:okhttp:4.9.x'
        resolutionStrategy.force 'com.squareup.okhttp3:okhttp-urlconnection:4.9.x'
    }
    ```
  </Tab>
</Tabs>

### Installing the React Native SDK

1. Navigate to the directory for your React Native project.
2. Install the packages from your terminal:

<Tabs>
  <Tab title="NPM">
    ```text theme={}
    npm install @argyleio/argyle-plugin-react-native --save
    ```
  </Tab>

  <Tab title="Yarn">
    ```text theme={}
    yarn add @argyleio/argyle-plugin-react-native
    ```
  </Tab>
</Tabs>

After installation:

1. Run `cd ios` to navigate to the `ios` folder.
2. Run `pod install` to install the Argyle pod.
3. Run `pod update` to ensure the most recent Argyle pod is installed.

### Implementing Link for React Native

Create a user token:

<Tabs>
  <Tab title="New users">
    1. Create a new user by sending a **POST** request to the API's [`/users`](/api-reference/users#create) endpoint.
    2. The response payload will include an `id` and `user_token`.
    3. Save the `id` for quickly creating user tokens for this user in the future.
    4. Pass the `user_token` as the value for the `userToken` parameter in your Link initialization.
  </Tab>

  <Tab title="Returning users">
    1. Send a POST request to the API's [`/user-tokens`](/api-reference/user-tokens#create) endpoint. Include the `id` of the user in the request body as a JSON object in the format `{"user": "<id>"}`.
    2. A `user_token` will be included in the response payload.
    3. Pass the `user_token` as the value for the `userToken` parameter in your Link initialization.
  </Tab>
</Tabs>

Initialize Link using the configuration below, replacing the user token.

<Tabs>
  <Tab title="React Native">
    ```js theme={}
    import { ArgyleLink } from '@argyleio/argyle-plugin-react-native';

    // ...

    const config = {
      userToken: 'USER_TOKEN',
      sandbox: true, // Set to false for production environment.
      // (Optional) Add a Link flow customization created in Console:
      //    flowId: '<ID of the Link flow>',
      // (Optional) Add a deposit switch flow:
      //    ddsConfig: '<Encrypted target deposit destination value>',
      // (Optional) Limit Link search to specific Items:
      //    items: ['item_000000001', 'item_000000002'],
      // (Optional) Connect directly to an existing account:
      //    accountId: '<ID of the account>',
      // (Optional) Set a language. Options: EN, ES, RU, ZH
      //    language: Language.EN,
      // (Optional) Callback examples:
      onAccountConnected: (payload) => console.log('onAccountConnected', payload),
      onAccountError: (payload) => console.log('onAccountError', payload),
      onDDSSuccess: (payload) => console.log('onDDSSuccess', payload),
      onDDSError: (payload) => console.log('onDDSError', payload),
      onTokenExpired: (updateToken) => {
        console.log('onTokenExpired');
        // Generate a new user token.
        // updateToken(newToken)
      },
    };

    ArgyleLink.start(config);
    // ArgyleLink.close()   // Manually close Link (typically the user closes Link).
    ```
  </Tab>
</Tabs>

## Flutter

Argyle's [Flutter SDK](https://github.com/argyle-systems/argyle-link-flutter) provides a way to integrate Link into your mobile applications. First-time installation instructions are below. To update versions, visit our [Flutter upgrade guide](/link/upgrade#flutter).

### Requirements - Flutter SDK

<Tabs>
  <Tab title="Android">
    * Android 8.0 (minSdk/API level 26) and above
    * compileSdk 34 and above

    Set the `minSdkVersion` in your `android/app/build.gradle` file to:

    ```text theme={}
    android {
        defaultConfig {
            minSdkVersion 26 // or greater
        }
    }
    ```
  </Tab>

  <Tab title="iOS">
    * iOS 14.0+, Xcode 14.0+, Swift 5.5+
  </Tab>
</Tabs>

### Installing the Flutter SDK

Add `argyle_link_flutter` as a [dependency](https://docs.flutter.dev/development/packages-and-plugins/using-packages) in your `pubspec.yaml` file.

<Accordion title="Example installation:">
  Using Flutter, run the command:

  ```text theme={}
  $ flutter pub add argyle_link_flutter
  ```

  This will add a line to your `pubspec.yaml` file with the latest SDK version:

  ```text theme={}
  dependencies:
    argyle_link_flutter: ^1.x.x
  ```

  You can now import the package into your Dart code using:

  ```text theme={}
  import 'package:argyle_link_flutter/argyle_link_flutter.dart';
  ```
</Accordion>

### Implementing Link for Flutter

Create a user token:

<Tabs>
  <Tab title="New users">
    1. Create a new user by sending a **POST** request to the API's [`/users`](/api-reference/users#create) endpoint.
    2. The response payload will include an `id` and `user_token`.
    3. Save the `id` for quickly creating user tokens for this user in the future.
    4. Pass the `user_token` as the value for the `userToken` parameter in your Link initialization.
  </Tab>

  <Tab title="Returning users">
    1. Send a POST request to the API's [`/user-tokens`](/api-reference/user-tokens#create) endpoint. Include the `id` of the user in the request body as a JSON object in the format `{"user": "<id>"}`.
    2. A `user_token` will be included in the response payload.
    3. Pass the `user_token` as the value for the `userToken` parameter in your Link initialization.
  </Tab>
</Tabs>

Initialize Link using the configuration below, replacing the user token.

<Tabs>
  <Tab title="Flutter">
    ```dart theme={}
    import 'package:argyle_link_flutter/link_config.dart';
    // (Required if using callbacks) Callback argument type definitions:
    import 'package:argyle_link_flutter/account_data.dart';
    import 'package:argyle_link_flutter/argyle_link.dart';
    import 'package:argyle_link_flutter/form_data.dart';

    // ...

    final config = LinkConfig(
      userToken: 'USER_TOKEN',
      sandbox: true, // Set to false for production environment.
      // (Optional) Add a Link flow customization created in Console:
      //    flowId: '<ID of the Link flow>',
      // (Optional) Add a deposit switch flow:
      //    ddsConfig: '<Encrypted target deposit destination value>',
      // (Optional) Limit Link search to specific Items:
      //    items: ['item_000000001', 'item_000000002'],
      // (Optional) Connect directly to an existing account:
      //    accountId: '<ID of the account>',
      // (Optional) Set a language. Options: en, es, ru, zh
      //    language: Language.en,
      // (Optional) Callback examples:
      onAccountConnected: (payload) => debugPrint('onAccountConnected'),
      onAccountError: (payload) => debugPrint('onAccountError'),
      onDDSSuccess: (payload) => debugPrint('onDDSSuccess'),
      onDDSError: (payload) => debugPrint('onDDSError'),
      onTokenExpired: (updateToken) => {
        debugPrint('onTokenExpired')
        // Generate a new user token.
        // updateToken(newToken)
      },
    );

    ArgyleLink.start(config);
    // ArgyleLink.close()   // Manually close Link (typically the user closes Link).
    ```
  </Tab>
</Tabs>
