/cordova-plugin-mobile-sensors

Get all mobile sensor info in one plugin [Beta Version]

Primary LanguageObjective-CMIT LicenseMIT

cordova-plugin-mobile-sensors

Get all mobile sensor info in one plugin [Beta Version]

Supported Platforms

  • Android
  • iOS

Installation Steps

This requires cordova ios 4.3.0+ which supports the use of cocoapods.
cordova plugin add https://github.com/NeutrinosPlatform/cordova-plugin-mobile-sensors

The plugin is still in its beta phase and hence has not been published on npm. Once the stable release is out, it will be published.

For Android that is all.

For iOS please also follow the steps below.

  • Once the iOS platform is added in command line, change directory to where podfile is found. Example location :- (myapp/platforms/ios).
  • Make sure you have cocoapods installed then in command line do pod update.
  • Now open myapp.xcworkspace which is usually found in the same directory as the podfile, then build and run.
    Note :- if you use myapp.xcodeproj to build and run, it will not work and it will show a linker error.

Plugin Usage

Currently only one sensor can be functional at once. So to enable a new sensor, User needs to first disable any other sensors that were enabled.

  • Get List of all sensors on the device.
mobsense.getSensorList(success,error);

function success(sensorArray)
{
  console.log(sensorArray);
}

function error(error)
{
  console.log(error);
}
  • Enable the sensor. Common values are ACCELEROMETER, GYROSCOPE, MAGNETIC_FIELD, STEP_COUNTER, GRAVITY. Complete list coming soon!
mobsense.enableSensor("ACCELEROMETER",success,error);

function success(sensorArray)
{
  console.log(sensorArray);
}

function error(error)
{
  console.log(error);
}
  • Disable all sensors.
mobsense.disableSensor(success,error);

function success(sensorArray)
{
  console.log(sensorArray);
}

function error(error)
{
  console.log(error);
}
  • Get raw values of the enabled sensor as an array. Refer to android and ios sensor documentation to understand the unit of the returned values.
mobsense.getState(success,error);

function success(sensorArray)
{
  console.log(sensorArray);
}

function error(error)
{
  console.log(error);
}

More about us

Find out more or contact us directly here :- http://www.neutrinos.co/

Facebook :- https://www.facebook.com/Neutrinos.co/
LinkedIn :- https://www.linkedin.com/company/25057297/
Twitter :- https://twitter.com/Neutrinosco
Instagram :- https://www.instagram.com/neutrinos.co/

N|Solid