diff --git a/App.js b/App.js
deleted file mode 100644
index eb02481bdeb2cdfe13c0e02afdc624c61884763f..0000000000000000000000000000000000000000
--- a/App.js
+++ /dev/null
@@ -1,54 +0,0 @@
-import React, { Component } from 'react';
-import { View, Button, NativeModules, NativeEventEmitter } from 'react-native';
-
-const { MyIdModule } = NativeModules;
-
-const myidEvents = new NativeEventEmitter(MyIdModule);
-
-export default class App extends Component {
-
- constructor() {
- super();
-
- this.startSdk = this.startSdk.bind(this);
- }
-
- UNSAFE_componentWillMount() {
- myidEvents.addListener('onSuccess', result =>
- Alert.alert(
- 'onSuccess received',
- )
- );
- myidEvents.addListener('onError', result =>
- Alert.alert(
- 'onError received',
- )
- );
- myidEvents.addListener('onUserExited', result =>
- Alert.alert(
- 'onUserExited received',
- )
- );
- }
-
- render() {
- return (
-
-
-
- );
- }
-
- startSdk() {
- MyIdModule.startMyId();
- }
-}
\ No newline at end of file
diff --git a/App.tsx b/App.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..8a816868f29d7d677b35f04e0ea68a2e3bf7d866
--- /dev/null
+++ b/App.tsx
@@ -0,0 +1,103 @@
+import React, {useEffect, useState} from 'react';
+import {
+ View,
+ Button,
+ NativeModules,
+ NativeEventEmitter,
+ Image,
+ StyleSheet,
+} from 'react-native';
+
+const {MyIdModule} = NativeModules;
+
+type SuccessEvent = {
+ code: string;
+ comparison: number;
+ image: string;
+};
+
+type ErrorEvent = {
+ message: string;
+ code: number;
+};
+
+const clientId = 'emit_sdk-pEXr5TMHOHYL5QcP2JjObte94zS0vPpLnjbqTigm"';
+const clientHash = 'f79e7195-cf94-4bdd-9115-6c08033e191c';
+const clientHashId =
+ 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwgGX9AQqActMnsW5K++GXYYCynxB/RQVMRSBsYCjSEmIrKaV8InLDxoG+WE2AY7lGyoo9qkxzKg1Vk6tW8pBW5PpNSH6xN1P9ufEnHQWuXCpdT+UkAoVMGnoYQ6glp9mZVlPEottslt6THAGa9wf3fMku97UdsuSctOeGXDr3LnsCFB7ZmaracTQFQ41v6SMbGZX2NsIKVtlJMZqAle9sI3crk9RGRg7Os8f1NolNNFuWQEjx/DpaSjCHGMMscWkSX7GEqJiVSNybGquHe1vjtswoT3oO2Mr+uCfz6Owx/d0/0Q8YWxvhorxbGT0CEw1m0CU+JbWh2lrgf1jHvBULQIDAQAB';
+const passportData = 'passport-number';
+const dateOfBirth = '1990-01-01'; // Ensure the date format matches what your SDK expects
+const buildMode = 'PRODUCTION'; // or "DEBUG", depending on your environment
+
+const App = () => {
+ const [imageBase64, setImageBase64] = useState('');
+
+ useEffect(() => {
+ if (MyIdModule) {
+ const myidEvents = new NativeEventEmitter(MyIdModule);
+
+ const onSuccess = (event: SuccessEvent) => {
+ console.log('onSuccess received', event.code, event.comparison);
+ // Clipboard.setString(event.image);
+ setImageBase64(event.image);
+ };
+ const onError = (event: ErrorEvent) =>
+ console.log('onError received', event);
+ const onUserExited = (event: any) =>
+ console.log('onUserExited received', event);
+
+ myidEvents.addListener('onSuccess', onSuccess);
+ myidEvents.addListener('onError', onError);
+ myidEvents.addListener('onUserExited', onUserExited);
+
+ return () => {
+ myidEvents.removeAllListeners('onSuccess');
+ myidEvents.removeAllListeners('onError');
+ myidEvents.removeAllListeners('onUserExited');
+ };
+ }
+ }, []);
+
+ const startSdk = () => {
+ if (MyIdModule) {
+ console.log('Calling startMyId');
+ MyIdModule.startMyId(
+ clientId,
+ clientHash,
+ clientHashId,
+ passportData,
+ dateOfBirth,
+ buildMode,
+ );
+ console.log('Called startMyId');
+ } else {
+ console.log('Module is not available');
+ }
+ };
+
+ return (
+
+ {imageBase64 ? (
+
+ ) : null}
+
+
+ );
+};
+
+export default App;
+
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ justifyContent: 'center',
+ alignItems: 'center',
+ },
+ image: {
+ width: 200,
+ height: 200,
+ },
+});
diff --git a/Gemfile b/Gemfile
index 1142b1b209ae3aa6451c2bd1cc20961eb7b230e7..8d72c37a80c3562f77b703e9d2a202146fcc6cfd 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,6 +1,9 @@
source 'https://rubygems.org'
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
-ruby '>= 2.6.10'
+ruby ">= 2.6.10"
-gem 'cocoapods', '>= 1.11.3'
+# Cocoapods 1.15 introduced a bug which break the build. We will remove the upper
+# bound in the template on Cocoapods with next React Native release.
+gem 'cocoapods', '>= 1.13', '< 1.15'
+gem 'activesupport', '>= 6.1.7.5', '< 7.1.0'
diff --git a/Gemfile.lock b/Gemfile.lock
index 30973227406168c41ff5459cfa08e847a0afb747..1a28fbd62c7d9bbfa6a8a0ef7f2ba78286f4413a 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,26 +1,30 @@
GEM
remote: https://rubygems.org/
specs:
- CFPropertyList (3.0.6)
+ CFPropertyList (3.0.7)
+ base64
+ nkf
rexml
- activesupport (7.0.4.3)
+ activesupport (6.1.7.8)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
- addressable (2.8.3)
- public_suffix (>= 2.0.2, < 6.0)
+ zeitwerk (~> 2.3)
+ addressable (2.8.7)
+ public_suffix (>= 2.0.2, < 7.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
atomos (0.1.3)
+ base64 (0.2.0)
claide (1.1.0)
- cocoapods (1.12.0)
+ cocoapods (1.14.3)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
- cocoapods-core (= 1.12.0)
+ cocoapods-core (= 1.14.3)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
- cocoapods-downloader (>= 1.6.0, < 2.0)
+ cocoapods-downloader (>= 2.1, < 3.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.6.0, < 2.0)
@@ -32,8 +36,8 @@ GEM
molinillo (~> 0.8.0)
nap (~> 1.0)
ruby-macho (>= 2.3.0, < 3.0)
- xcodeproj (>= 1.21.0, < 2.0)
- cocoapods-core (1.12.0)
+ xcodeproj (>= 1.23.0, < 2.0)
+ cocoapods-core (1.14.3)
activesupport (>= 5.0, < 8)
addressable (~> 2.8)
algoliasearch (~> 1.0)
@@ -44,7 +48,7 @@ GEM
public_suffix (~> 4.0)
typhoeus (~> 1.0)
cocoapods-deintegrate (1.0.5)
- cocoapods-downloader (1.6.3)
+ cocoapods-downloader (2.1)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.1)
@@ -53,46 +57,51 @@ GEM
netrc (~> 0.11)
cocoapods-try (1.2.0)
colored2 (3.1.2)
- concurrent-ruby (1.2.2)
+ concurrent-ruby (1.3.3)
escape (0.0.4)
ethon (0.16.0)
ffi (>= 1.15.0)
- ffi (1.15.5)
+ ffi (1.17.0)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
httpclient (2.8.3)
- i18n (1.12.0)
+ i18n (1.14.5)
concurrent-ruby (~> 1.0)
- json (2.6.3)
- minitest (5.18.0)
+ json (2.7.2)
+ minitest (5.24.1)
molinillo (0.8.0)
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
+ nkf (0.2.0)
public_suffix (4.0.7)
- rexml (3.2.5)
+ rexml (3.2.9)
+ strscan
ruby-macho (2.5.1)
- typhoeus (1.4.0)
+ strscan (3.1.0)
+ typhoeus (1.4.1)
ethon (>= 0.9.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
- xcodeproj (1.22.0)
+ xcodeproj (1.24.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (~> 3.2.4)
+ zeitwerk (2.6.16)
PLATFORMS
ruby
DEPENDENCIES
- cocoapods (>= 1.11.3)
+ activesupport (>= 6.1.7.5, < 7.1.0)
+ cocoapods (>= 1.13, < 1.15)
RUBY VERSION
- ruby 3.1.3p185
+ ruby 2.6.10p210
BUNDLED WITH
- 2.3.26
+ 2.1.4
diff --git a/README.md b/README.md
index 236910d5e8be6b4bcce395b0328de2821e37f041..12470c30ecb5a2dba694ea638163fa6ec177646d 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,79 @@
-# MyID Sample React Native
+This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli).
-## [Android](https://gitlab.myid.uz/myid-public-code/myid-sample-android)
-## [iOS](https://gitlab.myid.uz/myid-public-code/myid-sample-ios)
+# Getting Started
+
+>**Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding.
+
+## Step 1: Start the Metro Server
+
+First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native.
+
+To start Metro, run the following command from the _root_ of your React Native project:
+
+```bash
+# using npm
+npm start
+
+# OR using Yarn
+yarn start
+```
+
+## Step 2: Start your Application
+
+Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app:
+
+### For Android
+
+```bash
+# using npm
+npm run android
+
+# OR using Yarn
+yarn android
+```
+
+### For iOS
+
+```bash
+# using npm
+npm run ios
+
+# OR using Yarn
+yarn ios
+```
+
+If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly.
+
+This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.
+
+## Step 3: Modifying your App
+
+Now that you have successfully run the app, let's modify it.
+
+1. Open `App.tsx` in your text editor of choice and edit some lines.
+2. For **Android**: Press the R key twice or select **"Reload"** from the **Developer Menu** (Ctrl + M (on Window and Linux) or Cmd ⌘ + M (on macOS)) to see your changes!
+
+ For **iOS**: Hit Cmd ⌘ + R in your iOS Simulator to reload the app and see your changes!
+
+## Congratulations! :tada:
+
+You've successfully run and modified your React Native App. :partying_face:
+
+### Now what?
+
+- If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps).
+- If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started).
+
+# Troubleshooting
+
+If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.
+
+# Learn More
+
+To learn more about React Native, take a look at the following resources:
+
+- [React Native Website](https://reactnative.dev) - learn more about React Native.
+- [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment.
+- [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**.
+- [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts.
+- [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native.
diff --git a/__tests__/App-test.tsx b/__tests__/App.test.tsx
similarity index 73%
rename from __tests__/App-test.tsx
rename to __tests__/App.test.tsx
index 178476699b605584dc503e85537c47dac8b7b611..9eac6fbc87d2c39a36284595e7934a225fe183a6 100644
--- a/__tests__/App-test.tsx
+++ b/__tests__/App.test.tsx
@@ -6,6 +6,9 @@ import 'react-native';
import React from 'react';
import App from '../App';
+// Note: import explicitly to use the types shipped with jest.
+import {it} from '@jest/globals';
+
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
diff --git a/android/app/build.gradle b/android/app/build.gradle
index 7e1fd01706b4833c34c1c98834f046ec2de0b1ce..db542f879ae98c4b6ad0d8f45dc13ffd80129908 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -1,8 +1,7 @@
apply plugin: "com.android.application"
+apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "com.facebook.react"
-import com.android.build.OutputFile
-
/**
* This is the configuration block to customize your React Native Android app.
* By default you don't need to apply any configuration, just uncomment the lines you need.
@@ -13,8 +12,8 @@ react {
// root = file("../")
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
// reactNativeDir = file("../node_modules/react-native")
- // The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
- // codegenDir = file("../node_modules/react-native-codegen")
+ // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
+ // codegenDir = file("../node_modules/@react-native/codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
// cliFile = file("../node_modules/react-native/cli.js")
@@ -52,14 +51,6 @@ react {
// hermesFlags = ["-O", "-output-source-map"]
}
-/**
- * Set this to true to create four separate APKs instead of one,
- * one for each native architecture. This is useful if you don't
- * use App Bundles (https://developer.android.com/guide/app-bundle/)
- * and want to have separate APKs to upload to the Play Store.
- */
-def enableSeparateBuildPerCPUArchitecture = false
-
/**
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
*/
@@ -78,38 +69,19 @@ def enableProguardInReleaseBuilds = false
*/
def jscFlavor = 'org.webkit:android-jsc:+'
-/**
- * Private function to get the list of Native Architectures you want to build.
- * This reads the value from reactNativeArchitectures in your gradle.properties
- * file and works together with the --active-arch-only flag of react-native run-android.
- */
-def reactNativeArchitectures() {
- def value = project.getProperties().get("reactNativeArchitectures")
- return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
-}
-
android {
ndkVersion rootProject.ext.ndkVersion
+ buildToolsVersion rootProject.ext.buildToolsVersion
+ compileSdk rootProject.ext.compileSdkVersion
- compileSdkVersion rootProject.ext.compileSdkVersion
-
- namespace "com.myidsample"
+ namespace "com.myid"
defaultConfig {
- applicationId "com.myidsample"
+ applicationId "com.myid"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
-
- splits {
- abi {
- reset()
- enable enableSeparateBuildPerCPUArchitecture
- universalApk false // If true, also generate a universal APK
- include (*reactNativeArchitectures())
- }
- }
signingConfigs {
debug {
storeFile file('debug.keystore')
@@ -130,60 +102,40 @@ android {
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
-
- // applicationVariants are e.g. debug, release
- applicationVariants.all { variant ->
- variant.outputs.each { output ->
- // For each separate APK per architecture, set a unique version code as described here:
- // https://developer.android.com/studio/build/configure-apk-splits.html
- // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
- def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
- def abi = output.getFilter(OutputFile.ABI)
- if (abi != null) { // null for the universal-debug, universal-release variants
- output.versionCodeOverride =
- defaultConfig.versionCode * 1000 + versionCodes.get(abi)
- }
-
- }
- }
}
dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
- implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
-
- debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
- debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
- exclude group:'com.squareup.okhttp3', module:'okhttp'
- }
-
- debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
implementation jscFlavor
}
- implementation(files("libs/myid-sdk-2.1.5-release.aar"))
- implementation("androidx.appcompat:appcompat:1.5.1")
+ //MyId
+ implementation(files('libs/myid-capture-sdk-2.3.0.aar'))
+// implementation("uz.myid.sdk.capture:myid-capture-sdk:2.3.0")
+
+ implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
- implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1")
- implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.5.1")
+ implementation("androidx.activity:activity-ktx:1.8.2")
+ implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1")
+ implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
- def cameraVersion = "1.2.2"
+ def cameraVersion = "1.3.2"
implementation("androidx.camera:camera-camera2:$cameraVersion")
implementation("androidx.camera:camera-lifecycle:$cameraVersion")
implementation("androidx.camera:camera-view:$cameraVersion")
+ implementation("androidx.camera:camera-mlkit-vision:1.4.0-alpha04")
implementation("com.google.android.gms:play-services-mlkit-face-detection:17.1.0")
- implementation("com.google.android.gms:play-services-mlkit-text-recognition:18.0.2")
- implementation("com.google.android.gms:play-services-mlkit-barcode-scanning:18.2.0")
+ implementation("com.google.android.gms:play-services-mlkit-text-recognition:19.0.0")
+ implementation("com.google.android.gms:play-services-mlkit-barcode-scanning:18.3.0")
+ implementation("com.google.android.recaptcha:recaptcha:18.4.0")
- implementation("io.ktor:ktor-client-android:2.1.2")
- implementation("io.sentry:sentry-android:6.16.0")
}
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
diff --git a/android/app/libs/myid-capture-sdk-2.3.0.aar b/android/app/libs/myid-capture-sdk-2.3.0.aar
new file mode 100644
index 0000000000000000000000000000000000000000..d53a9db8144c485622f46967827899bcbc39d7cf
Binary files /dev/null and b/android/app/libs/myid-capture-sdk-2.3.0.aar differ
diff --git a/android/app/libs/myid-sdk-2.1.5-release.aar b/android/app/libs/myid-sdk-2.1.5-release.aar
deleted file mode 100644
index 792c656f87c3ea6a724438716f702256b28feaea..0000000000000000000000000000000000000000
Binary files a/android/app/libs/myid-sdk-2.1.5-release.aar and /dev/null differ
diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml
index 4b185bc1597eb762051660198c02074bf82ab974..eb98c01afd79a6ca551b3b638dc4a048d1315fb4 100644
--- a/android/app/src/debug/AndroidManifest.xml
+++ b/android/app/src/debug/AndroidManifest.xml
@@ -2,12 +2,8 @@
-
-
-
-
+ tools:ignore="GoogleAppIndexingWarning"/>
diff --git a/android/app/src/debug/java/com/myidsample/ReactNativeFlipper.java b/android/app/src/debug/java/com/myidsample/ReactNativeFlipper.java
deleted file mode 100644
index d3ec65105404e681c6bc5bcf97e44af6eb06e991..0000000000000000000000000000000000000000
--- a/android/app/src/debug/java/com/myidsample/ReactNativeFlipper.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * Copyright (c) Meta Platforms, Inc. and affiliates.
- *
- *
This source code is licensed under the MIT license found in the LICENSE file in the root
- * directory of this source tree.
- */
-package com.myidsample;
-
-import android.content.Context;
-import com.facebook.flipper.android.AndroidFlipperClient;
-import com.facebook.flipper.android.utils.FlipperUtils;
-import com.facebook.flipper.core.FlipperClient;
-import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
-import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
-import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
-import com.facebook.flipper.plugins.inspector.DescriptorMapping;
-import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
-import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
-import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
-import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
-import com.facebook.react.ReactInstanceEventListener;
-import com.facebook.react.ReactInstanceManager;
-import com.facebook.react.bridge.ReactContext;
-import com.facebook.react.modules.network.NetworkingModule;
-import okhttp3.OkHttpClient;
-
-/**
- * Class responsible of loading Flipper inside your React Native application. This is the debug
- * flavor of it. Here you can add your own plugins and customize the Flipper setup.
- */
-public class ReactNativeFlipper {
- public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
- if (FlipperUtils.shouldEnableFlipper(context)) {
- final FlipperClient client = AndroidFlipperClient.getInstance(context);
-
- client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
- client.addPlugin(new DatabasesFlipperPlugin(context));
- client.addPlugin(new SharedPreferencesFlipperPlugin(context));
- client.addPlugin(CrashReporterPlugin.getInstance());
-
- NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
- NetworkingModule.setCustomClientBuilder(
- new NetworkingModule.CustomClientBuilder() {
- @Override
- public void apply(OkHttpClient.Builder builder) {
- builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
- }
- });
- client.addPlugin(networkFlipperPlugin);
- client.start();
-
- // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
- // Hence we run if after all native modules have been initialized
- ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
- if (reactContext == null) {
- reactInstanceManager.addReactInstanceEventListener(
- new ReactInstanceEventListener() {
- @Override
- public void onReactContextInitialized(ReactContext reactContext) {
- reactInstanceManager.removeReactInstanceEventListener(this);
- reactContext.runOnNativeModulesQueueThread(
- new Runnable() {
- @Override
- public void run() {
- client.addPlugin(new FrescoFlipperPlugin());
- }
- });
- }
- });
- } else {
- client.addPlugin(new FrescoFlipperPlugin());
- }
- }
- }
-}
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 48021118e66e433ad228d334914fb8a62086b7e8..abf02047f95d59da531ed75fcf784725a3a39bad 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -1,8 +1,10 @@
+
+
=
+ PackageList(this).packages.apply {
+ // Packages that cannot be autolinked yet can be added manually here, for example:
+ // add(MyReactNativePackage())
+ add(ReactPackage())
+ }
+
+ override fun getJSMainModuleName(): String = "index"
+
+ override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
+
+ override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
+ override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
+ }
+
+ override val reactHost: ReactHost
+ get() = getDefaultReactHost(applicationContext, reactNativeHost)
+
+ override fun onCreate() {
+ super.onCreate()
+ SoLoader.init(this, false)
+ if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
+ // If you opted-in for the New Architecture, we load the native entry point for this app.
+ load()
+ }
+ }
+}
diff --git a/android/app/src/main/java/com/myid/MyIdModule.kt b/android/app/src/main/java/com/myid/MyIdModule.kt
new file mode 100644
index 0000000000000000000000000000000000000000..76ce94698f24c204d67b06d63d14fad9a8bd88cb
--- /dev/null
+++ b/android/app/src/main/java/com/myid/MyIdModule.kt
@@ -0,0 +1,118 @@
+package com.myid
+
+import android.app.Activity
+import android.content.Intent
+import android.graphics.Bitmap
+import android.util.Base64
+import android.util.Log
+import com.facebook.react.bridge.*
+import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter
+import uz.myid.android.sdk.capture.MyIdClient
+import uz.myid.android.sdk.capture.MyIdConfig
+import uz.myid.android.sdk.capture.MyIdException
+import uz.myid.android.sdk.capture.MyIdResult
+import uz.myid.android.sdk.capture.MyIdResultListener
+import uz.myid.android.sdk.capture.model.MyIdBuildMode
+import uz.myid.android.sdk.capture.model.MyIdCameraShape
+import uz.myid.android.sdk.capture.model.MyIdEntryType
+import uz.myid.android.sdk.capture.model.MyIdGraphicFieldType
+import java.io.ByteArrayOutputStream
+import java.util.*
+
+class MyIdModule(private val reactContext: ReactApplicationContext) :
+ ReactContextBaseJavaModule(reactContext), MyIdResultListener, ActivityEventListener {
+
+ private val client = MyIdClient()
+
+ init {
+ reactContext.addActivityEventListener(this)
+ }
+
+ override fun getName(): String = "MyIdModule"
+
+ @ReactMethod
+ fun addListener(eventName: String?) {
+ // Method to add listeners (placeholder for actual implementation if needed)
+ }
+
+ @ReactMethod
+ fun removeListeners(count: Int?) {
+ // Method to remove listeners (placeholder for actual implementation if needed)
+ }
+
+ @ReactMethod
+ fun startMyId(clientId: String, clientHash: String, clientHashId: String, passportData: String, dateOfBirth: String, buildMode: String) {
+ Log.d("MyIdModule", "startMyId called with clientId: $clientId")
+ val mode = if (buildMode == "PRODUCTION") MyIdBuildMode.PRODUCTION else MyIdBuildMode.DEBUG
+ val config = MyIdConfig.Builder(clientId)
+ .withClientHash(clientHash, clientHashId)
+ .withPassportData(passportData)
+ .withBirthDate(dateOfBirth)
+ .withBuildMode(mode)
+ .withEntryType(MyIdEntryType.FACE)
+ .withLocale(Locale("en"))
+ .withCameraShape(MyIdCameraShape.CIRCLE)
+ .build()
+
+ reactContext.currentActivity?.let {
+ val intent = client.createIntent(it, config)
+ it.startActivityForResult(intent, MY_ID_REQUEST_CODE)
+ } ?: Log.e("MyIdModule", "Current activity is null.")
+ }
+
+ override fun onActivityResult(activity: Activity?, requestCode: Int, resultCode: Int, data: Intent?) {
+ if (requestCode == MY_ID_REQUEST_CODE) {
+ Log.d("onActivity",data.toString())
+ client.handleActivityResult(resultCode, this)
+ }
+ }
+
+ override fun onNewIntent(p0: Intent?) {
+ TODO("Not yet implemented")
+ }
+
+ override fun onSuccess(result: MyIdResult) {
+ Log.d("MyIdModule", "onSuccess called")
+ val bitmap = result.getGraphicFieldImageByType(MyIdGraphicFieldType.FACE_PORTRAIT)
+ val base64Image = bitmap?.let { encodeToBase64(it) }
+ Log.d("base64Image",base64Image!!)
+ val params = Arguments.createMap().apply {
+ putString("code", result.code)
+ putDouble("comparison", result.comparison.toDouble())
+ putString("image", base64Image)
+ }
+ sendEvent("onSuccess", params)
+ }
+
+ override fun onError(e: MyIdException) {
+ Log.d("MyIdModule", "onError called")
+ val params = Arguments.createMap().apply {
+ putString("message", e.message)
+ putInt("code", e.code)
+ }
+ sendEvent("onError", params)
+ }
+
+ override fun onUserExited() {
+ Log.d("MyIdModule", "onUserExited called")
+ val params = Arguments.createMap().apply {
+ putString("message", "User exited SDK")
+ }
+ sendEvent("onUserExited", params)
+ }
+
+ private fun sendEvent(eventName: String, params: WritableMap) {
+ Log.d("MyIdModule", "sending event $eventName")
+ reactContext.getJSModule(RCTDeviceEventEmitter::class.java).emit(eventName, params)
+ }
+
+ private fun encodeToBase64(bitmap: Bitmap): String {
+ val outputStream = ByteArrayOutputStream()
+ bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream)
+ return Base64.encodeToString(outputStream.toByteArray(), Base64.DEFAULT)
+ }
+
+ companion object {
+ private const val MY_ID_REQUEST_CODE = 1
+ }
+}
diff --git a/android/app/src/main/java/com/myid/ReactPackage.kt b/android/app/src/main/java/com/myid/ReactPackage.kt
new file mode 100644
index 0000000000000000000000000000000000000000..91c09fb09fda40540519a458a88d378afe10c54f
--- /dev/null
+++ b/android/app/src/main/java/com/myid/ReactPackage.kt
@@ -0,0 +1,19 @@
+package com.myid
+
+import android.view.View
+import com.facebook.react.ReactPackage
+import com.facebook.react.bridge.NativeModule
+import com.facebook.react.bridge.ReactApplicationContext
+import com.facebook.react.uimanager.ReactShadowNode
+import com.facebook.react.uimanager.ViewManager
+
+class ReactPackage : ReactPackage {
+
+ override fun createViewManagers(
+ reactContext: ReactApplicationContext
+ ): MutableList>> = mutableListOf()
+
+ override fun createNativeModules(
+ reactContext: ReactApplicationContext
+ ): MutableList = listOf(MyIdModule(reactContext)).toMutableList()
+}
\ No newline at end of file
diff --git a/android/app/src/main/java/com/myidsample/MainActivity.java b/android/app/src/main/java/com/myidsample/MainActivity.java
deleted file mode 100644
index da1acb8998bbcfbefef14a9994c2a60d48c8d1d0..0000000000000000000000000000000000000000
--- a/android/app/src/main/java/com/myidsample/MainActivity.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.myidsample;
-
-import com.facebook.react.ReactActivity;
-import com.facebook.react.ReactActivityDelegate;
-import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
-import com.facebook.react.defaults.DefaultReactActivityDelegate;
-
-public class MainActivity extends ReactActivity {
-
- /**
- * Returns the name of the main component registered from JavaScript. This is used to schedule
- * rendering of the component.
- */
- @Override
- protected String getMainComponentName() {
- return "MyIdSample";
- }
-
- /**
- * Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link
- * DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React
- * (aka React 18) with two boolean flags.
- */
- @Override
- protected ReactActivityDelegate createReactActivityDelegate() {
- return new DefaultReactActivityDelegate(
- this,
- getMainComponentName(),
- // If you opted-in for the New Architecture, we enable the Fabric Renderer.
- DefaultNewArchitectureEntryPoint.getFabricEnabled(), // fabricEnabled
- // If you opted-in for the New Architecture, we enable Concurrent React (i.e. React 18).
- DefaultNewArchitectureEntryPoint.getConcurrentReactEnabled() // concurrentRootEnabled
- );
- }
-}
diff --git a/android/app/src/main/java/com/myidsample/MainApplication.java b/android/app/src/main/java/com/myidsample/MainApplication.java
deleted file mode 100644
index 724350b7fb310a3830787060eb0c1c101ded5de6..0000000000000000000000000000000000000000
--- a/android/app/src/main/java/com/myidsample/MainApplication.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package com.myidsample;
-
-import android.app.Application;
-
-import com.facebook.react.PackageList;
-import com.facebook.react.ReactApplication;
-import com.facebook.react.ReactNativeHost;
-import com.facebook.react.ReactPackage;
-import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
-import com.facebook.react.defaults.DefaultReactNativeHost;
-import com.facebook.soloader.SoLoader;
-
-import java.util.List;
-
-public class MainApplication extends Application implements ReactApplication {
-
- private final ReactNativeHost mReactNativeHost =
- new DefaultReactNativeHost(this) {
- @Override
- public boolean getUseDeveloperSupport() {
- return BuildConfig.DEBUG;
- }
-
- @Override
- protected List getPackages() {
- List packages = new PackageList(this).getPackages();
- packages.add(new MyIdPackage());
- return packages;
- }
-
- @Override
- protected String getJSMainModuleName() {
- return "index";
- }
-
- @Override
- protected boolean isNewArchEnabled() {
- return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
- }
-
- @Override
- protected Boolean isHermesEnabled() {
- return BuildConfig.IS_HERMES_ENABLED;
- }
- };
-
- @Override
- public ReactNativeHost getReactNativeHost() {
- return mReactNativeHost;
- }
-
- @Override
- public void onCreate() {
- super.onCreate();
- SoLoader.init(this, false);
- if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
- DefaultNewArchitectureEntryPoint.load();
- }
- ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
- }
-}
diff --git a/android/app/src/main/java/com/myidsample/MyIdModule.java b/android/app/src/main/java/com/myidsample/MyIdModule.java
deleted file mode 100644
index d1e0879015ef06a730a411fbfba9657223ac4688..0000000000000000000000000000000000000000
--- a/android/app/src/main/java/com/myidsample/MyIdModule.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package com.myidsample;
-
-import android.app.Activity;
-import android.content.Intent;
-
-import androidx.annotation.Nullable;
-
-import com.facebook.react.bridge.ActivityEventListener;
-import com.facebook.react.bridge.Arguments;
-import com.facebook.react.bridge.LifecycleEventListener;
-import com.facebook.react.bridge.ReactApplicationContext;
-import com.facebook.react.bridge.ReactContextBaseJavaModule;
-import com.facebook.react.bridge.ReactMethod;
-import com.facebook.react.bridge.WritableMap;
-import com.facebook.react.modules.core.DeviceEventManagerModule;
-
-import java.util.Locale;
-
-import uz.myid.android.sdk.capture.MyIdBuildMode;
-import uz.myid.android.sdk.capture.MyIdCameraShape;
-import uz.myid.android.sdk.capture.MyIdClient;
-import uz.myid.android.sdk.capture.MyIdConfig;
-import uz.myid.android.sdk.capture.MyIdEntryType;
-import uz.myid.android.sdk.capture.MyIdException;
-import uz.myid.android.sdk.capture.MyIdResidentType;
-import uz.myid.android.sdk.capture.MyIdResult;
-import uz.myid.android.sdk.capture.MyIdResultListener;
-
-public class MyIdModule extends ReactContextBaseJavaModule implements LifecycleEventListener, ActivityEventListener, MyIdResultListener {
-
- private final MyIdClient myIdClient = new MyIdClient();
-
- public MyIdModule(ReactApplicationContext reactContext) {
- super(reactContext);
-
- reactContext.addLifecycleEventListener(this);
- reactContext.addActivityEventListener(this);
- }
-
- @Override
- public String getName() {
- return "MyIdModule";
- }
-
- @Override
- public void onHostResume() {
- }
-
- @Override
- public void onHostPause() {
- }
-
- @Override
- public void onHostDestroy() {
- }
-
- @Override
- public void onActivityResult(Activity activity, int requestCode, int resultCode, @Nullable Intent intent) {
- myIdClient.handleActivityResult(resultCode, this);
- }
-
- @Override
- public void onNewIntent(Intent intent) {
- }
-
- @Override
- public void onSuccess(MyIdResult result) {
- WritableMap params = Arguments.createMap();
- params.putString("code", result.getCode());
- params.putDouble("comparison", result.getComparison());
-
- sendEvent("onSuccess", params);
- }
-
- @Override
- public void onError(MyIdException e) {
- WritableMap params = Arguments.createMap();
- params.putString("message", e.getMessage());
- params.putInt("code", e.getCode());
-
- sendEvent("onError", params);
- }
-
- @Override
- public void onUserExited() {
- WritableMap params = Arguments.createMap();
- params.putString("message", "User exited");
-
- sendEvent("onUserExited", params);
- }
-
- @ReactMethod
- public void startMyId() {
- MyIdConfig myIdConfig = new MyIdConfig.Builder("YOUR_CLIENT_ID")
- .withPassportData("AB1234567")
- .withBirthDate("01.09.1991")
- .withBuildMode(MyIdBuildMode.PRODUCTION)
- .withEntryType(MyIdEntryType.AUTH)
- .withResidency(MyIdResidentType.RESIDENT)
- .withLocale(new Locale("en"))
- .withCameraShape(MyIdCameraShape.CIRCLE)
- .withPhoto(false)
- .build();
-
- if (getCurrentActivity() != null) {
- myIdClient.startActivityForResult(getCurrentActivity(), 1, myIdConfig);
- }
- }
-
- private void sendEvent(
- String eventName,
- @Nullable WritableMap params
- ) {
- getReactApplicationContext()
- .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
- .emit(eventName, params);
- }
-}
diff --git a/android/app/src/main/java/com/myidsample/MyIdPackage.java b/android/app/src/main/java/com/myidsample/MyIdPackage.java
deleted file mode 100644
index 932a696f74c3df0c32e3572bd121f78816000123..0000000000000000000000000000000000000000
--- a/android/app/src/main/java/com/myidsample/MyIdPackage.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.myidsample;
-
-import com.facebook.react.ReactPackage;
-import com.facebook.react.bridge.NativeModule;
-import com.facebook.react.bridge.ReactApplicationContext;
-import com.facebook.react.uimanager.ViewManager;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-public class MyIdPackage implements ReactPackage {
-
- @Override
- public List createViewManagers(ReactApplicationContext reactContext) {
- return Collections.emptyList();
- }
-
- @Override
- public List createNativeModules(
- ReactApplicationContext reactContext) {
- List modules = new ArrayList<>();
-
- modules.add(new MyIdModule(reactContext));
-
- return modules;
- }
-
-}
\ No newline at end of file
diff --git a/android/app/src/main/res/drawable/rn_edit_text_material.xml b/android/app/src/main/res/drawable/rn_edit_text_material.xml
index f35d9962026a854a166779fd2a3850d05ce315c6..5c25e728ea2ce7724bd9ef08c87ce7ee89c77103 100644
--- a/android/app/src/main/res/drawable/rn_edit_text_material.xml
+++ b/android/app/src/main/res/drawable/rn_edit_text_material.xml
@@ -17,10 +17,11 @@
android:insetLeft="@dimen/abc_edit_text_inset_horizontal_material"
android:insetRight="@dimen/abc_edit_text_inset_horizontal_material"
android:insetTop="@dimen/abc_edit_text_inset_top_material"
- android:insetBottom="@dimen/abc_edit_text_inset_bottom_material">
+ android:insetBottom="@dimen/abc_edit_text_inset_bottom_material"
+ >
-
+ NSAllowsArbitraryLoads
+
+ NSAllowsLocalNetworking
+
+ NSCameraUsageDescription
+ Required for document and facial capture
NSLocationWhenInUseUsageDescription
UILaunchStoryboardName
LaunchScreen
UIRequiredDeviceCapabilities
- armv7
+ arm64
UISupportedInterfaceOrientations
diff --git a/ios/MyIdSample/LaunchScreen.storyboard b/ios/MyID/LaunchScreen.storyboard
similarity index 94%
rename from ios/MyIdSample/LaunchScreen.storyboard
rename to ios/MyID/LaunchScreen.storyboard
index 128298f2d78439e08ed78a1964c68be09fb4819d..203002558d2ec6d9c68b0eb40cdebbe4253b782a 100644
--- a/ios/MyIdSample/LaunchScreen.storyboard
+++ b/ios/MyID/LaunchScreen.storyboard
@@ -16,7 +16,7 @@
-