1.3.8 ā€¢ Published 3 months ago

@front-finance/frontfinance-rn-sdk v1.3.8

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

Front Finance React Native SDK

šŸ“Œ Deprecation Notice

As of Dec 7, 2023 this package is no longer maintained and has been superseded by a new version. For the latest features, improvements, and bug fixes, please use our updated package: mesh-react-native-sdk.

We encourage all users to migrate to the new package for continued support and updates.

Install

With npm:

npm install --save @front-finance/frontfinance-rn-sdk

With yarn:

yarn add @front-finance/frontfinance-rn-sdk

šŸ’” This package requires react-native-webview to be installed in your project. Although it is listed as direct dependency, some times it is not installed automatically (This is a known npm issue). You should install it manually via following command in this case:

npm install --save react-native-webview@11.26.0

# or with yarn
yarn add react-native-webview@11.26.0

Connect through linkToken

The connection link token should be obtained from the Get link token endpoint. Request must be performed from the server side because it requires the client secret. You will get the response in the following format: You should use content --> linkToken from this response to run the FrontFinance component.

here is an example http request using request API in JS:

const options = {
  method: 'POST',
  headers: {
    accept: 'application/json',
    'content-type': 'application/*+json',
    'X-Client-Secret': 'XXXX', // replace with your client secret
    'X-Client-Id': 'XXXX' // replace with your client id
  },
  body: '{"userId":"XXXX"}' // replace with your user id (could be user email or phone number)
};

const getLinkToken = async () => {
  const response = await fetch('https://integration-api.getfront.com/api/v1/linktoken', options);
  const json = await response.json();
  return json?.content?.linkToken;
};

You will get a response in the following structure:

{
  "content": {
    "linkToken": "REQUESTED_LINK_TOKEN"
  },
  "status": "ok",
  "message": "",
  "errorType": ""
}

Using the FrontFinance component

import React from 'react';
import {
  FrontFinance,
  FrontPayload,
  TransferFinishedPayload,
  TransferFinishedSuccessPayload,
  TransferFinishedErrorPayload
} from '@front-finance/frontfinance-rn-sdk';

export const App = () => {
  return (
    <FrontFinance
      linkToken={"YOUR_LINKTOKEN"}
      onBrokerConnected={(payload: FrontPayload) => {
        // use broker account data
      }}
      onTransferFinished={(payload: TransferFinishedPayload) => {
        if (payload.status === 'success') {
          const successPayload = payload as TransferFinishedSuccessPayload
          // use transfer finished data
        } else {
          const errorPayload = payload as TransferFinishedErrorPayload
          // handle transfer error
        }
      }}
      onClose={() => {
        // use close event
      }}
      onError={(err: string) => {
        // use error message
      }}
    />
  )
}

export default App;

ā„¹ļø See full source code examples at examples/.

FrontFinance component arguments

keytypeRequired/Optionaldescription
urlstring @deprecated (use linkToken instead)required (if linkToken is not provided)Connection catalog link
linkTokenstringrequiredlink token
onBrokerConnected(payload: FrontPayload) => voidoptionalCallback called when users connects their accounts
onTransferFinished(payload: TransferFinishedPayload) => voidoptionalCallback called when a crypto transfer is executed
onError(err: string) => void)optionalCalled if connection not happened. Returns an error message
onClose() => voidoptionalCalled at the end of the connection, or when user closed the connection page

Using tokens

You can use broker tokens to perform requests to get current balance, assets and execute transactions. Full API reference can be found here.

Typescript support

Typescript definitions for @front-finance/frontfinance-rn-sdk are built into the npm package.

1.3.8

3 months ago

1.3.7

5 months ago

1.2.0

10 months ago

1.1.0

10 months ago

1.3.6

7 months ago

1.0.9

10 months ago

1.3.5

7 months ago

1.0.8

10 months ago

1.3.4

7 months ago

1.0.7

10 months ago

1.3.3

8 months ago

1.3.2

8 months ago

1.3.1

8 months ago

1.2.2

9 months ago

1.3.0

8 months ago

1.2.1

10 months ago

1.3.0-beta

8 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago