@moneylion/react-native-engine-sdk
v1.0.0
Published
React Native components for the Engine by MoneyLion Mobile SDK
Downloads
158
Maintainers
Keywords
Readme
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 tokenendpoint
- the Engine API endpointprefilledData
- Any data you already have collected and don't want the flow to ask for againprimaryColor
- An alternative primary color for branding purposessecondaryColor
- An alternative accent color for branding purposesonExit
- A callback invoked when the user tries to exit the flowonInitialize
- A callback invoked when the SDK has finished initializingonCreate
- A callback invoked when a lead is first createdonUpdate
- A callback invoked when a lead is updatedonNavigate
- A callback invoked when the user navigates to a new screen in the flowonSubmit
- 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
Publishing to NPM
Run the following steps to publish the SDK to NPM.
- Update the version number in
package.json
andsrc/engine_sdk.tsx
. Commit this change. yarn prepare
- This will build the SDK.npm publish --access=public
- This will publish the SDK to NPM.
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.