You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

expo-proximity

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expo-proximity

Provides access to the system's proximity sensor.

1.1.0
latest
Source
npmnpm
Version published
Weekly downloads
70
27.27%
Maintainers
0
Weekly downloads
 
Created
Source

expo-proximity

Provides access to the system's proximity sensor.

API documentation

  • Documentation for the main branch
  • Documentation for the latest stable release

Installation in managed Expo projects

For managed Expo projects, run following command:

npx expo install expo-proximity

Installation 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-proximity

Configure 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.

Keywords

react-native

FAQs

Package last updated on 01 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts