
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
react-native-external-scan-gun
Advanced tools
本插件仅测试过外接 USB 扫码枪,其他外接设备若不正常可以在本项目中提 issue
npm install react-native-external-scan-gun
或者
yarn add react-native-external-scan-gun
android/app/src/main/java/[...]/MainApplication.java
文件, 并在文件顶部引入插件包,代码 import com.afei.scangun.ScanGunPackage;
android/app/src/main/java/[...]/MainActivity.java
文件, 并添加如下代码...
import android.view.KeyEvent;
...
import com.afei.scangun.ScanGunManager;
...
public class MainActivity extends ReactActivity {
...
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getKeyCode() != KeyEvent.KEYCODE_BACK && event.getDeviceId() != -1) {
ScanGunManager.getInstance().analysisKeyEvent(event);
return true;
}
return super.dispatchKeyEvent(event);
}
...
}
...
import scanGun from 'react-native-external-scan-gun';
...
useEffect(() => {
const eventEmitter = new NativeEventEmitter(NativeModules.ToastExample);
const eventListener = eventEmitter.addListener(
scanGun.onScanCodeReceiveData,
code => {
// TODO: 扫码之后的回调
},
);
return () => {
// 移除监听事件
eventListener.remove();
};
}, []);
...
以上是基于 expo eject 项目为基础的链接方式,原生项目链接时请参考 React Native
FAQs
基于 react-native 开发的安卓系统外接设备插件
We found that react-native-external-scan-gun demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.