Closed leoxiaoping closed 3 years ago
Unfortunately, there is no way to understand whether the user click the return button without changing java code of the plugin. This issue will be fixed in the next release. If you are able to change the plugin code, I can provide a quick fix here:
Replace lines from 307 to 324 in your_project/node_modules/@hmscore/react-native-hms-scan/android/src/main/java/com/huawei/hms/rn/scan/scanutils/RNHMSScanUtilsModule.java file with the code sample below:
@Override
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE_SCAN_DEFAULT && mPromise != null) {
HMSLogger.getInstance(mReactContext).sendSingleEvent("ScanUtilsMethodCallHandler.defaultView");
if (resultCode == RESULT_OK) {
if (data != null) {
HmsScan obj = data.getParcelableExtra(ScanUtil.RESULT);
//Sending Result
mPromise.resolve(toWM(gson.toJson(obj)));
} else {
mPromise.reject("NULL", "Data is null");
}
} else {
mPromise.reject("NOT_OK", "Result is not ok"); // The promise will be rejected if user clicked the return button
}
mPromise = null;
}
}
@mustafahaluk Thanks
react-native-hms-scan扫码库识别率很高,如标题,有没有办法监听 startDefaultView() 的返回按钮