How to use the expo-sensors.Accelerometer.isAvailableAsync function in expo-sensors

To help you get started, we’ve selected a few expo-sensors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github expo / expo / apps / native-component-list / src / screens / AccelerometerScreen.tsx View on Github external
async componentDidMount() {
    if (!(await Accelerometer.isAvailableAsync())) {
      this.setState({
        error:
          'Cannot start demo!' +
          '\nEnable device orientation in Settings > Safari > Motion & Orientation Access' +
          '\nalso ensure that you are hosting with https as DeviceMotion is now a secure API on iOS Safari.',
        isSetup: false,
      });
      return;
    }

    Accelerometer.addListener(({ x, y }) => {
      this.state.items.forEach((_, index) => {
        // All that matters is that the values are the same on iOS, Android, Web, ect...

        const { perspective } = this.props;
        const nIndex = index + 1;
github expo / expo / apps / storybook / stories / APIs / Accelerometer.stories.jsx View on Github external
onPress={async () => {
                      this.setState({
                        isAvailable: await Accelerometer.isAvailableAsync(),
                      });
                    }}>
                    Is Available: {isAvailable ? 'true' : 'false'}
github digidem / mapeo-mobile / src / frontend / sharedComponents / CameraView.js View on Github external
watchAccelerometer() {
    Accelerometer.isAvailableAsync().then(motionAvailable => {
      if (
        !motionAvailable ||
        !this.mounted ||
        this.subscription ||
        AppState.currentState !== "active"
      )
        return;
      Accelerometer.setUpdateInterval(1000);
      this.subscription = Accelerometer.addListener(acc => {
        this.acceleration = acc;
      });
    });
  }
github byCedric / use-expo / packages / sensors / src / use-accelerometer.ts View on Github external
useEffect(() => {
		if (availability) {
			Accelerometer.isAvailableAsync().then(setAvailable);
		}

		if (options.interval !== undefined) {
			Accelerometer.setUpdateInterval(options.interval);
		}

		return Accelerometer.addListener(setData).remove;
	}, []);