Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
expo-barcode-scanner
Advanced tools
expo-barcode-scanner
module allows scanning variety of supported barcodes both as standalone module and as extension for expo-camera
. It also allows scanning barcodes from existing images.
If your app is running in Expo then everything is already set up for you, just import { BarCodeScanner } from 'expo';
Otherwise, you need to install the package from npm
registry.
yarn add expo-barcode-scanner
or npm install expo-barcode-scanner
(that would install expo-barcode-scanner-interface
as well)
Also, make sure that you have expo-core and expo-permissions installed, as they are required by expo-barcode-scanner
to work properly.
Add the dependency to your Podfile
:
pod 'EXBarCodeScannerInterface', path: '../node_modules/expo-barcode-scanner-interface/ios'
pod 'EXBarCodeScanner', path: '../node_modules/expo-barcode-scanner/ios'
and run pod install
under the parent directory of your Podfile
.
android/settings.gradle
:
include ':expo-barcode-scanner-interface'
project(':expo-barcode-scanner-interface').projectDir = new File(rootProject.projectDir, '../node_modules/expo-barcode-scanner-interface/android')
include ':expo-barcode-scanner'
project(':expo-barcode-scanner').projectDir = new File(rootProject.projectDir, '../node_modules/expo-barcode-scanner/android')
android/app/build.gradle
:
compile project(':expo-barcode-scanner-interface')
compile project(':expo-barcode-scanner')
new BarCodeScannerPackage()
to your module registry provider in MainApplication.java
.Bar code format | iOS | Android |
---|---|---|
aztec | Yes | Yes |
codabar | No | Yes |
code39 | Yes | Yes |
code93 | Yes | Yes |
code128 | Yes | Yes |
code138 | Yes | No |
code39mod43 | Yes | No |
datamatrix | Yes | Yes |
ean13 | Yes | Yes |
ean8 | Yes | Yes |
interleaved2of5 | Yes | No |
itf14 | Yes* | Yes |
maxicode | No | Yes |
pdf417 | Yes | Yes |
rss14 | No | Yes |
rssexpanded | No | Yes |
upc_a | No | Yes |
upc_e | Yes | Yes |
upc_ean | No | Yes |
qr | Yes | Yes |
interleaved2of5
.You must request permission to access the user's camera before attempting to get it. To do this, you will want to use the Permissions API. You can see this in practice in the following example.
import React from 'react';
import { Button, Platform, StyleSheet, Text, View } from 'react-native';
import { BarCodeScanner } from 'expo-barcode-scanner';
import { Permissions } from 'expo-permissions';
export default class BarcodeScannerExample extends React.Component {
state = {
hasPermissionsGranted: null,
type: BarCodeScanner.Constants.Type.back,
};
async componentDidMount() {
let { status } = await Permissions.askAsync(Permissions.CAMERA);
this.setState({ hasPermissionsGranted: (status === 'granted') });
}
render() {
const { hasCameraPermission } = this.state;
if (hasCameraPermission === null) {
return <Text>Requesting for camera permission</Text>;
}
if (hasCameraPermission === false) {
return <Text>No access to camera</Text>;
}
return (
<View style={{ flex: 1 }}>
<BarCodeScanner
onBarCodeScanned={data => alert(JSON.stringify(data))}
barCodeTypes={[
BarCodeScanner.Constants.BarCodeType.qr,
BarCodeScanner.Constants.BarCodeType.pdf417,
]}
type={this.state.type}
style={{ ...StyleSheet.absoluteFillObject }}
/>
<TouchableOpacity
style={{
flex: 0.1,
alignSelf: 'flex-end',
alignItems: 'center',
}}
onPress={() => this.setState({ type:
this.state.type === BarCodeScanner.Constants.Type.back
? BarCodeScanner.Constants.Type.front
: BarCodeScanner.Constants.Type.back,
})}
>
<Text style={{ fontSize: 18, marginBottom: 10, color: 'white' }}> Flip </Text>
</TouchableOpacity>
</View>
);
}
}
Camera facing. Use one of BarCodeScanner.Constants.Type
. Use either Type.front
or Type.back
. Same as Camera.Constants.Type
. Default: Type.back
.
An array of bar code types. Usage: BarCodeScanner.Constants.BarCodeType.<codeType>
where codeType
is one of the listed below. Default: all supported bar code types. For example: barCodeTypes={[BarCodeScanner.Constants.BarCodeType.qr]}
Callback that is invoked when a bar code has been successfully scanned. The callback is provided with an Object of the shape { type: BarCodeScanner.Constants.BarCodeType, data: string }
, where the type refers to the bar code type that was scanned and the data is the information encoded in the bar code (in this case of QR codes, this is often a URL)
Expo.BarCodeScanner.scanFromURLAsync(url, barCodeTypes)
Scan bar codes from the image given by the URL.
Note: Only QR codes are supported on iOS.
A possibly empty array of objects of the shape { type: BarCodeScanner.Constants.BarCodeType, data: string }
, where the type refers to the bar code type that was scanned and the data is the information encoded in the bar code.
FAQs
Allows scanning variety of supported barcodes both as standalone module and as extension for expo-camera. It also allows scanning barcodes from existing images.
The npm package expo-barcode-scanner receives a total of 24,160 weekly downloads. As such, expo-barcode-scanner popularity was classified as popular.
We found that expo-barcode-scanner demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 30 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.