requestBackgroundWorkflow static method
- PermissionFlowDelegate? delegate,
- Config? config,
Requests the background permission workflow with rationale hooks.
Implementation
static Future<bool> requestBackgroundWorkflow({
PermissionFlowDelegate? delegate,
Config? config,
}) async {
final whenInUse = await PermissionService.requestWhenInUse();
if (!whenInUse.isGranted) {
return false;
}
final rationale = config?.backgroundPermissionRationale;
if (rationale != null && delegate?.onShowRationale != null) {
final proceed = await delegate!.onShowRationale!(rationale);
if (!proceed) {
return false;
}
}
final always = await PermissionService.requestAlways();
if (!always.isGranted) {
if (delegate?.onOpenSettings != null &&
await Permission.locationAlways.isPermanentlyDenied) {
await delegate!.onOpenSettings!();
}
return false;
}
final activity = await PermissionService.requestActivity();
if (!activity.isGranted) {
return false;
}
if (Platform.isAndroid) {
final notification = await PermissionService.requestNotification();
if (!notification.isGranted) {
return false;
}
}
return true;
}