Skip to content

Commit

Permalink
feat(sdk): react native stable SDK v1
Browse files Browse the repository at this point in the history
  • Loading branch information
ramananddigio committed Oct 27, 2023
1 parent b0ddfc6 commit 1bf65ce
Show file tree
Hide file tree
Showing 32 changed files with 15,562 additions and 65 deletions.
111 changes: 97 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,114 @@
# digio-react-native
# Digio React Native SDK

SDK for invoking client side journey for any of Digio request
Official React Native SDK for Digio Gateway Integration

## Installation

```sh
npm install digio-react-native
yarn install @digiotech/react-native
```

## Usage
## Documentation

```js
import { multiply } from 'digio-react-native';
Documentation of Digio Gateway Integration and their usage is available at <https://documentation.digio.in>

// ...
### Basic Usage

const result = await multiply(3, 7);
Instantiate the Digio instance with `environment` & other options

```tsx
import { Digio, DigioConfig, DigioResponse } from '@digiotech/react-native';

const config: DigioConfig = { environment: Environment.PRODUCTION };
const digio = new Digio(config);
const documentId = "<document_id>";
const identifier = "<email_or_phone>";
const digioResponse: DigioResponse = await digio.start(documentId, identifier);
```

### Consuming gateway events [Optional]

You can consume events and understand the flow or the journey of the user as he is performing it.

For a complete list of events and the payload associated with it, refer [here](https://docs.google.com/document/d/15LHtjGyXd_JNM0de8uH9zB7WllJikRl1d9e4qdy0-C0/edit?usp=sharing)

```tsx
import { useEffect } from 'react';
import { Digio, DigioConfig, GatewayEvent } from '@digiotech/react-native';

function YourComponent() {
useEffect(() => {
const gatewayEventListener = digio.addGatewayEventListener(
(event: GatewayEvent) => {
// Do some operation on the received events
}
);

return () => {
gatewayEventListener.remove();
}
}, []);
}
```

## Contributing
### Complete Usage

```tsx
import { useEffect } from 'react';
import { Digio, DigioConfig, GatewayEvent } from '@digiotech/react-native';

function YourComponent() {
useEffect(() => {
const gatewayEventListener = digio.addGatewayEventListener(
(event: GatewayEvent) => {
// Do some operation on the received events
}
);

return () => {
gatewayEventListener.remove();
}
}, []);

const triggerDigioGateway = async () => {
const config: DigioConfig = { environment: Environment.PRODUCTION };
const digio = new Digio(config);
const documentId = "<document_id>";
const identifier = "<email_or_phone>";
const tokenId = "<gateway_token_id";
const digioResponse: DigioResponse = await digio.start(documentId, identifier, tokenId);

}
}
```

## SDK Reference

### DigioConfig

**Parameters:**

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
| Name | Type | Description |
|-----------------|---------|----------------------------------------------------------------------------------------|
| environment* | string | Environment for which you want to open gateway. One of `sandbox` or `production` |
| logo | string | Pass an URL of your brand logo. **Note:** Pass an optimised image url for best results |
| theme | string | Options for changing the appearance of the gateway. See below for options under it. |

## License
**Theme:**

MIT
| Name | Type | Description |
|----------------|---------|--------------------------------------------------------------------------|
| primaryColor | string | Your brand colour's HEX code to alter CTA (call-to-action) button colors |
| secondaryColor | string | HEX Code to alter text colors |
| fontFamily | string | Font Family of your choice. For eg: Crimson Pro |
| fontFormat | string | Format of the Font Family Provided. For eg: ’woff2’,’ot’,’tt’ |
| fontUrl | string | Font Family URL. For eg: '{font_family_url}.woff2' |

---
### DigioResponse [Response received from Gateway]

Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
| Name | Type | Description |
|-------------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| code* | number | SUCCESS = 1001 <br /> FAIL = 1002 <br /> CANCEL = -1000 <br /> WEBVIEW_CRASH = 1003 <br /> WEBVIEW_ERROR = 10017 <br /> SDK_CRASH = 1004 <br /> Location/Camera/MicroPhone Permission Denied By User = 1008 |
| documentId | string | Document ID Passed from the parent app. For eg: `KID22040413040490937VNTC6LAP8KWD` |
| message | string | Error message in case of crash or failure |
| permissions | Array<string> | List of mandatory permissions which are not given during kyc journey |
20 changes: 20 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ buildscript {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}

dependencies {
Expand Down Expand Up @@ -69,6 +70,10 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
dataBinding true
}
}

repositories {
Expand All @@ -82,5 +87,20 @@ dependencies {
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation 'com.github.digio-tech:gateway:v4.0.8'
implementation 'com.github.digio-tech:gateway_kyc:v4.0.8'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "androidx.camera:camera-core:1.1.0"
implementation "androidx.camera:camera-camera2:1.1.0"
implementation "androidx.camera:camera-lifecycle:1.1.0"
implementation "androidx.camera:camera-view:1.1.0"
implementation 'androidx.navigation:navigation-fragment:2.5.3'
implementation 'androidx.navigation:navigation-ui:2.5.3'
implementation 'androidx.preference:preference:1.2.0'
implementation 'com.google.android.gms:play-services-mlkit-face-detection:17.1.0'
implementation 'com.google.android.gms:play-services-location:21.0.1'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
}

Binary file added android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 1bf65ce

Please sign in to comment.