更新记录
v1.0.0(2024-07-05) 下载此版本
UNIPHIZ设备二维码扫描插件
平台兼容性
Android | Android CPU类型 | iOS |
---|---|---|
适用版本区间:5.0 - 14.0 | armeabi-v7a:支持,arm64-v8a:支持,x86:未测试 | × |
原生插件通用使用流程:
- 购买插件,选择该插件绑定的项目。
- 在HBuilderX里找到项目,在manifest的app原生插件配置中勾选模块,如需要填写参数则参考插件作者的文档添加。
- 根据插件作者的提供的文档开发代码,在代码中引用插件,调用插件功能。
- 打包自定义基座,选择插件,得到自定义基座,然后运行时选择自定义基座,进行log输出测试。
- 开发完毕后正式云打包
付费原生插件目前不支持离线打包。
Android 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/android
iOS 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/ios
注意事项:使用HBuilderX2.7.14以下版本,如果同一插件且同一appid下购买并绑定了多个包名,提交云打包界面提示包名绑定不一致时,需要在HBuilderX项目中manifest.json->“App原生插件配置”->”云端插件“列表中删除该插件重新选择
UNIPHIZ-API-Scanner Specification
To use this plugin, you also need to install the UNIPHIZ-API-Common plugin, otherwise some functions may not work properly
1. Reference Mode
const scanner = uni.requireNativePlugin('UNIPHIZ-API-Scanner-ScannerManager')
2. Interface Catalog
// Get instance
// Release resource
// Close the scanner
If scanOpen() is called is an activity, scanClose() should be called when the activity ends
// Get the barcode device parameters
// Open the scanner
Call this method to open the scanner and use scanClose() to close it
Call scanClose() when the activity is finished
// Set the barcode device parameters
// If a parameter is set, the scanner will automatically exit scanning after the maximum number of scans to be performed
If the parameter is 0, the scanner will perform continuous scanning.
// Set whether to enable the flashlight during scanning
// Start scanning
startScan(callbackOnRead, callbackOnComplete, callbackOnCancel)
// Stop scanning
3. Interface Specification
Function Description
Function | Type | Description |
---|---|---|
function | get instance |
Example
scanner.init()
Function Description
Function | Type | Description |
---|---|---|
function | release resource |
Example
scanner.destroy()
Function Description
Function | Type | Description |
---|---|---|
json | result of execution |
Example
scanner.closeScan()
Function Description
Function | Type | Description |
---|---|---|
json | barcodes supported by device |
Example
scanner.getBarcodeParam()
Function Description
Function | Type | Description |
---|---|---|
json | result of execution |
Example
scanner.openScan()
Function Description
Function | Type | Description |
---|---|---|
json | result of execution |
Parameter | Type | Description |
---|---|---|
paramStr | string | barcode param string |
Example
scanner.setBarcodeParam("UPC-A,true,C39,true,C128,falseI25,true,C93,false,GS1 DATABAR,true,MSI,false,CODEBLOCK F,false,PDF417,true")
Function Description
Function | Type | Description |
---|---|---|
json | result of execution |
Parameter | Type | Description |
---|---|---|
maxScanItem | number | maximum number of scans performed |
Example
scanner.setBatchScanMode(8)
Function Description
Function | Type | Description |
---|---|---|
json | result of execution |
Parameter | Type | Description |
---|---|---|
isOn | boolean | whether enable the flashlight during scanning |
Example
scanner.setFlashOn(false)
startScan(callbackOnRead, callbackOnComplete, callbackOnCancel)
Function Description
Function | Type | Description |
---|---|---|
json | result of execution |
Parameter | Type | Description |
---|---|---|
callbackOnRead | Callback | callback after scan complete |
callbackOnComplete | Callback | callback when scan complete |
callbackOnCancel | Callback | callback when scan cancel |
Callback | Type | Description |
---|---|---|
result | json | result of scanning |
Example
scanner.startScan(result => {
console.log(result)
}, () => {
scanner.stopScan()
}, () => {
scanner.closeScan()
})
Function Description
Function | Type | Description |
---|---|---|
json | result of execution |
Example
scanner.stopScan()