React Native library to check device state. Focused in iOS +8.0 and Android +4.4 for now.
$ npm install react-native-state --save
$ react-native link react-native-state
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-state
and addRNState.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNState.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.ismaeld.RNStatePackage;
to the imports at the top of the file - Add
new RNStatePackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-state' project(':react-native-state').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-state/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-state')
import State from 'react-native-state'
State.isBluetoothEnabled().then(console.log) // true|false
State.isLocationEnabled().then(console.log) // true|false
State.isLocationAuthorized().then(console.log) // true|false
Method | Details | Resolve |
---|---|---|
isBluetoothEnabled | bool | |
isLocationEnabled | Android network and gps location take count. | bool |
isLocationAuthorized | Android always returns true. | bool |
Thanks to dpa99c for the inspiration and cordova plugin. https://github.com/mablack/cordova-diagnostic-plugin
MIT