通过NPM下载插件
$ npm install cmbsdk-react-native --save
主要是自动安装
$ react-native link cmbsdk-react-native
通过添加此信息将组件导入您的反应本应用程序中的组件
从'cmbsdk-reacteNATIDE'导入{cmbreader,cmbcomponent};
您可以通过CMBComponent常数访问所有API方法,并且所有枚举和常数都在CMBreader类中可用。
在继续之前,请从我们的下载部分下载CMBSDK React-Native ZIP文件,并查看API参考。
Download page:https://cmbdn.cognex.com/download
API reference:https://www.npmjs.com/package/cmbsdk-reactnative
确保您从我们的下载页面下载了CMBSDK React-native zip存档。从下载的zip文件中,打开iOS目录。
1.首先,我们需要添加cocoaasyncsocket依赖关系。为此,请打开“依赖关系”目录和“拖放” Xcode中的Cocoaasyncsocket.framework文件。在添加文件弹出窗口上,请确保已选中“如果需要”的“复制项目”,然后在“添加到目标”中检查您的应用程序。如果您使用的是移动设备内置的相机,请使用位于iOS/Resources目录中的“ mwbscannerimages.xcassets”文件进行操作。必威随行版官网
2. Open your targets General settings and add "CocoaAsyncSocket.framework" under "Embedded binaries"
3. In your projects info.plist file you need to add a key depending on the readerDevice type that you are using.
就是这样。您应该能够使用CMBSDK React-Native模块工作来运行应用程序。
确保您从我们的下载页面下载了CMBSDK React-native zip存档。From the downloaded zip file, open the Android/cmbsdk-android-binary directory.
1. Open theyourrnapp/android/app/目录,创建一个名为“ libs”的新文件夹,如果还没有,然后将其打开。将文件“ cmbsdklib-release.aar”放在libs文件夹中。可以在下载的zip文件中找到此AAR
2. Open the app build.gradle located inyourrnapp/android/appand add these lines:
- Above the dependencies add this:
存储库{flatdir {dirs'libs'}}
3.打开构建。yourrnapp/androidand change the minSdkVersion to 19 or above
就是这样。您应该能够使用CMBSDK React-Native模块工作来运行应用程序。