Class DeviceSensorPermissions

java.lang.Object
org.vaadin.firitin.devicemotion.DeviceSensorPermissions

public class DeviceSensorPermissions extends Object
Helper class for handling device sensor permissions (motion and orientation). On iOS 13+, these permissions must be requested from a user-initiated action (click event). This class provides utilities to handle permissions seamlessly.
Author:
mstahv
  • Constructor Details

    • DeviceSensorPermissions

      public DeviceSensorPermissions()
  • Method Details

    • createRequestPermissionButton

      public static com.vaadin.flow.component.button.Button createRequestPermissionButton(String buttonText, DeviceSensorPermissions.SensorType sensorType, Runnable onSuccess, Runnable onError)
      Creates a button that requests the specified permissions on click, then executes the onSuccess callback if permissions are granted.
      Parameters:
      buttonText - the text for the button
      sensorType - which sensor permissions to request
      onSuccess - callback to execute after permissions are granted (on server side)
      onError - callback to execute if permissions are denied (on server side)
      Returns:
      a configured button
    • configurePermissionRequest

      public static void configurePermissionRequest(com.vaadin.flow.component.button.Button button, DeviceSensorPermissions.SensorType sensorType, Runnable onSuccess, Runnable onError)
      Configures an existing button to request permissions on click, then execute the action callback on the server side. This allows seamless integration - clicking the button requests permissions if needed, then executes the intended action.
      Parameters:
      button - the button to configure
      sensorType - which sensor permissions to request
      onSuccess - callback to execute after permissions are granted (on server side)
      onError - callback to execute if permissions are denied (on server side)
    • isPermissionRequired

      public static boolean isPermissionRequired(com.vaadin.flow.component.UI ui, DeviceSensorPermissions.SensorType sensorType)
      Checks if device sensor permissions are required on this platform. Returns true on iOS 13+ Safari.
      Parameters:
      ui - the UI context
      sensorType - which sensor to check
      Returns:
      true if permission request is needed