Skip to content

Conversation

Hoseong-Ryu
Copy link

Summary

Add checkLocationPermissions option to prevent SecurityException on Android 10+ when location permissions are revoked during background service execution.

Problem

Android 10+ throws SecurityException when location permissions are revoked while a foreground service with foregroundServiceType="location" is running.

Solution

  • Added checkLocationPermissions?: boolean option
  • Service validates location permissions before starting on Android 10+
  • Stops gracefully instead of crashing when permissions are missing
  • Fixed boolean parameter passing from JavaScript to Android

Usage

const options = {
  // ... other options
  checkLocationPermissions: true, // Enable permission check
};

BackgroundActions.start(task, options);

Notes

Currently using checkLocationPermissions?: boolean | undefined option to control location permission checks.

Feedback requested: If there's a way to automatically detect foregroundServiceType without requiring additional code, that would be a better solution. Please share any ideas or suggestions you might have.

Ideally, we could automatically determine whether to check location permissions based on the service type, without requiring developers to manually set this option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant