Accelerometer on iBook

Getting accelerometer data has been evolving over several iOS releases.

  • In iOS 11 and below, it was fully possible to get this data without doing anything.
  • iOS 12 required users changing a setting in their iOS Preferences, clearly not ideal.
  • iOS 13 allows developers to explicitly make a call for a user permission prompt. Serving over HTTPS is a secondary requirement as well.

Unfortunately this DeviceMotionEvent.requestPermission() call won’t work in the iBooks environment from what I can tell.

There are folks who have put this call into a WKWebView within a native app and had it work. It appears that a requirement (perhaps a bug) is that a WKUIDelegate must be set on the view for it to work. However it isn’t clear to me if this can work with local content; you may still need to serve the page over HTTPS.