0.1.81 • Published 8 months ago

expo-myid v0.1.81

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

expo-myid

Wrapper of https://docs.myid.uz/#/en/sdk my id sdk

Installation in managed Expo projects

expo install expo-myid expo-camera

npx expo prebuild

In app.config.ts or app.json

Add the following to your plugins section in app.json:

    "plugins": [
        "expo-myid",
      [
        "expo-camera",
        {
          "cameraPermission": "Allow $(PRODUCT_NAME) to access your camera",
          "microphonePermission": "Allow $(PRODUCT_NAME) to access your microphone",
          "recordAudioAndroid": true
        }
      ]
    ]

YOU MUST PREBUILD YOUR CLEAN AFTER INSTALLATION OF THE LIBRARY

npx expo prebuild --clean

npm run android or npm run ios

Usage

import { MyId, useMyIdEvent } from 'expo-myid';
import {Button, SafeAreaView, ScrollView, Text, View} from 'react-native';

const client_id = 'sample_client_id';
const clientHashId = 'sample_client_hash_id';
const mode: "DEBUG"|"PRODUCTION" = 'DEBUG';
const clientHash = `sample_client_hash`;
const language = 'ru';

export default function App() {
  const payload = useMyIdEvent(); // null or onMyidPayload

  console.log(payload)

  return (
    <SafeAreaView style={styles.container}>
      <ScrollView style={styles.container}>
        <Text style={styles.header}>Module API Example</Text>
        <Group name="Async functions">
          <Button
            title="Myid"
            onPress={async () => {
              MyId.myid_login({
                clientHashId: clientHashId,
                clientId: client_id,
                clientHash: clientHash,
                mode: mode,
                locale: language
              })
            }} // will open login intent
          />
        </Group>
        <Group name="Events">
          <Text>Status: {payload?.status}</Text>
          <Text>Error: {payload?.error}</Text>
          <Text>Error Code: {payload?.error_code}</Text>
          <Text>Code: {payload?.code}</Text>
          
        </Group>
      </ScrollView>
    </SafeAreaView>
  );
}
    

Types

ExpoMyid.myid_login

type myid_login = (
  props:
    {
      clientId: string,
      clientHashId: string,
      clientHash: string,
      mode: "DEBUG" | "PRODUCTION",
      locale: "ru" | "en" | "uz",
    }
) => Promise<void>

useMyIdEvent();

type useMyIdEvent = () => null | onMyidPayload;

onMyidPayload

export type onMyidPayload = {
  code: string;
  error: string;
  status: "success"|"error"
  error_code: string;
};
0.1.81

8 months ago

0.1.8

8 months ago

0.1.7

8 months ago

0.1.6

8 months ago

0.1.5

8 months ago

0.1.3

8 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago