react-native-wifi-transfer
手机端开启一个http服务器 可以接收局域网上传的文件 保存到app文档中 支持ios和android
Getting started
$ npm install react-native-wifi-transfer --save
Mostly automatic installation
$ react-native link react-native-wifi-transfer
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-wifi-transfer
and addRNWifiTransfer.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNWifiTransfer.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.zt5.wifitrans.RNWifiTransferPackage;
to the imports at the top of the file - Add
new RNWifiTransferPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-wifi-transfer' project(':react-native-wifi-transfer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-wifi-transfer/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-wifi-transfer')
Usage
//导入模块; //接收新文件事件RNWifiTransferEmitter; //开启服务器 直到找到可用端口let port = 10000; { console; RNWifiTransferstartport;};; //关闭服务器RNWifiTransfer;