![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
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.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.