react-native-rdservice-fingerprintscanner 1.0.7 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -37,7 +37,7 @@ import { getDeviceInfo, captureFinger } from "react-native-rdservice-fingerprint
37
37
 
38
38
  getDeviceInfo()
39
39
  .then((response) => {
40
- console.log(response, 'DEVICE DRIVER FOUND'); // Either The Device connected or not connected response here
40
+ console.log(response, 'DEVICE DRIVER FOUND'); // Response about Device Driver
41
41
  })
42
42
  .catch((error) => {
43
43
  console.log(error, 'DEVICE DRIVER NOT FOUND'); //Failed to get device information
@@ -45,15 +45,45 @@ getDeviceInfo()
45
45
 
46
46
  captureFinger(pidOptions)
47
47
  .then((response) => {
48
- console.log(response, 'FINGER CAPTURE'); // Either The Device Connected or Not Connected Response here
48
+ console.log(response, 'FINGER CAPTURE'); // FingerPrint Response
49
49
  })
50
50
  .catch((e) => {
51
51
  console.log(e, 'ERROR_FINGER_CAPTURE'); // Failed to capture the Fingerprint
52
52
  });
53
53
  ```
54
54
 
55
+
55
56
  ```pidOptions``` is an XML String that you have to pass to ```captureFinger``` method. Refer [UIDAI Document](https://uidai.gov.in/images/resource/Aadhaar_Registered_Devices_2_0_4.pdf)
56
57
 
58
+ ```Note``` : Call ```captureFinger()``` Method after getting response from getDeviceInfo() method. Calling of ```captureFinger()``` method before ```getDeviceInfo()``` method, only returns Error in ```catch``` block. Refer [Example Code](https://github.com/senthalan2/react-native-rdservice-fingerprintscanner/blob/main/example/src/App.js)
59
+
60
+
61
+ ## Response JSON Object
62
+
63
+ ```getDeviceInfo()``` Method Reponse
64
+
65
+ Key | Value | Description
66
+ --- | --- | ---
67
+ status | -1 or 1 or 0 | ```-1``` - Device Driver not Found, ```1``` - READY, ```0``` - NOTREADY
68
+ isWhitelisted | true or false | iT is about the Device is Approved or not. ```true``` - Approved, ```false``` - Not Approved
69
+ rdServiceInfoJson |JSON DATA | The device returns XML DATA of Device Information. this parameter contains converted JSON DATA of XML DATA
70
+ rdServiceInfoXML | XML DATA | Device Information
71
+ rdServicePackage | Device Package
72
+
73
+
74
+
75
+ ```captureFinger()``` Method Reponse
76
+
77
+ Key | Value | Description
78
+ --- | --- | ---
79
+ status | 1 or 0 | ```1``` - Fingerprint Captured Successfully, ```0``` - FingerPrint not Captured (Check Connection of Device and OTG Connection Settings in Mobile)
80
+ errorCode | ERROR CODE from RD Service | Refer [UIDAI Document](https://uidai.gov.in/images/resource/Aadhaar_Registered_Devices_2_0_4.pdf) and [RDService Error Details](https://github.com/senthalan2/react-native-rdservice-fingerprintscanner/blob/main/Assets/RDService_Error_Details.pdf)
81
+ errInfo | Error Message according to the ERROR CODE | Refer [UIDAI Document](https://uidai.gov.in/images/resource/Aadhaar_Registered_Devices_2_0_4.pdf) and [RDService Error Details](https://github.com/senthalan2/react-native-rdservice-fingerprintscanner/blob/main/Assets/RDService_Error_Details.pdf)
82
+ pidDataJson |JSON DATA | The device returns PID DATA of Captured Fingerprint. this parameter contains converted JSON pidData of XML pidData
83
+ pidDataXML | XML DATA | pidData Captured Fingerprint
84
+ rdServicePackage | Device Package
85
+
86
+
57
87
  ## Contributing
58
88
 
59
89
  See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
@@ -56,4 +56,5 @@ repositories {
56
56
  dependencies {
57
57
  //noinspection GradleDynamicVersion
58
58
  implementation "com.facebook.react:react-native:+" // From node_modules
59
+ implementation 'com.github.smart-fun:XmlToJson:1.5.1'
59
60
  }
@@ -2,6 +2,7 @@ package com.reactnativerdservicefingerprintscanner;
2
2
 
3
3
  import android.app.Activity;
4
4
  import android.content.Intent;
5
+ import android.util.Log;
5
6
  import android.widget.Toast;
6
7
 
7
8
  import androidx.annotation.NonNull;
@@ -15,6 +16,11 @@ import com.facebook.react.bridge.ReactMethod;
15
16
  import com.facebook.react.bridge.WritableMap;
16
17
  import com.facebook.react.module.annotations.ReactModule;
17
18
 
19
+ import org.json.JSONException;
20
+ import org.json.JSONObject;
21
+
22
+ import fr.arnaudguyon.xmltojsonlib.XmlToJson;
23
+
18
24
  @ReactModule(name = RdserviceFingerprintscannerModule.NAME)
19
25
  public class RdserviceFingerprintscannerModule extends ReactContextBaseJavaModule implements RDServiceEvents {
20
26
  public static final String NAME = "RdserviceFingerprintscanner";
@@ -40,41 +46,78 @@ public class RdserviceFingerprintscannerModule extends ReactContextBaseJavaModul
40
46
  this.promise = promise;
41
47
  final Activity activity = getCurrentActivity();
42
48
  rdServiceManager.discoverRdService(activity);
43
-
44
-
45
49
  }
46
50
 
47
51
  @ReactMethod
48
52
  public void captureFinger(String pidOptions, Promise promise) {
49
53
  this.promise = promise;
50
54
  final Activity activity = getCurrentActivity();
51
-
52
55
  rdServiceManager.captureRdService(servicePackage,pidOptions,activity);
53
-
54
-
55
56
  }
56
57
 
57
58
  @Override
58
59
  public void onRDServiceDriverDiscovery(String rdServiceInfo, String rdServicePackage, Boolean isWhitelisted) {
59
60
  // Called when an installed driver is discovered
60
61
  servicePackage = rdServicePackage;
62
+ XmlToJson xmlToJson = new XmlToJson.Builder(rdServiceInfo).build();
63
+ String jsonString = xmlToJson.toString();
64
+ try{
65
+ JSONObject obj = new JSONObject(jsonString);
66
+ String statusMsg = obj.getJSONObject("RDService").getString("status");
67
+ WritableMap responseData = Arguments.createMap();
68
+ if(statusMsg.equals("READY")){
69
+ responseData.putInt("status",1);
70
+ responseData.putString("message","Device is Ready");
71
+ }
72
+ else {
73
+ responseData.putInt("status",0);
74
+ responseData.putString("message","Make Sure the Device is Connected and OTG Connection is Enabled in your Mobile");
75
+ }
76
+ responseData.putString("rdServiceInfoJsonString", jsonString);
77
+ responseData.putString("rdServiceInfoXML", rdServiceInfo);
78
+ responseData.putString("rdServicePackage", rdServicePackage);
79
+ responseData.putBoolean("isWhitelisted",isWhitelisted);
80
+ promise.resolve(responseData);
81
+ }
82
+ catch(JSONException e){
83
+ promise.reject("DRIVER_DISCOVERY_FAILED","Driver Discovery Failed");
84
+ }
85
+
61
86
 
62
- WritableMap responseData = Arguments.createMap();
63
- responseData.putInt("status",1);
64
- responseData.putString("rdServiceInfo", rdServiceInfo);
65
- responseData.putString("rdServicePackage", rdServicePackage);
66
- responseData.putBoolean("isWhitelisted",isWhitelisted);
67
- promise.resolve(responseData);
68
87
  }
69
88
 
70
89
  @Override
71
90
  public void onRDServiceCaptureResponse(String pidData, String rdServicePackage) {
72
- // Called when fingerprint is successfully captured
73
- WritableMap responseData = Arguments.createMap();
74
- responseData.putInt("status",1);
75
- responseData.putString("pidData", pidData);
76
- responseData.putString("rdServicePackage", rdServicePackage);
77
- promise.resolve(responseData);
91
+
92
+ XmlToJson xmlToJson = new XmlToJson.Builder(pidData).build();
93
+ String jsonString = xmlToJson.toString();
94
+
95
+ try{
96
+ JSONObject obj = new JSONObject(jsonString);
97
+ JSONObject response = obj.getJSONObject("PidData").getJSONObject("Resp");
98
+ String errorCode = response.getString("errCode");
99
+ String errInfo = response.getString("errInfo");
100
+ WritableMap responseData = Arguments.createMap();
101
+ if(Integer.parseInt(errorCode) == 0 ){
102
+ responseData.putInt("status",1);
103
+ responseData.putString("message","FingerPrint Scanned Successfully");
104
+ }
105
+ else {
106
+ responseData.putInt("status",0);
107
+ responseData.putString("message","Make Sure the Device is Connected and OTG Connection is Enabled in your Mobile");
108
+ }
109
+
110
+ responseData.putString("errorCode",errorCode);
111
+ responseData.putString("errInfo",errInfo);
112
+ responseData.putString("pidDataJsonString", jsonString);
113
+ responseData.putString("pidDataXML", pidData);
114
+ responseData.putString("rdServicePackage", rdServicePackage);
115
+ promise.resolve(responseData);
116
+ }
117
+ catch (JSONException e){
118
+ promise.reject("FINGERPRINT_CAPTURE__FAILED","FingerPrint Capture Failed");
119
+ }
120
+
78
121
 
79
122
  }
80
123
 
@@ -82,7 +125,7 @@ public class RdserviceFingerprintscannerModule extends ReactContextBaseJavaModul
82
125
  public void onRDServiceDriverNotFound() {
83
126
  // Called when no installed driver is found
84
127
  WritableMap responseData = Arguments.createMap();
85
- responseData.putInt("status",0);
128
+ responseData.putInt("status",-1);
86
129
  responseData.putString("message","Driver Not Found");
87
130
  promise.resolve(responseData);
88
131
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rdservice-fingerprintscanner",
3
- "version": "1.0.7",
3
+ "version": "1.1.1",
4
4
  "description": "FingerPrint Scanner RD Service",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
package/src/index.js CHANGED
@@ -18,24 +18,48 @@ const RdserviceFingerprintscanner = NativeModules.RdserviceFingerprintscanner
18
18
  );
19
19
 
20
20
  export function getDeviceInfo() {
21
- return new Promise((resolve,reject)=>{
22
- RdserviceFingerprintscanner.getDeviceInfo().then(res=>{
23
- resolve(res)
24
- }).catch(err=>{
25
- reject(err)
26
- })
27
- })
28
-
21
+ return new Promise((resolve, reject) => {
22
+ RdserviceFingerprintscanner.getDeviceInfo()
23
+ .then((res) => {
24
+ if (res.status === -1) {
25
+ const resObj = {
26
+ status: res.status,
27
+ message: res.message,
28
+ };
29
+ resolve(resObj);
30
+ } else {
31
+ const resObj = {
32
+ isWhitelisted: res.isWhitelisted,
33
+ rdServiceInfoJson: JSON.parse(res.rdServiceInfoJsonString),
34
+ rdServiceInfoXML: res.rdServiceInfoXML,
35
+ rdServicePackage: res.rdServicePackage,
36
+ status: res.status,
37
+ };
38
+ resolve(resObj);
39
+ }
40
+ })
41
+ .catch((err) => {
42
+ reject(err);
43
+ });
44
+ });
29
45
  }
30
46
 
31
47
  export function captureFinger(pidOptions) {
32
- return new Promise((resolve,reject)=>{
33
- RdserviceFingerprintscanner.captureFinger(pidOptions).then(res => {
34
- resolve(res)
35
- }).catch( err => {
36
- reject(err)
37
- })
38
-
39
- })
40
-
48
+ return new Promise((resolve, reject) => {
49
+ RdserviceFingerprintscanner.captureFinger(pidOptions)
50
+ .then((res) => {
51
+ const resObj = {
52
+ pidDataJson: JSON.parse(res.pidDataJsonString),
53
+ pidDataXML: res.pidDataXML,
54
+ rdServicePackage: res.rdServicePackage,
55
+ status: res.status,
56
+ errInfo: res.errInfo,
57
+ errorCode: parseInt(res.errorCode),
58
+ };
59
+ resolve(resObj);
60
+ })
61
+ .catch((err) => {
62
+ reject(err);
63
+ });
64
+ });
41
65
  }
@@ -1,44 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.captureFinger = captureFinger;
7
- exports.getDeviceInfo = getDeviceInfo;
8
-
9
- var _reactNative = require("react-native");
10
-
11
- const LINKING_ERROR = `The package 'react-native-rdservice-fingerprintscanner' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
12
- ios: "- You have run 'pod install'\n",
13
- default: ''
14
- }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
15
- const RdserviceFingerprintscanner = _reactNative.NativeModules.RdserviceFingerprintscanner ? _reactNative.NativeModules.RdserviceFingerprintscanner : new Proxy({}, {
16
- get() {
17
- throw new Error(LINKING_ERROR);
18
- }
19
-
20
- });
21
-
22
- function getDeviceInfo() {
23
- return new Promise((resolve,reject)=>{
24
- RdserviceFingerprintscanner.getDeviceInfo().then(res=>{
25
- resolve(res)
26
- }).catch(err=>{
27
- reject(err)
28
- })
29
- })
30
-
31
- }
32
-
33
- function captureFinger(pidOptions) {
34
- return new Promise((resolve,reject)=>{
35
- RdserviceFingerprintscanner.captureFinger(pidOptions).then(res => {
36
- resolve(res)
37
- }).catch( err => {
38
- reject(err)
39
- })
40
-
41
- })
42
-
43
- }
44
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["index.js"],"names":["LINKING_ERROR","Platform","select","ios","default","RdserviceFingerprintscanner","NativeModules","Proxy","get","Error","getDeviceInfo","captureFinger","pidOptions"],"mappings":";;;;;;;;AAAA;;AAEA,MAAMA,aAAa,GAChB,oGAAD,GACAC,sBAASC,MAAT,CAAgB;AAAEC,EAAAA,GAAG,EAAE,gCAAP;AAAyCC,EAAAA,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,2BAA2B,GAAGC,2BAAcD,2BAAd,GAChCC,2BAAcD,2BADkB,GAEhC,IAAIE,KAAJ,CACE,EADF,EAEE;AACEC,EAAAA,GAAG,GAAG;AACJ,UAAM,IAAIC,KAAJ,CAAUT,aAAV,CAAN;AACD;;AAHH,CAFF,CAFJ;;AAWO,SAASU,aAAT,GAAyB;AAC9B,SAAOL,2BAA2B,CAACK,aAA5B,EAAP;AACD;;AAEM,SAASC,aAAT,CAAuBC,UAAvB,EAAmC;AACxC,SAAOP,2BAA2B,CAACM,aAA5B,CAA0CC,UAA1C,CAAP;AACD","sourcesContent":["import { NativeModules, Platform } from 'react-native';\n\nconst LINKING_ERROR =\n `The package 'react-native-rdservice-fingerprintscanner' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst RdserviceFingerprintscanner = NativeModules.RdserviceFingerprintscanner\n ? NativeModules.RdserviceFingerprintscanner\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport function getDeviceInfo() {\n return RdserviceFingerprintscanner.getDeviceInfo();\n}\n\nexport function captureFinger(pidOptions) {\n return RdserviceFingerprintscanner.captureFinger(pidOptions);\n}\n"]}
@@ -1,33 +0,0 @@
1
- import { NativeModules, Platform } from 'react-native';
2
- const LINKING_ERROR = `The package 'react-native-rdservice-fingerprintscanner' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
3
- ios: "- You have run 'pod install'\n",
4
- default: ''
5
- }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
6
- const RdserviceFingerprintscanner = NativeModules.RdserviceFingerprintscanner ? NativeModules.RdserviceFingerprintscanner : new Proxy({}, {
7
- get() {
8
- throw new Error(LINKING_ERROR);
9
- }
10
-
11
- });
12
- export function getDeviceInfo() {
13
- return new Promise((resolve,reject)=>{
14
- RdserviceFingerprintscanner.getDeviceInfo().then(res=>{
15
- resolve(res)
16
- }).catch(err=>{
17
- reject(err)
18
- })
19
- })
20
-
21
- }
22
- export function captureFinger(pidOptions) {
23
- return new Promise((resolve,reject)=>{
24
- RdserviceFingerprintscanner.captureFinger(pidOptions).then(res => {
25
- resolve(res)
26
- }).catch( err => {
27
- reject(err)
28
- })
29
-
30
- })
31
-
32
- }
33
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["index.js"],"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","RdserviceFingerprintscanner","Proxy","get","Error","getDeviceInfo","captureFinger","pidOptions"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,QAAxB,QAAwC,cAAxC;AAEA,MAAMC,aAAa,GAChB,oGAAD,GACAD,QAAQ,CAACE,MAAT,CAAgB;AAAEC,EAAAA,GAAG,EAAE,gCAAP;AAAyCC,EAAAA,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,2BAA2B,GAAGN,aAAa,CAACM,2BAAd,GAChCN,aAAa,CAACM,2BADkB,GAEhC,IAAIC,KAAJ,CACE,EADF,EAEE;AACEC,EAAAA,GAAG,GAAG;AACJ,UAAM,IAAIC,KAAJ,CAAUP,aAAV,CAAN;AACD;;AAHH,CAFF,CAFJ;AAWA,OAAO,SAASQ,aAAT,GAAyB;AAC9B,SAAOJ,2BAA2B,CAACI,aAA5B,EAAP;AACD;AAED,OAAO,SAASC,aAAT,CAAuBC,UAAvB,EAAmC;AACxC,SAAON,2BAA2B,CAACK,aAA5B,CAA0CC,UAA1C,CAAP;AACD","sourcesContent":["import { NativeModules, Platform } from 'react-native';\n\nconst LINKING_ERROR =\n `The package 'react-native-rdservice-fingerprintscanner' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst RdserviceFingerprintscanner = NativeModules.RdserviceFingerprintscanner\n ? NativeModules.RdserviceFingerprintscanner\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport function getDeviceInfo() {\n return RdserviceFingerprintscanner.getDeviceInfo();\n}\n\nexport function captureFinger(pidOptions) {\n return RdserviceFingerprintscanner.captureFinger(pidOptions);\n}\n"]}