To make your development process easier we created SDKs for most popular platforms and frameworks:

Vanilla JS

JS SDK for browsers is available on npm: https://www.npmjs.com/package/@truv/bridge

Install

With npm:

npm install @truv/bridge --save

With yarn:

yarn add -S @truv/bridge

Usage

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

React SDK for web is available on npm: https://www.npmjs.com/package/@truv/react

Install

With npm:

npm install @truv/react --save

With yarn:

yarn add -S @truv/react

Usage

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

const BridgeElement = () => {
  const [isOpened, setOpened] = 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) => {
          setOpened(false);
          console.log(publicToken, metaData);
        }}
        isOpened={isOpened}
      />
    </>
  );
}

React Native

React Native SDK for iOS and Android is available on npm: https://www.npmjs.com/package/@truv/react-native

Install

With npm:

npm install @truv/react-native --save

With yarn:

yarn add -S @truv/react-native

Usage

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

Flutter SDK for iOS and Android is available on pub.dev: https://pub.dev/packages/truv_flutter

Install

Add truv_flutter as a dependency in your pubspec.yaml file:

dependencies:
  ...
  truv_flutter: <version>

Usage

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

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

      },
    );
  }
}

Did this page help you?