0

Is it possible for a web app to gather an iPhone's accelerometer data? If so, how? I would think they might have in the Safari Web browser an API with such functionality.

If it is possible could someone send me a link to pages with specific coding information.

OOProg
  • 189
  • 1
  • 5
  • 16

1 Answers1

2

Found this snippet from here with a bit of Googling.

window.ondevicemotion = function(event) {
  ax = event.accelerationIncludingGravity.x
  ay = event.accelerationIncludingGravity.y
  az = event.accelerationIncludingGravity.z
  rotation = event.rotationRate;
  if (rotation != null) {
    arAlpha = Math.round(rotation.alpha);
    arBeta = Math.round(rotation.beta);
    arGamma = Math.round(rotation.gamma);
  }
} 
Bemmu
  • 17,849
  • 16
  • 76
  • 93