[sensors_plus] Missing permissions requests for accelerometer/gyroscope in Safari
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
- Run the example app from the sensors_plus package on an https web server.
- Access the example web application in Safari through an iPhone/iPad.
Have same issue on Android Chrome 97.0.4692.87. Is there some workaround for this?
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
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
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