expo-proximity
v1.1.0
Published
Provides access to the system's proximity sensor.
Downloads
1,428
Maintainers
Readme
expo-proximity
Provides access to the system's proximity sensor.
API documentation
Installation in managed Expo projects
For managed Expo projects, run following command:
npx expo install expo-proximityInstallation in bare React Native projects
For bare React Native projects, you must ensure that you have installed and configured the expo package before continuing.
Add the package to your npm dependencies
npm install expo-proximityConfigure for iOS
Run npx pod-install after installing the npm package.
Configure for Android
API
import {
isAvailableAsync,
getProximityState,
isActivated,
addProximityStateListener,
deactivate,
activate,
useProximity,
} from 'expo-proximity'Hooks
useProximity()
const { proximityState, isActivated } = useProximity()Methods
getProximityState()
Get if an object is near the sensor or not.
Returns: boolean
isActivated()
Get if the sensor is activated or not.
Returns: boolean
addProximityStateListener(listener: (event: ProximityStateChangeEvent) => void)
Method to add a listener on proximity state change event.
Returns: NativeEventSubscription
deactivate()
Method to deactivate the sensor.
Returns: Promise<void>
activate()
Method to activate the sensor.
Returns: Promise<void>
Contributing
Contributions are very welcome! Please refer to guidelines described in the contributing guide.
