---
updatedAt: 2025-07-26T15:11:36.000Z
agentTools:
  projectIndex: https://docs.metakeep.xyz/llms.txt
---

# Introduction

## Introduction

MetaKeep mobile is a lightweight SDK that can be used in any Android, iOS, React Native, or any other mobile platform. Note that for any platform not listed here, you can write a `minimal amount` of code to `wrap the native SDKs` and expose the required functionality.

## Importing the library

Follow the instructions below for your platform to import the library.

* [Android Installation](https://docs.metakeep.xyz/reference/mobile-sdk-android-installation)
* [iOS Installation](https://docs.metakeep.xyz/reference/mobile-sdk-ios-installation)
* [React Native Installation](https://docs.metakeep.xyz/reference/mobile-sdk-react-native-installation)
* [Flutter Installation](https://docs.metakeep.xyz/reference/mobile-sdk-flutter-installation)

## Initializing the library

Now that you've imported `MetaKeep Mobile SDK`, you need to first initialize the SDK with the `appId`. You can find `appId` in the developer console. Here are examples-

```kotlin Initialize SDK Android - Kotlin
import xyz.metakeep.sdk.*

// Init SDK
// Replace with your own App id.
val sdk = MetaKeep(appId = "<app_id>", AppContext(activity!!))
```
```swift Initialize SDK iOS - Swift
import MetaKeep

// Init SDK
// Replace with your own App id.
// Note the empty AppContext class. It's reserved for future use.
let sdk = MetaKeep(appId: "<app_id>", appContext: AppContext())
```
```javascript React Native
import MetaKeep from 'metakeep-react-native-sdk';

// Init SDK
// Replace with your own App id.
const sdk = new MetaKeep( "<app_id>");
```
```javascript Flutter
import 'package:metakeep_flutter_sdk/metakeep_flutter_sdk.dart';

// Init SDK
// Replace with your own App id.
const sdk = new MetaKeep( "<app_id>");
```

> ❗️ SDK can only be initialized inside an Activity or Fragment on Android.
>
> Make sure to initialize the SDK inside your Activity or Fragment. Otherwise, the activity will be null causing your app to crash.

If you already have a signed-in user, you can provide the user's email address to the MetaKeep SDK. This provides a native logged-in user experience when your app and MetaKeep SDK are interacting. If the user's email is not provided, the SDK will ask the user for their email address when you perform the first SDK operation.

```kotlin Set user email Android - Kotlin
sdk.user = User(email = "user@email.com")
```
```swift Set user email iOS - Swift
sdk.user = User(email: "user@email.com")
```
```javascript Set user email - React Native
await sdk.setUser({
    email: 'user@email.com',
  });
```
```javascript Set user email - Flutter
await sdk.setUser({
    "email": "user@email.com",
  });
```

## SDK Operation Response

On `iOS` and `Android`, all SDK operations take a `Callback` object as a parameter. The Callback object expects 2 functions as parameters: `onSuccess` and `onFailure`. The `onSuccess` function is called when the operation is successful. The `onFailure` function is called when the operation fails.

On `React Native`, all SDK operations are `asynchronous` and return a `Promise` object. The `Promise` object can be used to get the result of the operation.

On `Flutter`, all SDK operations return a `Future` object. The `Future` object can be used to get the result of the operation. The result is a `dynamic` object that contains `parsed JSON` data.

```kotlin Callback on Android - Kotlin
val callback =
    Callback(
  			// Called on operation success
        onSuccess = { response: JsonResponse -> Log.d("Success", response.toString()) },
  			// Called on operation failure
        onFailure = { error: JsonResponse -> Log.d("Error", error.toString()) },
    )
```
```swift Callback on iOS - Swift
let callback = Callback(
  // Called on operation success
  onSuccess: { (result: JsonResponse) in
    print("onSuccess")
    print(result.description)
  },
  // Called on operation failure
  onFailure: { (error: JsonResponse) in
    print("onFailure")
    print(error.description)
  }
)
```

Both functions are called with a result object of type `JsonResponse` as a parameter. The `JsonResponse` object is a wrapper around the JSON response returned by the MetaKeep API. The response will always contain a `status` field which is a string indicating the status of the operation. Here's how to read data from the response:

```kotlin JsonResponse Android - Kotlin
val callback =
    Callback(
        onSuccess = { response: JsonResponse ->
            run {
                // Status field
                val status: String? = response.data["status"]?.jsonPrimitive?.content

                // Signature field
                val signature: String? = response.data["signature"]?.jsonPrimitive?.content

                // Signature r value
                val r: String? = response.data["r"]?.jsonPrimitive?.content

                // Signature s value
                val s: String? = response.data["s"]?.jsonPrimitive?.content

                // Signature v value
                val v: String? = response.data["v"]?.jsonPrimitive?.content

                Log.d("OnSuccess", "status: $status")
                Log.d("OnSuccess", "signature: $signature")
                Log.d("OnSuccess", "r: $r")
                Log.d("OnSuccess", "s: $s")
                Log.d("OnSuccess", "v: $v")
            }
        },
        onFailure = { error: JsonResponse -> Log.d("Error", error.toString()) },
    )
```
```swift JsonResponse iOS - Swift
let callback = Callback(
  onSuccess: { (result: JsonResponse) in
    print("onSuccess")

    // Status field
    let status = result.data["status"] as? String

    // Signature field
    let signature = result.data["signature"] as? String

    // Signature r field
    let r = result.data["r"] as? String

    // Signature s field
    let s = result.data["s"] as? String

    // Signature v field
    let v = result.data["v"] as? String

    print("status: \(status ?? "UNKNOWN")")
    print("signature: \(signature ?? "UNKNOWN")")
    print("r: \(r ?? "UNKNOWN")")
    print("s: \(s ?? "UNKNOWN")")
    print("v: \(v ?? "UNKNOWN")")

  },
  onFailure: { (error: JsonResponse) in
    print("onFailure")
    print(error.description)
  }
)
```

## Configuration options

The following properties can be configured in the MetaKeep SDK:

<Table align={["left","left","left"]}>
  <thead>
    <tr>
      <th>
        Option
      </th>

      <th>
        Description
      </th>

      <th>
        Required
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        appId
      </td>

      <td>
        This is your public app ID that you get from the MetaKeep Developer Console. Use this to customize the look and feel of the MetaKeep wallet UI for your users.
      </td>

      <td>
        Yes
      </td>
    </tr>

    <tr>
      <td>
        user
      </td>

      <td>
        Use this to provide the email address of the signed-in user to create a seamless UI experience.  

        If not specified, users will be asked for their identity.
      </td>

      <td>
        No
      </td>
    </tr>
  </tbody>
</Table>

© Copyright 2024, Passbird Research Inc.