Giter Site home page Giter Site logo

shaharyarmaroof / react-native-plaid-link-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from plaid/react-native-plaid-link-sdk

0.0 0.0 0.0 116 KB

Plaid Link for React Native

License: MIT License

JavaScript 20.61% Kotlin 32.68% Java 3.29% Objective-C 40.55% Ruby 1.89% Makefile 0.97%

react-native-plaid-link-sdk's Introduction

Getting Started

In your react-native project directory:

npm install --save react-native-plaid-link-sdk

Updating from previous versions.

When upgrading from a previous major version of this library, see the notes here for additional instructions.

iOS

Add Plaid to your project’s Podfile as follows (likely located at ios/Podfile). The current minimum version supported is 1.1.27.

pod 'Plaid', '~> 1.1.27'

Then install your cocoapods dependencies:

cd ios && pod install && cd ..

Add a Run Script build phase (after the [CP] Embed Pods Frameworks step) to your target as described in Plaid Link for iOS documentation. This strips simulator symbols from App Store release builds.

That's it if using a recent react-native version with autolinking support.

Manual Integration

If using a version of react-native without autolinking support, then you will need to:

`react-native link react-native-plaid-link-sdk`

followed by

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-plaid-link-sdkios and add RNLinksdk.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNLinksdk.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

To register your app id:

  1. Log into your Plaid Dashboard at the API page
  2. Next to Allowed Android package names click "Configure" then "Add New Android Package Name" (for example com.plaid.example)
  3. Click "Save Changes", you may be prompted to re-enter your password

android/app/src/main/java/<AppName>/MainApplication.java

Add import com.plaid.PlaidPackage; on the imports section

Add packages.add(new PlaidPackage()); in List<ReactPackage> getPackages();

android/app/build.gradle

Add implementation project(':react-native-plaid-link-sdk') and implementation 'com.plaid.link:sdk-core:1.0.0' in the dependencies block

android/settings.gradle

Add:

include ':react-native-plaid-link-sdk'
project(':react-native-plaid-link-sdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-plaid-link-sdk/android')

PlaidLink

In your app:

import Text from 'react-native';
import PlaidLink from 'react-native-plaid-link-sdk';
 
const MyPlaidComponent = () => {
  return (
    <PlaidLink
     // Replace any of the following <#VARIABLE#>s according to your setup,
     // for details see https://plaid.com/docs/quickstart/#client-side-link-configuration
 
      publicKey='<# Your Public Key #>'
      clientName='<# Your Client Name #>'
      env='<# Environment #>'  // 'sandbox' or 'development' or 'production'
      product={['<# Product #>']}
      onSuccess={data => console.log('success: ', data)}
      onExit={data => console.log('exit: ', data)}
      onCancelled = {(result) => {console.log('Cancelled: ', result)}}
 
      // Optional props
      countryCodes={['<# Country Code #>']}
      language='<# Language #>'
      userEmailAddress='<# User Email #>'
      userLegalName='<# User Legal Name #>'
      userPhoneNumber='<# User Phone Number #>'
      webhook='<# Webhook URL #>'
    >
      <Text>Add Account</Text>
    </PlaidLink>
  );
};

To receive onEvent callbacks:

The React Native Plaid module emits onEvent events throughout the account linking process — see details here. To receive these events in your React Native app, wrap the PlaidLink react component with the following in order to listen for those events:

import React from 'react';
import { Text, NativeEventEmitter, NativeModules } from 'react-native';
 
class PlaidEventContainer extends React.Component {
 
  componentDidMount() {
    const emitter = new NativeEventEmitter(Platform.OS === 'ios' ? NativeModules.RNLinksdk : NativeModules.PlaidAndroid);
    this._listener = emitter.addListener('onEvent', (e) => console.log(e));
  }
 
  componentWillUnmount() {
    if (this._listener) {
      this._listener.remove();
    }
  }
 
  render() {
    return (
      <PlaidLink
        clientName='##YOUR CLIENT NAME##'
        publicKey='#YOUR PUBLIC KEY##'
        env='sandbox'
        onSuccess={data => console.log('success: ', data)}
        onExit={data => console.log('exit: ', data)}
        onCancelled = {(result) => {console.log('Cancelled: ', result)}}
        product={['transactions']}
        language='en'
        countryCodes={['US']}
      >
        <Text>Add Account</Text>
      </PlaidLink>
    );
  }
}

Customizing the PlaidLink component

By default, PlaidLink renders a TouchableOpacity component. You may override the component used by passing component and componentProps. For example:

      <PlaidLink
        clientName = "Component Test"
        publicKey = "##YOUR PUBLIC KEY##"
        products = {["transactions"]}
        env = "sandbox"
        component= {Button}
        componentProps = {{title: 'Add Account'}}
        onSuccess = {(result) => {console.log('Success: ', result)}}
        onError = {(result) => {console.log('Error: ', result)}}
        onCancelled = {(result) => {console.log('Cancelled: ', result)}}
        product = {["transactions"]}
        language = "en"
        countryCodes = {["US"]}
    >

react-native-plaid-link-sdk's People

Contributors

wkiefer avatar vafada avatar shaharyarmaroof avatar dustinhorton avatar caroaguilar avatar celwell avatar pbernasconi avatar shaharyarmaroof-em avatar zsweigart avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.