Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@monaca/monaca-plugin-barcode-scanner
Advanced tools
Readme
Barcode scanner Monaca Plugin.
This plugin provides a scanning barcode feature. Detect barcode or QR Code1 by device's camera and returns extracted strings.
Normal
modeOne Shot
modeA Specified message can be displayed if no code is detected for a certain period.
Notes:
See here for the caution of detection.
Some devices may fail to detect barcodes. See here for details.
monaca.BarcodeScanner.scan(successCallback, failCallback[, options])
scan ()
will transition to the scanner screen.Normal mode
)successCallback
.One Shot
mode, the first detected code is returned and screen is closed automatically.successCallback(result)
result: following data
{
data: {
"text": "xxxxxxxx" // detected string
"format": "QR_CODE" // barcode type
},
cancelled: false // detection cancelled(true) or not(false)
}
failCallback(error)
error: error message(string)
message | description |
---|---|
"permission denied" | camera permission is not granted. |
{
"oneShot" : true,
"timeoutPrompt" : {
"show" : true,
"timeout" : 5,
"prompt" : "Not detected"
},
"debug" : {
"preview" : 0
}
}
parameter | type | default value | description |
---|---|---|---|
oneShot | boolean | false | Enable or disable One Shot mode. |
timeoutPrompt.show | boolean | false | Show or hide detection timeout message. |
timeoutPrompt.timeout | int | - | Period(in seconds) from when the barcode not detected until the message is displayed. |
timeoutPrompt.prompt | string | "Barcode not detected" | Timeout message. |
debug.preview (android only) | int | 0 | Displays camera preview bitmap(before sending to MLKit) on screen. 0: OFF(default) 1: Inside detection area 2: Whole camera image |
monaca.BarcodeScanner.scan((result) => {
if (result.cancelled) {
// scan cancelled
} else {
// scan
const detected_text = result.data.text;
const detected_format = result.data.format;
}
}, (error) => {
// permission error
const error_message = error;
}, {
"oneShot" : true,
"timeoutPrompt" : {
"show" : true,
"timeout" : 5,
"prompt" : "Not detected"
}
});
Since iOS 10, it's mandatory to provide a usage description in the info.plist
.
The description string is displayed in the permission dialog box.
This plugin requires the following usage descriptions:
NSCameraUsageDescription
specifies the reason for your app to access the device's camera.To add these entries ito the info.plist
, you can use the <edit-config>
tag in the config.xml
file like this:
<platform name="ios">
<edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="merge">
<string>need camera access to scan barcode</string>
</edit-config>
</platform>
The library androidx.camera:camera-view
used internally requires compileSDKVersion>=31
.
To specify the compileSdkVersion in Cordova, you should set android-targetSdkVersion
by using the <preference>
tag in the config.xml
file like this:
<preference name="android-targetSdkVersion" value="31" />
This plugin detects barcodes by processing the image captured by the camera (ImageProxy) and passing it to the barcode detection library (MLKit).
ImageProxy can store images in a variety of formats, and it depends on the device what format the camera captures.
Some devices may fail to detect barcodes because they are captured in a format not supported by the plugin.
version | supported format |
---|---|
before ver.1.2.1 | - Support JPEG or YUV_420_888 - Support only when plane buffer's rowStride is same as ImageWidth |
ver.1.3.0 | - Support when plane buffer's rowStride is different from ImageWidth |
You can check the device compatibility by using the debug preview
feature added in ver.1.3.0.
debug preview
in config monaca.BarcodeScanner.scan((result) => {
if (result.cancelled) {
// scan cancelled
} else {
// scan
}
}, (error) => {
// permission error
const error_message = error;
}, {
"debug" : {
"preview" : 1
}
});
If this thumbnail image is displayed distorted, it will be a device that does not support.
Ver.1.2.0:
Ver.1.4.0
Caution:
see LICENSE
QR Code is a registered trademark of DENSO WAVE INCORPORATED in Japan and in other countries. ↩
FAQs
Monaca Barcode Scanner Plugin
The npm package @monaca/monaca-plugin-barcode-scanner receives a total of 10 weekly downloads. As such, @monaca/monaca-plugin-barcode-scanner popularity was classified as not popular.
We found that @monaca/monaca-plugin-barcode-scanner demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.