Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

Sensors

Improve this doc

This plugin enables sensors on Android devices

Repo: https://github.com/fabiorogeriosj/cordova-plugin-sensors.git

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add https://github.com/fabiorogeriosj/cordova-plugin-sensors.git
    $ npm install --save @ionic-native/sensors@4
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { Sensors, TYPE_SENSOR } from '@ionic-native/sensors';


constructor(private sensors: Sensors) { }

...


this.sensors.enableSensor(TYPE_SENSOR.LIGHT);

Instance Members

enableSensor(TYPE_SENSOR)

This function enables the sensor

Param Type Details
TYPE_SENSOR string

Specify the sensor to enable

Returns: Promise<any> Returns a promise that resolves when something happens

disableSensor()

This function disables the sensor

Returns: Promise<any> Returns a promise that resolves when something happens

getState()

This function calls the success callback

Returns: Promise<any> Returns sensor state

API

Native

General