Bridge SDKs

Learn how to get started with Truv Bridge.

Overview

Truv Bridge is a drop-in module for your users. Users can then connect their accounts to Truv and allow you to access their data with Truv's API.

Truv Bridge handles employer searches, validating credentials, multi-factor authentication, and error handling. The module works across all modern browsers and platforms. This includes web, mobile, iOS, and Android, as well as through React Native, Flutter and Expo.

Libraries

The following SDK sections below are overviews on installing and using Truv Bridge. For demo applications, view the Testing page as well as the Truv GitHub link for additional information.

iOS

The Swift SDK for iOS is available on Cocoa Pods.

Install

The code below in Ruby lets you add the TruvSDK pod.

use_frameworks!

target 'MyApp' do
    pod 'TruvSDK'
end

Usage

The Swift code below helps you get Truv Bridge started.

import TruvSDK

let truvBridgeView = TruvBridgeView(token: token, delegate: self)
view.addSubview(truvBridgeView)
// add constraints if needed

Android

The Kotlin SDK for Android is available on MavenCentral.

Install

The two steps below cover the installation process for the Kotlin SDK.

  1. Add the MavenCentral repository to your project build.gradle file.
allprojects {
		repositories {
			...
			mavenCentral()
		}
	}
  1. Add the dependency to your build.gradle file.
implementation 'com.truv.sdk:android-sdk:1.5.0'

Usage

The TruvBridgeView is a View for integrating into your app workflow.

<?xml version="1.0" encoding="utf-8"?>
<com.truv.TruvBridgeView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/bridgeView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
val truvEventsListener = object : TruvEventsListener {

        override fun onClose() {
            Log.d(TAG, "Bridge Closed")
        }

        override fun onError() {
            Log.e(TAG, "Bridge Error")
        }

        override fun onEvent(event: TruvEventPayload.EventType) {
            Log.d(TAG, "Event: $event")
        }

        override fun onLoad() {
            Log.d(TAG, "Bridge Loaded")
        }

        override fun onSuccess(payload: TruvSuccessPayload) {
            Log.d(TAG, "Bridge Success")
            val token = payload.publicToken
            // Do something with your token
        }

    }

binding.bridgeView.addEventListener(truvEventsListener)

React Native

The React Native SDK for iOS and Android is available on npm.

Install

The two options below allow you to install the Truv Bridge SDK for React Native.

  • npm
npm install @truv/react-native --save
  • yarn
yarn add -S @truv/react-native

Usage

Use the code below to get started with the React Native Truv Bridge SDK.

import React, { useState } from 'react';
import TruvBridge from '@truv/react-native';

const BridgeElement = () => {
  return (
    <TruvBridge
        bridgeToken={bridgeToken}
        onClose={() => {
            console.log('bridge closed');
        }}
        onError={() => {
            console.log('bridge error');
        }}
        onEvent={(event) => console.log('event from bridge: ', event)}
        onLoad={() => {
            console.log('bridge loaded');
        }}
        onSuccess={() => {
            console.log('bridge succeeded');
        }}
    />
  );
}

Flutter

The Flutter SDK for iOS and Android is available on pub.dev.

Install

The code below allows you to add truv_flutter as a dependency in your pubspec.yaml file.

dependencies:
  ...
  truv_flutter: <version>

Usage

View the code below to get started with the Flutter SDK.

class MainScreen extends StatelessWidget {
  final bridgeToken = 'yourbridgetoken';

  Widget build(BuildContext context) {
    return TruvBridge(
      bridgeToken: bridgeToken,
      onEvent: (String event) {

      },
    );
  }
}

Vanilla JS

The JavaScript SDK for browsers is available on npm.

Install

Use the following options to install the JavaScript SDK.

  • npm
npm install @truv/bridge --save
  • yarn
yarn add -S @truv/bridge

Usage

The code sample below covers getting started with the JavaScript SDK.

import TruvBridge from '@truv/bridge'

const bridge = TruvBridge.init({
  bridgeToken: '<previously generated bridge token>', // more info https://docs.truv.com/reference/bridge-tokens_create
  onSuccess: (publicToken, metaData) => {
    console.log(publicToken, metaData);
  },
});

// when widget need to be opened
bridge.open();

React

The React SDK for web is available on npm.

Install

Use the following options to install the React SDK.

  • npm
npm install @truv/react --save
  • yarn
yarn add -S @truv/react

Usage

This example code lets you get started with the React SDK.

import React, { useState } from 'react';
import TruvBridge from '@truv/react';

const BridgeElement = () => {
  const [isOpened, setOpened] = useState(false);
  const [isSuccess, setIsSuccess] = useState(false);

  return (
    <>
      <button onClick={() => setOpened(true)}>Open</button>
      <TruvBridge
        bridgeToken="<previously generated bridge token>" // more info https://docs.truv.com/reference/bridge-tokens_create
        onClose={() => setOpened(false)}
        onSuccess={(publicToken, metaData) => {
          setIsSuccess(true);
          console.log(publicToken, metaData);
        }}
        isOpened={isOpened}
      />
    </>
  );
}

Next steps

Work directly with Truv Bridge response data from the Data Reference for Truv Bridge page. Navigate next steps for users with information from callbacks, event data, and possible errors.


What’s Next

Learn more about creating excellent integrations for your users with Truv Bridge.