0.1.4 • Published 4 years ago
@goki-lock/react-native-utils v0.1.4
@goki-lock/react-native-utils
Check all requirements & make the app ready to do bluetooth communication
Installation
yarn add @goki-lock/react-native-utilsUsage
import GokiLockUtils, {ErrorCodeType} from '@goki-lock/react-native-utils';Listen to bluetooth state changes
const subscription = GokiLockUtils.addBluetoothStateListener((state) => {
console.log(state);
})Check bluetooth state
GokiLockUtils.getBluetoothState().then((state) => {
console.log(state);
})request to enable bluetooth
GokiLockUtils.requestToEnableBluetooth()open bluetooth settings
GokiLockUtils.openBluetoothSettings()enable/disable bluetooth (Android only)
needs bluetooth admin permission
GokiLockUtils.enableBluetooth()
GokiLockUtils.disableBluetooth()open location source settings (Android only)
GokiLockUtils.openLocationSourceSettings()open app details settings (Android only)
GokiLockUtils.openAppDetailsSettings()check location service is enabled
GokiLockUtils.isLocationServiceEnabled().then((enabled) => {
console.log(enabled);
})check all conditions
GokiLockUtils.checkRequirements({
openLocationSettings: true,
openBluetoothSettings: true,
fixLocation: true,
fixBluetooth: true,
}).then(() => {
})
.catch((error) => {
// error.code = ErrorCodeType
console.log(error);
})related packages
most of native codes are based on following packages