Fix camera permission flow on iOS - 17 Apr 2026
This commit is contained in:
1 parent
d1b4fb344e
commit
ece167ea75
3 files changed
+55
-35
No files matched your search
@@ -45,23 +45,30 @@ class ImagePickerHelper {
|
||||
}
|
||||
|
||||
var status = await permission.status;
|
||||
if (status.isGranted || status.isLimited) return true;
|
||||
|
||||
// On iOS, if already denied, request() won't show anything.
|
||||
// On Android, permanently denied also won't show anything.
|
||||
if (status.isPermanentlyDenied || (Platform.isIOS && status.isDenied)) {
|
||||
await _showSettingsDialog(context, name);
|
||||
return false;
|
||||
// ⭐ Match Live Chat behavior: On iOS, don't force a manual request if already denied
|
||||
// Let ImagePicker handle it, or only show settings dialog if permanently denied.
|
||||
if (Platform.isIOS) {
|
||||
if (status.isPermanentlyDenied) {
|
||||
await _showSettingsDialog(context, name);
|
||||
return false;
|
||||
}
|
||||
return true; // Return true to let ImagePicker try to open and trigger system prompt
|
||||
}
|
||||
|
||||
// Android behavior
|
||||
if (status.isGranted || status.isLimited) return true;
|
||||
|
||||
// Now request permission
|
||||
status = await permission.request();
|
||||
|
||||
if (status.isGranted || status.isLimited) {
|
||||
return true;
|
||||
} else {
|
||||
// If user denied it just now, or it was already denied (iOS)
|
||||
await _showSettingsDialog(context, name);
|
||||
// Only show settings dialog if permanently denied on Android
|
||||
if (status.isPermanentlyDenied) {
|
||||
await _showSettingsDialog(context, name);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
Reference in new issue
Block a user