Skip to main content

Auto Selfie

Changing the colors on Android

You must add a resource file on Android for AutoSelfie colors. You can find the keys in the example below.

To create this file, open the project on Android Studio right click on the res directory and create new Android Resource file. While creating select the "Resource Type" to values.

After that modify the file as shown below. note: pose estimation module has different set of keys that you can add. If you want to use pose estimation while using the auto selfie merge the files.

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="auto_selfie_text">#000000</color>
<color name="auto_selfie_counter_text">#000000</color>
<color name="auto_selfie_oval_view">#000000</color>
<color name="auto_selfie_success_anim">#000000</color>
</resources>

Auto selfie usage

Get the auto selfie module from the main AmaniSDK instance which you have previously initialized.

import {
AmaniSDK,
type AndroidAutoSelfieSettings,
type IOSAutoSelfieSettings,
} from "react-native-amani-sdk";

// Somewhere outside of your component
const androidSettings: AndroidAutoSelfieSettings = {
textSize: 16,
counterVisible: true,
counterTextSize: 21,
manualCaptureTimeout: 30,
distanceText: "Please align your face with the area",
faceNotFoundText: "No faces found",
restartText: "Process failed, restarting...",
stableText: "Please hold stable",
};

const iosSettings: IOSAutoSelfieSettings = {
faceIsOk: "Please hold stable",
notInArea: "Please align your face with the area",
faceTooSmall: "Your face is in too far",
faceTooBig: "Your face is in too close",
completed: "All OK!",
appBackgroundColor: "000000",
appFontColor: "ffffff",
primaryButtonBackgroundColor: "ffffff",
ovalBorderSuccessColor: "00ff00",
ovalBorderColor: "ffffff",
countTimer: "3",
manualCropTimeout: 30,
};

This is the method that you should give to your "start" button

const onStart = useCallback(() => {
AmaniSDK.sharedInstance.autoSelfie
.start(iosSettings, androidSettings)
.then((image) => setImageData(image));
}, []);

On the .then() part of the promise you can also trigger the upload process.

const onStart = useCallback(() => {
AmaniSDK.sharedInstance.autoSelfie
.start(iosSettings, androidSettings)
.then((image) => {
AmaniSDK.sharedInstance.autoSelfie.upload().then(uploadState => setUploadState(uploadState)})
});
}, []);