diff --git a/.npmignore b/.npmignore index 65a3f8e..6392b65 100644 --- a/.npmignore +++ b/.npmignore @@ -1,5 +1,6 @@ TestApp SampleApp +FabricSample .gitlab testutils diff --git a/FabricSample/.bundle/config b/FabricSample/.bundle/config new file mode 100644 index 0000000..848943b --- /dev/null +++ b/FabricSample/.bundle/config @@ -0,0 +1,2 @@ +BUNDLE_PATH: "vendor/bundle" +BUNDLE_FORCE_RUBY_PLATFORM: 1 diff --git a/FabricSample/.eslintrc.js b/FabricSample/.eslintrc.js new file mode 100644 index 0000000..187894b --- /dev/null +++ b/FabricSample/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + root: true, + extends: '@react-native', +}; diff --git a/FabricSample/.gitignore b/FabricSample/.gitignore new file mode 100644 index 0000000..08b135a --- /dev/null +++ b/FabricSample/.gitignore @@ -0,0 +1,76 @@ +# OSX +# +.DS_Store + +# Xcode +# +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate +**/.xcode.env.local + +# Android/IntelliJ +# +build/ +.idea +.gradle +local.properties +*.iml +*.hprof +.cxx/ +*.keystore +!debug.keystore + +# node.js +# +node_modules/ +npm-debug.log +yarn-error.log + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/ + +**/fastlane/report.xml +**/fastlane/Preview.html +**/fastlane/screenshots +**/fastlane/test_output + +# Bundle artifact +*.jsbundle + +# Ruby / CocoaPods +**/Pods/ +/vendor/bundle/ + +# Temporary files created by Metro to check the health of the file watcher +.metro-health-check* + +# testing +/coverage + +.yalc + +# Yarn +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/sdks +!.yarn/versions diff --git a/FabricSample/.prettierrc.js b/FabricSample/.prettierrc.js new file mode 100644 index 0000000..2b54074 --- /dev/null +++ b/FabricSample/.prettierrc.js @@ -0,0 +1,7 @@ +module.exports = { + arrowParens: 'avoid', + bracketSameLine: true, + bracketSpacing: false, + singleQuote: true, + trailingComma: 'all', +}; diff --git a/FabricSample/App.js b/FabricSample/App.js new file mode 100644 index 0000000..d98bc2a --- /dev/null +++ b/FabricSample/App.js @@ -0,0 +1,105 @@ +import React, {Component} from 'react'; +import {Button, StyleSheet, Text, View, Platform} from 'react-native'; +import {Onfido, OnfidoCaptureType} from '@onfido/react-native-sdk'; +import {Redirect} from 'react-router-native'; +import createSdkToken from './backend-server-example'; + +export default class App extends Component { + state = { + title: 'Welcome to Onfido React Native SDK!', + subtitle: "To get started, press 'Launch'", + status: 'Starting', + message: '--', + sdkToken: null, + sdkFlowComplete: false, + workflowRunId: null, + }; + + componentDidMount() { + // In your app, you will need to gather the user's information beforehand for the sdk to work. Only first and last name are required. + const propsMatch = this.props.match ? this.props.match : {params: {}}; + const {firstName, lastName} = propsMatch.params; + // Your application id may be different on iOS and Android so you'll need to check which platform the code is running on first. + const applicationId = + Platform.OS === 'ios' + ? 'org.reactjs.native.example.SampleApp' + : 'com.sampleapp'; + const applicant = { + first_name: !firstName || firstName.trim() === '' ? 'Jane' : firstName, + last_name: !lastName || lastName.trim() === '' ? 'Doe' : lastName, + }; + this.getSDKToken(applicant, applicationId); + } + + getSDKToken = async (applicant, applicationId) => { + const newState = await createSdkToken(applicant, applicationId); + this.setState(newState); + }; + + startSDK = () => { + Onfido.start({ + sdkToken: this.state.sdkToken, + workflowRunId: this.state.workflowRunId, + localisation: { + ios_strings_file_name: 'Localizable', + }, + flowSteps: { + welcome: true, + captureDocument: {}, + captureFace: { + type: OnfidoCaptureType.VIDEO, + }, + }, + }) + .then(response => { + this.setState({ + status: 'resolved', + message: JSON.stringify(response), + sdkFlowComplete: true, + }); + }) + .catch(error => { + this.setState({ + status: 'rejected', + message: error.code + ': ' + error.message, + sdkFlowComplete: true, + }); + }); + }; + + render() { + return ( + + + {this.state.title} + + + {this.state.subtitle} + +