Overview

Check out the SDK Authentication guide on the available SDK authentication schemes, and how to authenticate with the Vital Mobile SDK.

Accessing Vital API

You can access Vital API through VitalClient with typed request methods and response models.

// e.g. Link Service
let linkService = VitalClient.shared.link

Typed API access is not yet available in React Native.

You can obtain an URL to the Vital Link Widget through VitalClient.linkWidgetUrl. Note that the URL contains a short-lived token with 10-minute expiry.

For the redirectUrl, you should set it to a URL with a custom URL scheme which your app would register to handle.

let widgetUrl = await VitalClient.shared.link.createProviderLink(
  redirectURL: "x-vital-app://"
)

Core SDK Status

You can inspect the status of the Core SDK for troubleshooting, as well as for your own business logic. For example, you may reconcile your user session and the Vital SDK sign-in based on the Core SDK status.

The SDK normally reports one of the following status combinations:

CombinationsAuth SchemeRemarks
EmptyN/AThe SDK has neither been configured nor an active sign-in.
ConfiguredAPI KeyThe SDK has been configured, but does not have an active sign-in.
Configured, SignedIn & UseApiKeyAPI KeyThe active sign-in was done by setting an API Key and a target Vital User ID.
Configured, SignedIn & UseSignInTokenVital Sign-In TokenThe active sign-in was done by consuming a Vital Sign-In Token.

Get the current status

import VitalCore

let status: VitalClient.Status = VitalClient.status

Observe status changes over time

import VitalCore

// Combine Publisher
let cancellable = VitalClient.statusDidChange.sink { _ in }

// AsyncStream
Task {
  for status in VitalClient.statuses {
    // ...
  }
}

Get Current Vital User ID

Aside from the Core SDK Status, you can also query the Vital User ID of the signed-in user:

import VitalCore

let userId: String? = VitalClient.currentUserId

Reset the SDK (Sign Out)

Refer to the Sign Out section in the SDK Authentication guide.