UNPKG

expo-sensors

Version:

Provides access to a hardware device's accelerometer, gyroscope, magnetometer, and pedometer.

30 lines (25 loc) 796 B
import { ConfigPlugin, createRunOncePlugin, IOSConfig, withPodfileProperties, } from 'expo/config-plugins'; const pkg = require('expo-sensors/package.json'); const MOTION_USAGE = 'Allow $(PRODUCT_NAME) to access your device motion'; const withSensors: ConfigPlugin<{ motionPermission?: string | false } | void> = ( config, { motionPermission } = {} ) => { if (motionPermission === false) { config = withPodfileProperties(config, (config) => { config.modResults.MOTION_PERMISSION = 'false'; return config; }); } return IOSConfig.Permissions.createPermissionsPlugin({ NSMotionUsageDescription: MOTION_USAGE, })(config, { NSMotionUsageDescription: motionPermission, }); }; export default createRunOncePlugin(withSensors, pkg.name, pkg.version);