Sensors
This plugin enables sensors on Android devices
Repo: https://github.com/fabiorogeriosj/cordova-plugin-sensors.git
Installation
- 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
- Add this plugin to your app's module
Supported platforms
- Android
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