Ionic文档扫描仪:结果不正确或用户取消了操作



我的离子文档扫描仪有问题(https://ionicframework.com/docs/native/document-scanner)它封装了cordova插件文档扫描仪(https://github.com/NeutrinosPlatform/cordova-plugin-document-scanner)。

我正在运行这段代码(从文档中复制(

ngAfterViewInit() {
this.platform.ready().then((readySource) => {
console.log('Platform ready from', readySource);
// Platform now ready, execute any required native code
let opts: DocumentScannerOptions = {};
this.documentScanner.scanDoc(opts)
.then((res: string) => console.log(res))
.catch((error: any) => console.error(error));  
});
}

显示相机视图,我拍照,显示图片以供用户验证。如果我确实接受图片,则会获得此错误:

Incorrect result or user canceled the action.

我不明白为什么会出现这个错误。版本:

Ionic CLI:6.12.3

Ionic框架:@ion/angular 5.6.

Cordova CLI:10.0.0

Cordova平台:android 9.0.0

cordova插件文档扫描仪4.2.6"扫描";

@离子原生/document-scanner@5.31.1

在android 11设备上运行(OxygenOS 11.1.1(

谢谢你的帮助。

此问题已在最新的测试版中修复。。请检查https://github.com/NeutrinosPlatform/cordova-plugin-document-scanner/issues/74#issuecomment-777267803

我在拍照前解决了禁用backgroundMode插件的问题,然后我再次启用插件:

this.backgroundMode.disable();
const OPTIONS: DocumentScannerOptions = {
sourceType: 1,
quality: 2.5,
returnBase64; true
}
this.DocumentScanner.scanDoc (OPTIONS)
.then ( result => {
setTimeout ( () => {
this.backgroundMode.enable();
}, 500);
console.log ( result );

相机和文档扫描仪插件都与backgroundMode插件存在此冲突。

最新更新