In iOS, you can get a compass value like this.
window.addEventListener('deviceorientation', function(e) { console.log( e.webkitCompassHeading ); }, false);
Read the Apple DeviceOrientationEvent documentation for more information.
Hope this helps.
Simon arnold
source share