Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Plaid Link Component #6362

Merged
merged 8 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ios/NewExpensify.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,8 @@
"${PODS_ROOT}/Target Support Files/Pods-NewExpensify/Pods-NewExpensify-frameworks.sh",
"${PODS_ROOT}/hermes-engine/destroot/Library/Frameworks/iphoneos/hermes.framework",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/Onfido/Onfido.framework/Onfido",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL/OpenSSL.framework/OpenSSL",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/LinkKit/LinkKit.framework/LinkKit",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal/OpenSSL.framework/OpenSSL",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/Plaid/LinkKit.framework/LinkKit",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
Expand Down Expand Up @@ -720,8 +720,8 @@
"${PODS_ROOT}/Target Support Files/Pods-NewExpensify-NewExpensifyTests/Pods-NewExpensify-NewExpensifyTests-frameworks.sh",
"${PODS_ROOT}/hermes-engine/destroot/Library/Frameworks/iphoneos/hermes.framework",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/Onfido/Onfido.framework/Onfido",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL/OpenSSL.framework/OpenSSL",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/LinkKit/LinkKit.framework/LinkKit",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal/OpenSSL.framework/OpenSSL",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/Plaid/LinkKit.framework/LinkKit",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
Expand Down
40 changes: 20 additions & 20 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ SPEC CHECKSUMS:
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
DoubleConversion: cf9b38bf0b2d048436d9a82ad2abe1404f11e7de
FBLazyVector: 7b423f9e248eae65987838148c36eec1dbfe0b53
FBReactNativeSpec: e6c5eb078317f6a15612c7e3b4d410c4d01bb703
FBReactNativeSpec: 1d564cbdef3e1546843d1f1ceb0e4463b7993e3a
Firebase: 54cdc8bc9c9b3de54f43dab86e62f5a76b47034f
FirebaseABTesting: c3e48ebf5e7e5c674c5a131c68e941d7921d83dc
FirebaseAnalytics: 4751d6a49598a2b58da678cc07df696bcd809ab9
Expand All @@ -840,7 +840,7 @@ SPEC CHECKSUMS:
Flipper-Folly: 755929a4f851b2fb2c347d533a23f191b008554c
Flipper-Glog: 1dfd6abf1e922806c52ceb8701a3599a79a200a6
Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9
flipper-plugin-react-native-performance: 82e0d9bf8f330d2e256ff018978e2a19b86fec17
flipper-plugin-react-native-performance: c639bbaf0e0444bab8eeb86dad93651c2e13291e
Flipper-RSocket: 127954abe8b162fcaf68d2134d34dc2bd7076154
FlipperKit: 8a20b5c5fcf9436cac58551dc049867247f64b00
glog: 73c2498ac6884b13ede40eda8228cb1eee9d9d62
Expand All @@ -853,9 +853,9 @@ SPEC CHECKSUMS:
Onfido: 116a268e4cb8b767c15285e8071c2e8304673cdf
onfido-react-native-sdk: b8f1b7cbe1adab6479d735275772390161630dcd
OpenSSL-Universal: 1aa4f6a6ee7256b83db99ec1ccdaa80d10f9af9b
Permission-LocationAccuracy: 76669f87b4c276f5ae803cc0ddd1862a4c0e9dd8
Permission-LocationAlways: a274bc04bb386068782468dbdaca3859f51634ca
Permission-LocationWhenInUse: 3a2b0dbc167d79e8e920a4377ff9520cdc108407
Permission-LocationAccuracy: e8adff9ede1b23b43b7054a4500113d515fc87a8
Permission-LocationAlways: 7f7f373d086af7a81b2f4f20d65d29266ca2043b
Permission-LocationWhenInUse: 3ae82a9feb5da4e94e386dba17c7dd3531af9feb
Plaid: 3485574bd01075562d969a2d9384cde1ed7d9252
PromisesObjC: 68159ce6952d93e17b2dfe273b8c40907db5ba58
Protobuf: 7327d4444215b5f18e560a97f879ff5503c4581c
Expand All @@ -871,16 +871,16 @@ SPEC CHECKSUMS:
React-jsiexecutor: 124e8f99992490d0d13e0649d950d3e1aae06fe9
React-jsinspector: 500a59626037be5b3b3d89c5151bc3baa9abf1a9
react-native-config: d8b45133fd13d4f23bd2064b72f6e2c08b2763ed
react-native-document-picker: f2f73db94328c84e22144e369fb4a3ede47bc1f5
react-native-document-picker: 0e3602a4064da040321bafad6848d8b0edcb1d55
react-native-flipper: 169e8ba429b73ad637ce007337ce4b415e783799
react-native-image-picker: 474cf2c33c2b6671da53d293a16c97995f0aec15
react-native-netinfo: 30fb89fa913c342be82a887b56e96be6d71201dd
react-native-image-picker: 4089335b89b625d4e34d53fb249c48a7a791b3ea
react-native-netinfo: 52cf0ee8342548a485e28f4b09e56b477567244d
react-native-pdf: 4b5a9e4465a6a3b399e91dc4838eb44ddf716d1f
react-native-performance: 6bd6cfac80594775fb782405fceaaf206becf53b
react-native-plaid-link-sdk: 0b2e16d091abfee30ba01cf37734182ad610f917
react-native-progress-bar-android: be43138ab7da30d51fc038bafa98e9ed594d0c40
react-native-progress-view: 21b1e29e70c7559c16c9e0a04c4adc19fce6ede2
react-native-safe-area-context: 79fea126c6830c85f65947c223a5e3058a666937
react-native-performance: 8edfa2bbc9a2af4a02f01d342118e413a95145e0
react-native-plaid-link-sdk: dcc247a441571b6e0b9029ab00a30f82e4cfa906
react-native-progress-bar-android: ce95a69f11ac580799021633071368d08aaf9ad8
react-native-progress-view: 5816e8a6be812c2b122c6225a2a3db82d9008640
react-native-safe-area-context: 01158a92c300895d79dee447e980672dc3fb85a6
React-perflogger: aad6d4b4a267936b3667260d1f649b6f6069a675
React-RCTActionSheet: fc376be462c9c8d6ad82c0905442fd77f82a9d2a
React-RCTAnimation: ba0a1c3a2738be224a08092fa7f1b444ab77d309
Expand All @@ -894,23 +894,23 @@ SPEC CHECKSUMS:
React-runtimeexecutor: ff951a0c241bfaefc4940a3f1f1a229e7cb32fa6
ReactCommon: bedc99ed4dae329c4fcf128d0c31b9115e5365ca
rn-fetch-blob: f065bb7ab7fb48dd002629f8bdcb0336602d3cba
RNBootSplash: 24175aa28fe203b10c48dc34e78d946fd33c77af
RNCAsyncStorage: 56a3355a10b5d660c48c6e37325ac85ebfd09885
RNCClipboard: 41d8d918092ae8e676f18adada19104fa3e68495
RNCMaskedView: fc29d354a40316a990e8fb46391f08aea829c3aa
RNBootSplash: 3123ba68fe44d8be09a014e89cc8f0f55b68a521
RNCAsyncStorage: 8324611026e8dc3706f829953aa6e3899f581589
RNCClipboard: 5e299c6df8e0c98f3d7416b86ae563d3a9f768a3
RNCMaskedView: 138134c4d8a9421b4f2bf39055a79aa05c2d47b1
RNCPicker: 6780c753e9e674065db90d9c965920516402579d
RNDateTimePicker: 7658208086d86d09e1627b5c34ba0cf237c60140
RNDateTimePicker: c9911be59b1f8670b9f244b85af3a7c295e175ed
RNFBAnalytics: 8ba84c2d31c64374d054c8621b998f25145ffddc
RNFBApp: 64c90ab78b6010ed5c3ade026dfe5ff6442c21fd
RNFBCrashlytics: 1de18b8cc36d9bcf86407c4a354399228cc84a61
RNFBPerf: e3a7269f573a4787810a32de51647cdcbe08dfb4
RNGestureHandler: 9b7e605a741412e20e13c512738a31bd1611759b
RNPermissions: 4c8a37b4dde50f1f152bf8cd08c4a43d2355829e
RNPermissions: eb94f9fdc0a8ecd02fcce0676d56ffb1395d41e1
RNReactNativeHapticFeedback: b83bfb4b537bdd78eb4f6ffe63c6884f7b049ead
RNReanimated: 833ebd229b31e18a8933ebd0cd744a0f47d88c42
RNScreens: e8e8dd0588b5da0ab57dcca76ab9b2d8987757e0
RNSVG: ce9d996113475209013317e48b05c21ee988d42e
urbanairship-react-native: ee53526e1f81c5170863dd3e039df7f98730ef53
urbanairship-react-native: 60b4b4235838ff109a2639b639e2ef01d54ad455
Yoga: a7de31c64fe738607e7a3803e3f591a4b1df7393
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

Expand Down
58 changes: 18 additions & 40 deletions src/components/PlaidLink/index.native.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,33 @@
import React from 'react';
import {NativeEventEmitter} from 'react-native';
import {openLink} from 'react-native-plaid-link-sdk';
import {useEffect} from 'react';
import {openLink, useDeepLinkRedirector, usePlaidEmitter} from 'react-native-plaid-link-sdk';
import Log from '../../libs/Log';
import CONST from '../../CONST';
import nativeModule from './nativeModule';
import {plaidLinkPropTypes, plaidLinkDefaultProps} from './plaidLinkPropTypes';

class PlaidLink extends React.Component {
constructor(props) {
super(props);
this.listener = undefined;
}

componentDidMount() {
const emitter = new NativeEventEmitter(nativeModule);
this.listener = emitter.addListener('onEvent', this.onEvent.bind(this));

const PlaidLink = (props) => {
useDeepLinkRedirector();
usePlaidEmitter((event) => {
Log.info('[PlaidLink] Handled Plaid Event: ', false, event);
if (event.eventName === CONST.PLAID.EVENT.ERROR) {
props.onError(event.metadata);
} else if (event.eventName === CONST.PLAID.EVENT.EXIT) {
props.onExit();
}
});
useEffect(() => {
openLink({
tokenConfig: {
token: this.props.token,
token: props.token,
},
onSuccess: ({publicToken, metadata}) => {
this.props.onSuccess({publicToken, metadata});
props.onSuccess({publicToken, metadata});
},
});
}

componentWillUnmount() {
if (!this.listener) {
return;
}

this.listener.remove();
}

/**
* @param {*} event
*/
onEvent(event) {
Log.info('[PlaidLink] Handled Plaid Event: ', false, event);
if (event.eventName === CONST.PLAID.EVENT.ERROR) {
this.props.onError(event.metadata);
} else if (event.eventName === CONST.PLAID.EVENT.EXIT) {
this.props.onExit();
}
}
}, []);

render() {
return null;
}
}
return null;
};

PlaidLink.propTypes = plaidLinkPropTypes;
PlaidLink.defaultProps = plaidLinkDefaultProps;
Expand Down