Azify SDK adapter to react native. π±
- Installation
- Usage
- API
- Types
- Components
- How to add images in Aziface SDK module?
- Limitations and Features
- Contributing
- License
npm install @azify/aziface-mobile
# or
yarn add @azify/aziface-mobile
Only iOS:
cd ios && pod install
import * as React from 'react';
import {
StyleSheet,
View,
Text,
TouchableOpacity,
ScrollView,
} from 'react-native';
import { enroll, initialize, photoMatch } from '@azify/aziface-mobile';
export default function App() {
const init = async () => {
/*
* The SDK must be initialized first
* so that the rest of the library
* functions can work!
*
* */
const headers = {
'x-token-bearer': 'YOUR_X_TOKEN_BEARER',
'x-api-key': 'YOUR_X_API_KEY',
'clientInfo': 'YUOR_CLIENT_INFO',
'contentType': 'YOUR_CONTENT_TYPE',
'device': 'YOUR_DEVICE',
'deviceid': 'YOUR_DEVICE_ID',
'deviceip': 'YOUR_DEVICE_IP',
'locale': 'YOUR_LOCALE',
'xForwardedFor': 'YOUR_X_FORWARDED_FOR',
'user-agent': 'YOUR_USER_AGENT',
'x-only-raw-analysis': '1',
};
const params = {
isDeveloperMode: false,
device: 'YOUR_DEVICE',
url: 'YOUR_BASE_URL',
key: 'YOUR_KEY',
productionKey: 'YOUR_PRODUCTION_KEY',
};
try {
const isInitialized = await initialize({
params,
headers,
});
console.log(isInitialized);
} catch (error: any) {
console.error(error.message);
}
};
const onPressPhotoMatch = async () => {
try {
const isSuccess = await photoMatch();
console.log(isSuccess);
} catch (error: any) {
console.error(error.message);
}
};
const onPressEnroll = async () => {
try {
const isSuccess = await enroll();
console.log(isSuccess);
} catch (error: any) {
console.error(error.message);
}
};
return (
<ScrollView style={styles.container}>
<View style={styles.content}>
<TouchableOpacity
style={styles.button}
onPress={async () => await init()}
>
<Text style={styles.text}>Init Aziface Module</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.button} onPress={onPressPhotoMatch}>
<Text style={styles.text}>Open Photo Match</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.button} onPress={onPressEnroll}>
<Text style={styles.text}>Open Enroll</Text>
</TouchableOpacity>
</View>
</ScrollView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
padding: 20,
},
content: {
justifyContent: 'center',
alignItems: 'center',
marginVertical: 30,
},
button: {
width: '100%',
backgroundColor: '#4a68b3',
padding: 20,
borderRadius: 15,
alignItems: 'center',
justifyContent: 'center',
marginVertical: 20,
},
text: {
color: 'white',
fontWeight: '700',
fontSize: 22,
},
});
Methods | Return Type | Platform |
---|---|---|
initialize |
Promise<boolean> |
All |
enroll |
Promise<boolean> |
All |
authenticate |
Promise<boolean> |
Unavailable |
liveness |
Promise<boolean> |
Unavailable |
photoMatch |
Promise<boolean> |
All |
photoScan |
Promise<boolean> |
Unavailable |
setTheme |
void |
All |
This is the principal method to be called, he must be called first to initialize the Aziface SDK. If he doens't be called the other methods don't works!
Initialize |
type | Required | Default |
---|---|---|---|
params |
Params |
β | - |
headers |
Headers |
β | undefined |
This method makes a 3D reading of the user's face. But, you must use to subscribe user in Aziface SDK or in your server.
SessionParams<"base"> |
type | Required | Default |
---|---|---|---|
data |
SessionBasePathUrl |
β | undefined |
This method make to read from face and documents for user, after compare face and face documents from user to check veracity.
SessionParams<"match"> |
type | Required | Default |
---|---|---|---|
data |
SessionMatchPathUrl |
β | undefined |
This method must be used to set the theme of the Aziface SDK screen.
Property | type | Required | Default |
---|---|---|---|
options |
Theme |
β | undefined |
Enums | iOS | Android |
---|---|---|
Errors |
β | β |
Types | Platform |
---|---|
Params |
All |
Headers |
All |
SessionParams |
All |
SessionBasePathUrl |
All |
SessionMatchPathUrl |
All |
Theme |
All |
ButtonLocation |
All |
StatusBarColor |
iOS |
ThemeImage |
All |
ThemeFrame |
All |
ThemeButton |
All |
ThemeGuidance |
All |
ThemeGuidanceRetryScreen |
All |
ThemeOval |
All |
ThemeFeedback |
All |
FeedbackBackgroundColor |
iOS |
Point |
iOS |
ThemeResultScreen |
All |
ThemeResultAnimation |
All |
ThemeIdScan |
All |
ThemeIdScanSelectionScreen |
All |
ThemeIdScanReviewScreen |
All |
ThemeIdScanCaptureScreen |
All |
DefaultMessage |
All |
DefaultScanMessage |
All |
DefaultScanMessageFrontSide |
All |
DefaultScanMessageBackSide |
All |
DefaultScanMessageUserConfirmInfo |
All |
DefaultScanMessageNFC |
All |
DefaultScanMessageSkippedNFC |
All |
DefaultScanMessageSuccess |
All |
DefaultScanMessageRetry |
All |
Here must be passed to initialize the Aziface SDK! Case the parameters isn't provided the Aziface SDK goes to be not initialized.
Params |
type | Required |
---|---|---|
device |
string |
β |
url |
string |
β |
key |
string |
β |
productionKey |
string |
β |
isDeveloperMode |
boolean |
β |
Here you can add your headers to send request when some method is called. Only values from type string, null or undefined are accepts!
Headers |
type | Required | Default |
---|---|---|---|
[key: string] |
string , null or undefined |
β | undefined |
This type is related to the data that will be sent by the SDK methods. It accepts any key, but has a property called pathUrl
. The pathUrl
is an object of URLs that will be passed in requests instead of the SDK's default URLs.
SessionParams<T> |
type | Required | Default |
---|---|---|---|
pathUrl |
SessionBasePathUrl or SessionMatchPathUrl |
β | undefined |
[key: string] |
any |
β | undefined |
This type is only for SDK methods that perform a single request. It contains the base
property, where you can specify the URL you want the request to be made natively. If not specified, the default URL will be used for the request.
If the URL is different from the default and requires passing the processId
parameter, you can enter the URL in this style /my-url/:my-id/my-final-url
. Internally, our native module will identify the slug /:my-id
and replace it with the processId
in the parameters.
SessionBasePathUrl |
type | Required | Default |
---|---|---|---|
base |
string |
β | undefined |
This type is only for SDK methods that perform a single request. It contains the base
and match
properties, where you can specify the URL you want the request to be made natively. If not specified, the default URL will be used for the request.
If the URL is different from the default and requires passing the processId
parameter, you can enter the URL in this style /my-url/:my-id/my-final-url
. Internally, our native module will identify the slug /:my-id
and replace it with the processId
in the parameters.
This type is specify of the photoMatch
method.
SessionMatchPathUrl |
type | Required | Default |
---|---|---|---|
base |
string |
β | undefined |
match |
string |
β | undefined |
This is a list of theme properties that can be used to styling. Note, we recommend that you use only hexadecimal values to colors, between six and eight characters, because still we don't supported others color type.
Theme |
type | Platform | Required | Default |
---|---|---|---|---|
overlayBackgroundColor |
string |
All | β | #ffffff |
cancelButtonLocation |
ButtonLocation |
All | β | TOP_RIGHT |
statusBarColor |
StatusBarColor |
iOS | β | DARK_CONTENT |
authenticateMessage |
DefaultMessage |
All | β | undefined |
enrollMessage |
DefaultMessage |
All | β | undefined |
livenessMessage |
DefaultMessage |
All | β | undefined |
scanMessage |
DefaultScanMessage |
All | β | undefined |
matchMessage |
DefaultScanMessage & DefaultMessage |
All | β | undefined |
image |
ThemeImage |
All | β | undefined |
frame |
ThemeFrame |
All | β | undefined |
guidance |
ThemeGuidance |
All | β | undefined |
oval |
ThemeOval |
All | β | undefined |
feedback |
ThemeFeedback |
All | β | undefined |
resultScreen |
ThemeResultScreen |
All | β | undefined |
idScan |
ThemeIdScan |
All | β | undefined |
This type must be used to position of the cancel button on screen.
ButtonLocation |
Description |
---|---|
DISABLED |
Disable cancel button and doesn't show it. |
TOP_LEFT |
Position cancel button in top right. |
TOP_RIGHT |
Position cancel button in top right. It's default position. |
This type must be used to status bar color.
StatusBarColor |
Description |
---|---|
DARK_CONTENT |
Default color to status bar. |
DEFAULT |
Status bar color that's set from the device. |
LIGHT_CONTENT |
Light color to status bar. |
An object containing the image assets used in the Aziface SDK.
ThemeImage |
type | Platform | Required | Default |
---|---|---|---|---|
logo |
string |
All | β | facetec_your_app_logo.png |
cancel |
string |
All | β | facetec_cancel.png |
An object containing the frame styles used in the Aziface SDK.
ThemeFrame |
type | Platform | Required | Default |
---|---|---|---|---|
cornerRadius |
number |
All | β | 20 |
borderColor |
string |
All | β | #ffffff |
backgroundColor |
string |
All | β | #ffffff |
An object containing the button styles used in the Aziface SDK.
ThemeButton |
type | Platform | Required | Default |
---|---|---|---|---|
backgroundNormalColor |
string |
All | β | #026ff4 |
backgroundDisabledColor |
string |
All | β | #b3d4fc |
backgroundHighlightColor |
string |
All | β | #0264dc |
textNormalColor |
string |
All | β | #ffffff |
textDisabledColor |
string |
All | β | #ffffff |
textHighlightColor |
string |
All | β | #ffffff |
An object containing the styles used in the guidance view.
ThemeGuidance |
type | Platform | Required | Default |
---|---|---|---|---|
backgroundColor |
string or string[] |
All | β | #ffffff (Android) and ['#ffffff', '#ffffff'] (iOS) |
foregroundColor |
string |
All | β | #272937 |
button |
ThemeButton |
All | β | undefined |
retryScreen |
ThemeGuidanceRetryScreen |
All | β | undefined |
An object containing the styles used in the guidance retry screen.
ThemeGuidanceRetryScreen |
type | Platform | Required | Default |
---|---|---|---|---|
imageBorderColor |
string |
All | β | #ffffff |
ovalStrokeColor |
string |
All | β | #ffffff |
An object containing the oval styles used in the Aziface SDK.
ThemeOval |
type | Platform | Required | Default |
---|---|---|---|---|
strokeColor |
string |
All | β | #026ff4 |
firstProgressColor |
string |
All | β | #0264dc |
secondProgressColor |
string |
All | β | #0264dc |
An object containing the oval styles used in the Aziface SDK.
ThemeFeedback |
type | Platform | Required | Default |
---|---|---|---|---|
backgroundColor |
string |
Android | β | #026ff4 |
backgroundColors |
string |
iOS | β | undefined |
textColor |
string |
All | β | #ffffff |
This type must be used to set the theme of the feedback box.
FeedbackBackgroundColor |
Description | type | Required | Default |
---|---|---|---|---|
colors |
An array of colors defining the color of each gradient stop. | string[] |
β | ["#026FF4", "#026FF4"] |
locations |
It's accepts only two values between 0 and 1 that defining the location of each gradient stop. |
[number, number] |
β | [0, 1] |
startPoint |
The start point of the gradient when drawn in the layerβs coordinate space. | Point |
β | { x: 0, y: 0 } |
endPoint |
The end point of the gradient when drawn in the layerβs coordinate space. | Point |
β | { x: 1, y: 0 } |
This interface defines the drawn in the layer's coordinate space.
Point |
type | Required | Default |
---|---|---|---|
x |
number |
β | 0 |
y |
number |
β | 0 |
An object containing the styles used in the result screen.
ThemeResultScreen |
type | Platform | Required | Default |
---|---|---|---|---|
backgroundColor |
string or string[] |
All | β | #ffffff (Android) and ['#ffffff', '#ffffff'] (iOS) |
foregroundColor |
string |
All | β | #272937 |
activityIndicatorColor |
string |
All | β | #026ff4 |
uploadProgressFillColor |
string |
All | β | #026ff4 |
resultAnimation |
ThemeResultAnimation |
All | β | undefined |
An object containing the animation styles used in the Aziface SDK result animation.
ThemeResultAnimation |
type | Platform | Required | Default |
---|---|---|---|---|
backgroundColor |
string |
All | β | #026ff4 |
foregroundColor |
string |
All | β | #ffffff |
An object containing the styles used in the ID scan screens.
ThemeIdScan |
type | Platform | Required | Default |
---|---|---|---|---|
selectionScreen |
ThemeIdScanSelectionScreen |
All | β | undefined |
reviewScreen |
ThemeIdScanReviewScreen |
All | β | undefined |
captureScreen |
ThemeIdScanCaptureScreen |
All | β | undefined |
button |
ThemeButton |
All | β | undefined |
An object containing the styles used in the ID scan selection screen.
ThemeIdScanSelectionScreen |
type | Platform | Required | Default |
---|---|---|---|---|
backgroundColor |
string or string[] |
All | β | #ffffff (Android) and ['#ffffff', '#ffffff'] (iOS) |
foregroundColor |
string |
All | β | #272937 |
An object containing the styles used in the ID scan review screen.
ThemeIdScanReviewScreen |
type | Platform | Required | Default |
---|---|---|---|---|
foregroundColor |
string |
All | β | #ffffff |
textBackgroundColor |
string |
All | β | #026ff4 |
An object containing the styles used in the ID scan capture screen.
ThemeIdScanCaptureScreen |
type | Platform | Required | Default |
---|---|---|---|---|
foregroundColor |
string |
All | β | #ffffff |
textBackgroundColor |
string |
All | β | #ffffff |
backgroundColor |
string |
All | β | #026ff4 |
frameStrokeColor |
string |
All | β | #ffffff |
This interface represents the success message and loading data message during to Aziface SDK flow. It interface is used by processors's enroll processor.
DefaultMessage |
type | Platform | Required | Default |
---|---|---|---|---|
successMessage |
string |
All | β | Face Scanned\n3D Liveness Proven |
uploadMessage |
string |
iOS | β | Still Uploading... |
This interface represents the all scan messages during to Aziface SDK flow. It interface is used by photoMatch processors.
DefaultScanMessage |
type | Platform | Required | Default |
---|---|---|---|---|
skipOrErrorNFC |
string |
All | β | ID Details Uploaded |
frontSide |
DefaultScanMessageFrontSide |
All | β | undefined |
backSide |
DefaultScanMessageBackSide |
All | β | undefined |
userConfirmedInfo |
DefaultScanMessageUserConfirmInfo |
All | β | undefined |
nfc |
DefaultScanMessageNFC |
All | β | undefined |
skippedNFC |
DefaultScanMessageSkippedNFC |
All | β | undefined |
success |
DefaultScanMessageSuccess |
All | β | undefined |
retry |
DefaultScanMessageRetry |
All | β | undefined |
Represents the front-side scan messages during to Aziface SDK flow.
DefaultScanMessageFrontSide |
type | Platform | Required | Default |
---|---|---|---|---|
uploadStarted |
string |
All | β | Uploading Encrypted ID Scan |
stillUploading |
string |
All | β | Still Uploading... Slow Connection |
uploadCompleteAwaitingResponse |
string |
All | β | Upload Complete |
uploadCompleteAwaitingProcessing |
string |
All | β | Processing ID Scan |
Represents the back-side scan messages during to Aziface SDK flow.
DefaultScanMessageBackSide |
type | Platform | Required | Default |
---|---|---|---|---|
uploadStarted |
string |
All | β | Uploading Encrypted Back of ID |
stillUploading |
string |
All | β | Still Uploading... Slow Connection |
uploadCompleteAwaitingResponse |
string |
All | β | Upload Complete |
uploadCompleteAwaitingProcessing |
string |
All | β | Processing Back of ID |
Represents the user confirmed information messages during to Aziface SDK flow.
DefaultScanMessageUserConfirmInfo |
type | Platform | Required | Default |
---|---|---|---|---|
uploadStarted |
string |
All | β | Uploading Your Confirmed Info |
stillUploading |
string |
All | β | Still Uploading... Slow Connection |
uploadCompleteAwaitingResponse |
string |
All | β | Upload Complete |
uploadCompleteAwaitingProcessing |
string |
All | β | Processing |
Represents the NFC scan messages during to Aziface SDK flow.
DefaultScanMessageNFC |
type | Platform | Required | Default |
---|---|---|---|---|
uploadStarted |
string |
All | β | Uploading Encrypted NFC Details |
stillUploading |
string |
All | β | Still Uploading... Slow Connection |
uploadCompleteAwaitingResponse |
string |
All | β | Upload Complete |
uploadCompleteAwaitingProcessing |
string |
All | β | Processing NFC Details |
Represents the skipped NFC scan messages during to Aziface SDK flow.
DefaultScanMessageSkippedNFC |
type | Platform | Required | Default |
---|---|---|---|---|
uploadStarted |
string |
All | β | Uploading Encrypted ID Details |
stillUploading |
string |
All | β | Still Uploading... Slow Connection |
uploadCompleteAwaitingResponse |
string |
All | β | Upload Complete |
uploadCompleteAwaitingProcessing |
string |
All | β | Processing ID Details |
Represents the success messages during to Aziface SDK flow.
DefaultScanMessageSuccess |
type | Platform | Required | Default |
---|---|---|---|---|
frontSide |
string |
All | β | ID Scan Complete |
frontSideBackNext |
string |
All | β | Front of ID Scanned |
frontSideNFCNext |
string |
All | β | Front of ID Scanned |
backSide |
string |
All | β | ID Scan Complete |
backSideNFCNext |
string |
All | β | Back of ID Scanned |
passport |
string |
All | β | Passport Scan Complete |
passportNFCNext |
string |
All | β | Passport Scanned |
userConfirmation |
string |
All | β | Photo ID Scan Complete |
NFC |
string |
All | β | ID Scan Complete |
Represents the retry messages during to Aziface SDK flow.
DefaultScanMessageSkippedNFC |
type | Platform | Required | Default |
---|---|---|---|---|
faceDidNotMatch |
string |
All | β | Face Didnβt Match Highly Enough |
IDNotFullyVisible |
string |
All | β | ID Document Not Fully Visible |
OCRResultsNotGoodEnough |
string |
All | β | ID Text Not Legible |
IDTypeNotSupported |
string |
All | β | ID Type Mismatch Please Try Again |
Errors |
Description | Platform |
---|---|---|
ConfigNotProvided |
When device , url , key and productionKey aren't provided. |
All |
HTTPSError |
When exists some network error. | All |
InitializationFailed |
When parameters provided by initialize are inconsistent or invalid. | All |
JSONError |
When exists some problem in getting data in request of base URL information. |
All |
ParamsNotProvided |
When parameters aren't provided, this case, it is null . |
All |
NotInitialized |
When session status is different of success. | All |
ProcessorError |
When an unknown session error occurs. | Android |
SessionNotProcessedError |
When the image ID sent to the processors cannot be processed due to inconsistency. | All |
SessionScanStatusError |
When scan session status isn't success. It's recommend try again. | Android |
SessionStatusError |
When session status isn't of success. It's recommend try again. | Android |
The FaceView
extends all properties of the View
, but it has five new callbacks to listener Aziface SDK events.
Property | Description | Returns | Platform |
---|---|---|---|
onOpen |
Callback function called when the Aziface SDK is opened. | boolean |
All |
onClose |
Callback function called when the Aziface SDK is closed. | boolean |
All |
onCancel |
Callback function called when the Aziface SDK is cancelled. | boolean |
All |
onError |
Callback function called when an error occurs in the Aziface SDK. | boolean |
All |
onInitialize |
Callback function called when the Aziface SDK is initialized. | boolean |
All |
The logoImage
and cancelImage
properties represents your logo and icon of the button cancel. Does not possible to remove them from the module. Default are Azify images and .png
format. By default in Android
the logo image is shown, but on iOS
it isn't shown, It's necessary to add manually.
To add your images in Android
, you must go to your project's android/src/main/res/drawable
directory. If in your project drawable
folder doesn't exist, it create one. Inside the drawable
folder, you must put your images and done!
Important: The filename of the image can't have uppercase letters, Android doesn't accept these characters in the image name.
In iOS
, open your XCode and go to your project's ios/<YOUR_PROJECT_NAME>/Images.xcassets
directory. Open the Images.xcassets
folder and only put your images inside there.
Now, go back to where you want to apply the styles, import setTheme
method and add only the image name, no extension format, in image property (logo
or cancel
). Note: If the image is not founded the default image will be showed. Check the code example below:
import React, { useEffect } from 'react';
import { View, TouchableOpacity, Text } from 'react-native';
import { initialize, enroll, setTheme } from '@azify/aziface-mobile';
export default function App() {
useEffect(() => {
const params = {
isDeveloperMode: true,
device: 'YOUR_DEVICE',
url: 'YOUR_URL',
key: 'YOUR_PUBLIC_KEY',
productionKey: 'YOUR_PRODUCTION_KEY',
};
async function initialize() {
setTheme({
image: {
logo: 'brand_logo' // brand_logo.png
cancel: 'close' // close.png
}
});
await initialize({ params });
}
initialize();
}, []);
return (
<View
style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center',
paddingHorizontal: 20,
}}
>
<TouchableOpacity
style={{
width: '100%',
height: 64,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'black',
}}
onPress={async () => {
try {
const isSuccess = await enroll();
console.log(isSuccess);
} catch (error: any) {
console.error(error);
}
}}
>
<Text style={{ textAlign: 'center', fontSize: 24, color: 'white' }}>
Open!
</Text>
</TouchableOpacity>
</View>
);
}
See the native implementation to learn more about the limitations and features that will need improving in the @azify/aziface-mobile
.
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT License. π
Made with create-react-native-library. π