plus_plugins icon indicating copy to clipboard operation
plus_plugins copied to clipboard

[sensors_plus] Missing permissions requests for accelerometer/gyroscope in Safari

Open rohrz4nge opened this issue 5 years ago • 4 comments

About this issue

Currently, accessing the accelerometer/gyroscope in Safari on iPhones/iPads, through the sensors_plus web package, does not follow the Safari permissions requests procedure, and thus fails to read the sensor data.

Access to device motion and orientation sensors requires use of the DeviceMotionEvent/DeviceOrientationEvent. Additionally, Safari requires explicit consent from the user by calling DeviceMotionEvent.requestPermission(), according to https://w3c.github.io/deviceorientation/#dom-deviceorientationevent-requestpermission

This function is not defined in all other browsers, so there probably has to be an explicit check for this. Example JS code can be found in the answer at https://stackoverflow.com/questions/56514116/how-do-i-get-deviceorientationevent-and-devicemotionevent-to-work-on-safari. The requestPermissions function is currently not supported by the dart:html package, as per https://github.com/dart-lang/sdk/issues/41337. However it is defined in the js_bindings package, in case this could he added to the sensors_plus package.

System info

Issue occurs on: iOS Plugin name: sensors_plus Plugin version: 1.0.2

Steps to Reproduce

  1. Run the example app from the sensors_plus package on an https web server.
  2. Access the example web application in Safari through an iPhone/iPad.

rohrz4nge avatar Jul 14 '21 23:07 rohrz4nge

Have same issue on Android Chrome 97.0.4692.87. Is there some workaround for this?

artemsivcev avatar Jan 20 '22 09:01 artemsivcev

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days

github-actions[bot] avatar May 31 '22 15:05 github-actions[bot]

Have same issue on Android Chrome 97.0.4692.87. Is there some workaround for this?

Afaik the only workaround is something like what is done here: https://github.com/abegehr/monsterjump/commit/34a098ef980804b89363fde943945595043904a3 So implementing a custom js function for the web page, and calling that function from the web dart code

rohrz4nge avatar May 31 '22 17:05 rohrz4nge

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days

github-actions[bot] avatar Aug 30 '22 00:08 github-actions[bot]