$ npm install react-native-smart-config-p --save
or
$ yarn add react-native-smart-config-p --save
CLI autolink featurelinks the module while building the app.
For iOS using
cocoapods**
, run:
$ cd ios/ && pod install`
$ react-native link react-native-smartconfig-p
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-smartconfig-p
and addRnSmartConfigP.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRnSmartConfigP.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Addimport com.phuong.smartconfigp.RnSmartConfigPPackage;
to the imports at the top of the file - Addnew RnSmartConfigPPackage()
to the list returned by thegetPackages()
method - Append the following lines to
android/settings.gradle
:include ':react-native-smartconfig-p' project(':react-native-smartconfig-p').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-smartconfig-p/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:implementation project(':react-native-smartconfig-p')
import SmartConfigP from 'react-native-smartconfig-p';
SmartConfigP.start({
ssid: "WiFi Name",
password: "Password",
bssid: "MAC", // Mac address of Mobile
count: 1, //Number Esp
cast: 'broadcast' // boardcast or multicast
}).then(data => {
console.log(data);
/*[
{
'bssid': 'device-bssi1', //device bssid
'ipv4': '192.168.1.11' //local ip address
},
{
'bssid': 'device-bssi2', //device bssid
'ipv4': '192.168.1.12' //local ip address
},
...
]*/
}).catch(err => {
// if smart config fail after timeout
});
// if want cancle, use:
SmartConfigP.stop();