Skip to content

Commit

Permalink
do not show custom prompt of navigating to setting if user don't allo…
Browse files Browse the repository at this point in the history
…w location permission
  • Loading branch information
cp-ishita-g committed Dec 17, 2024
1 parent 853c381 commit 7751342
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/lib/ui/flow/permission/enable_permission_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ class PermissionViewNotifier extends StateNotifier<PermissionViewState> {
}

Future<void> requestLocationPermission() async {
final permissionState = await permissionService.requestLocationPermission();
final permissionState = await permissionService.requestLocationPermissionStatus();
if (permissionState.isGranted) {
state = state.copyWith(isLocationGranted: true);
} else if (permissionState.isDenied) {
await permissionService.requestLocationPermission();
} else {
state = state.copyWith(showLocationPrompt: DateTime.now());
}
Expand Down
3 changes: 3 additions & 0 deletions data/lib/service/permission_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class PermissionService {
Future<PermissionStatus> requestLocationPermission() async {
return await Permission.location.request();
}
Future<PermissionStatus> requestLocationPermissionStatus() async {
return await Permission.location.status;
}

Future<bool> isBackgroundLocationPermissionGranted() async {
return await Permission.locationAlways.isGranted;
Expand Down

0 comments on commit 7751342

Please sign in to comment.