@moneylion/react-native-engine-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.5.1 • Public • Published

react-native-engine-sdk

React Native components for Engine by MoneyLion. This implements a turnkey flow for gathering user information and submitting them to the Engine service to find financial products.

Getting Started

Request an api token and api endpoint from Engine.

Run yarn add @moneylion/react-native-engine-sdk

import { EngineSdk } from "@moneylion/react-native-engine-sdk";

// In your app
<EngineSdk
	bearer={authentication_token}
	endpoint={api_endpoint}
	prefilledData={prefilledData}
	primaryColor="#FF0000"
	secondaryColor="#00FF00"
	onExit={() => { /* handle user intention to exit */ }}
	onInitialize={() => { /* handle initialize callback */ }}
	onCreate={() => { /* handle lead creation callback */ }}
	onUpdate={() => { /* handle lead update callback */ }}
	onNavigate={() => { /* handle flow navigation callback */ }}
	onSubmit={() => { /* handle lead submission callback */ }}
/>

Props

  • bearer - the authentication token
  • endpoint - the Engine API endpoint
  • prefilledData - Any data you already have collected and don't want the flow to ask for again
  • primaryColor - An alternative primary color for branding purposes
  • secondaryColor - An alternative accent color for branding purposes
  • onExit - A callback invoked when the user tries to exit the flow
  • onInitialize - A callback invoked when the SDK has finished initializing
  • onCreate - A callback invoked when a lead is first created
  • onUpdate - A callback invoked when a lead is updated
  • onNavigate - A callback invoked when the user navigates to a new screen in the flow
  • onSubmit - A callback invoked when the user submits their data to receive a rate table

Development workflow

This project is managed using Yarn workspaces. It contains the following packages:

  • The library package in this directory.
  • An example app in the example/ directory.

To get started with the project, run yarn in this directory to install the required dependencies for each package:

yarn

Since the project relies on Yarn workspaces, you cannot use npm for development.

The example app demonstrates usage of the library. You need to run it to test any changes you make.

It is configured to use the local version of the library, so any changes you make to the library's source code will be reflected in the example app. Changes to the library's JavaScript code will be reflected in the example app without a rebuild, but native code changes will require a rebuild of the example app.

You can use various commands from this directory to work with the project.

To start the packager:

yarn example start

To run the example app on Android:

yarn example android

To run the example app on iOS:

yarn example ios

To run the example app on Web:

yarn example web

Make sure your code passes TypeScript and ESLint. Run the following to verify:

yarn typecheck
yarn lint

To fix formatting errors, run the following:

yarn lint:fix

Remember to add tests for your change if possible. Run the unit tests by:

yarn test

Scripts

The package.json file contains various scripts for common tasks:

  • yarn: setup project by installing dependencies.
  • yarn typecheck: type-check files with TypeScript.
  • yarn lint: lint files with ESLint.
  • yarn test: run unit tests with Jest.
  • yarn example start: start the Metro server for the example app.
  • yarn example android: run the example app on Android.
  • yarn example ios: run the example app on iOS.

Made with create-react-native-library

Troubleshooting

If you're testing the release build on Android and you find you are getting an error like this:

Error: adb: failed to install /home/dwt/moneylion/engine/ui-library-react-native/example/android/app/build/outputs/apk/debug/app-debug.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Existing package com.engine.sdk.example signatures do not match newer version; ignoring!]

Run the following command to remove the release build from your emulator or device:

adb uninstall 'com.engine.sdk.example'

"Unable to boot simulator"

Sometimes you might encounter a problem where the iOS simulator refuses to start. This can present with an error message like Failed to start launchd_sim: could not bind to session, launchd_sim may have crashed or quit responding.

You might be able to fix it by clearing the simulator caches. Navigate to ~/Library/Developer/CoreSimulator/Caches and remove the files in there.

Readme

Keywords

none

Package Sidebar

Install

npm i @moneylion/react-native-engine-sdk

Weekly Downloads

60

Version

0.5.1

License

ISC

Unpacked Size

4.99 MB

Total Files

507

Last publish

Collaborators

  • danielwilsonthomas-mj
  • loriing
  • randazzojoeml
  • jeromedanemoneylion
  • aceba1
  • zhuoyang-ml
  • ajohnson14
  • moneylion-x-infrastructure