Skip to content

This plugins give cordova native apps to get data from proximity sensor in the device

License

Notifications You must be signed in to change notification settings

DeshanKTD/cordova-plugin-proximity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cordova-plugin-proximity

This plugin can be use to get Proximity sensor data for a app from a device.

The API supports to one time call and repeated calls which will directed to callback functions.

A successful response receive as a JSON, {"distance":5} Most devices generates two values as proximity sensor output. 0 or 5, but 5 can be changed according to the device.

Installation

cordova plugin add https://github.com/DeshanKTD/cordova-plugin-proximity

Methods

  • window.plugin.proximity.getReading
  • window.plugin.proximity.watchReadings
  • window.plugin.proximity.stop

window.plugin.proximity.getReading

This method get a single reading from the proximity sensor


	window.plugin.proximity.getReading(
	    function success(reading){
	      console.log(JSON.stringify(reading)); 
	      alert(JSON.stringify(reading));
	      // Output: {x: 23.113, y:-37.245, z:6.172, magnitude: 44.266}
	    }, 
	    function error(message){
	     console.log(message);
	    }
  	)
  
 

reading object properties:

  • distance

window.plugin.proximity.watchReadings

This helps get reapeated readings from the proximity sensor.

	
		window.plugin.proximity.watchReadings(
		    function success(reading){
		      console.log(JSON.stringify(reading));
		      alert(JSON.stringify(reading)); 
		      // Output: {x: 23.113, y:-37.245, z:6.172, magnitude: 44.266}
		    }, 
		    function error(message){
		     console.log(message);
		    }
		  )
	

reading object properties

  • distance

window.plugin.proximity.stop

Stops gettings readings from the proximity sensor.

	
	  window.plugin.proximity.stop([watchID])
	

Supported Platforms

  • Android

About

This plugins give cordova native apps to get data from proximity sensor in the device

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published