identification
Example :
- Android
- IOS
- Flutter
- React Native
package com.immeapp;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import androidx.appcompat.app.AppCompatActivity;
import com.immeapp.Constants.CYCURID_REQUEST_CODE;
import com.immeapp.databinding.ActivityMainBinding;
import java.util.*;
public class MainActivity extends AppCompatActivity {
private ActivityMainBinding binding; // View binding for activity_main.xml
private CycurIDClass cycurIDClass; // Instance of CycurIDClass
private CycuridType apiFlow = CycuridType.identification; // Type of CycurID flow
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initialize view binding
binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
// Set text for sample text view
binding.sampleText.setText("Demo App");
// Button click listener
binding.button1.setOnClickListener(v -> {
v.setEnabled(false);
// Configure CycurID
CycurIDConfiguration.Configure(
this,
"API KEY",
"API SECRET",
"USER ID",
(cycurid, error) -> {
if (cycurid != null) {
cycurid.beginProcess(CycuridType.identification); // Begin CycurID process
} else {
Log.i("Error", "${error}"); // Log error if configuration fails
}
}
);
});
}
// Handle result from CycurID activity
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CYCURID_REQUEST_CODE) {
String res = data.getStringExtra("CYCURID_RESULT"); // Get CycurID result
Log.i("CYCURIDSDK", "Result: ${res}"); // Log CycurID result
}
}
}
import UIKit
import imme_ios
class ViewController: UIViewController, BiometricResultDelegate {
// Declare variables
var button1: UIButton! // Button for starting Identification check
var uuid: String? // UUID for device identification
override func viewDidLoad() {
super.viewDidLoad()
// Create and configure the button
button1 = UIButton(type: .system)
button1.setTitle("Start Identification", for: .normal)
button1.addTarget(self, action: #selector(startidentification(sender:)), for: .touchUpInside)
button1.frame = CGRect(x: 50, y: 100, width: 200, height: 50)
view.addSubview(button1)
}
// BiometricResultDelegate method
func biometricResult(result: String) {
print("identification Result is: \(result)")
}
// Button action method for starting Identification check
@objc func startidentification(sender: UIButton) {
// Configure CycurID with API key, secret key, and userId
CycurIDConfiguration.Configure(apiKey: "API KEY", secretKey: "SECRET KEY", userId: "USER ID") { [self] result in
switch result {
case .success(let cycurid):
// Call CycurID's beginProcess method with flow type identification and self as delegate
self.cycurid.beginProcess(flow: .identification, delegateClass: self)
case .failure(let err):
// Optionally, present an error alert to the user
print("Config Error: \(err)")
}
}
}
}
// Importing necessary packages
import 'package:flutter/material.dart';
import 'package:flutter_cycurid/flutter_cycurid.dart';
import 'package:flutter_cycurid/flutter_cycurid_method_channel.dart';
// Main entry point of the application
void main() {
runApp(const MainApp()); // Starting the app by running the MainApp widget
}
// Main application widget
class MainApp extends StatelessWidget {
const MainApp({Key? key}); // Constructor for MainApp widget
Widget build(BuildContext context) {
return const MaterialApp(
home: const MyHomePage(title: 'Cycurid SDK Demo'), // Setting MyHomePage as the home screen
);
}
}
// Home screen widget
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}); // Constructor for MyHomePage widget
final String title;
State<MyHomePage> createState() => _MyHomePageState(); // Creating state for MyHomePage
}
// State class for MyHomePage
class _MyHomePageState extends State<MyHomePage> {
final _flutterCycuridPlugin = FlutterCycurid(); // Instance of FlutterCycurid class
final _flutterEventChannel = MethodChannelFlutterCycurid(); // Instance of MethodChannelFlutterCycurid class
String _eventData = ''; // Variable to hold event data
// Method to initialize CycurID
Future<void> initCycurID() async {
CycurIdType type = CycurIdType.identification; // Setting CycurID type
CycuridOptions options = CycuridOptions( // Creating options for CycurID initialization
userId: "USER ID",
apiKey: "API KEY",
secretKey: "SECRET KEY");
_flutterCycuridPlugin.initCycurid(type, options); // Initializing CycurID
}
void initState() {
super.initState();
// Setting up listener to receive CycurID result
_flutterEventChannel.onReceiveCycuridResult().listen((event) {
setState(() {
_eventData = event.toString(); // Updating event data when result is received
});
});
}
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(_eventData), // Displaying event data
SizedBox(height: 20),
Center(
child: FloatingActionButton(
onPressed: initCycurID, // Initiating CycurID when button is pressed
tooltip: 'Start',
child: Text('Start'),
),
),
],
),
),
);
}
}
import { useState } from 'react';
import { Text, View, StyleSheet, Button } from 'react-native';
import {
initCycurid,
CycurIdType,
CycuridConfig,
} from 'react-native-cycurid-sdk';
export default function App() {
const [result, setResult] = useState<string | null>(null);
const handleButtonPress = async (type: CycurIdType) => {
const config = new CycuridConfig('API KEY', 'SECRET KEY', 'USER ID');
try {
const result = await initCycurid(type, config);
setResult(result);
} catch (error) {
console.error('Error:', error);
}
};
return (
<View style={styles.container}>
<View style={styles.buttonContainer}>
<Button
title="Identification"
onPress={() => handleButtonPress(CycurIdType.identification)}
/>
</View>
{result && <Text style={styles.resultText}>Result: {result}</Text>}
</View>
);
}
Responses:
identification Success:
["Liveness": "Pass", "ID_Verification": "Pass"]