Skip to content

Conversation

@teal-bauer
Copy link
Contributor

Summary

Fixes permission handling so that permissions are requested before the specific actions that need them, rather than failing silently or at unexpected times.

Issues Fixed

  • Scooter pairing: No location permission check before Bluetooth scanning, causing silent failures or unexpected system dialogs
  • Background scanning: Notification permission was requested during service init instead of when user enables the feature
  • Auto-unlock: No permission check before enabling the feature that requires location for proximity detection

Changes

  • Onboarding flow: Added location permission check before Bluetooth scanning
  • Background scanning toggle: Request notification permission when user enables the feature
  • Auto-unlock toggle: Verify location permission before enabling
  • User feedback: Added clear error messages in all languages (en, de, pi) when permissions are denied

Technical Details

  • Location permission is required for Bluetooth scanning on Android 12+
  • Notification permission is required for foreground service notifications
  • All permission checks include mounted guards to prevent BuildContext issues
  • Used existing packages (geolocator, flutter_local_notifications) instead of adding new dependencies

Files Changed

  • lib/onboarding_screen.dart - Permission check before scooter search
  • lib/stats/settings_section.dart - Permission checks for background scan and auto-unlock
  • assets/i18n/*.json - Added translation keys for permission error messages

Testing Checklist

  • First run onboarding with permissions granted
  • First run onboarding with permissions denied
  • Enabling background scanning
  • Enabling auto-unlock feature
  • All error messages display correctly

- Check and request location permissions before Bluetooth scanning in onboarding
- Request notification permissions when enabling background scanning
- Check location permissions before enabling auto-unlock feature
- Add user-friendly error messages for permission denials
- Add translations for permission error messages (en, de, pi)
@teal-bauer
Copy link
Contributor Author

I'm not sure this actually happens in "prod" deployments but with the dev app I keep having the app attempt to scan or bond scooters but never asking for the permission.

@TheFreal TheFreal merged commit 1b02b8a into main Nov 29, 2025
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.

3 participants