sensorsChecker.js

Mostly all recent browsers expose an api for deviceorientation
and devicemotion
events.
- That doesn't mean the device you're on has sensors (accelerometer+gyroscope) to feed them.
- So, to check if the device has sensors, you can't rely on simple feature detection like
"ondeviceorientation" in window
or "ondevicemotion" in window
- This module will let you check if there is really an accelerometer+gyroscope to rely on.
sensorsChecker.checkDeviceorientation(function(){
console.log('sensors detected');
},function(){
console.error('no sensor detected');
}
);
sensorsChecker.checkDevicemotion(function(){
console.log('sensors detected');
},function(){
console.error('no sensor detected');
},{
userAgentCheck: /(iPad|iPhone|Nexus|Mobile|Tablet)/i,
delay: 600
}
);
Used in :
Now available on npm: npm install sensors-checker --save