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
@@ -72,7 +72,10 @@ class _ServiceRequestScreenState extends ConsumerState<ServiceRequestScreen> {
|
||||
Expanded(
|
||||
child: Text(
|
||||
msg,
|
||||
style: AppTextStyles.regular.copyWith(color: Colors.white, fontSize: 12),
|
||||
style: AppTextStyles.regular.copyWith(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 2,
|
||||
),
|
||||
@@ -251,18 +254,31 @@ class _ServiceRequestScreenState extends ConsumerState<ServiceRequestScreen> {
|
||||
|
||||
var status = await permission.status;
|
||||
|
||||
print("status $status");
|
||||
// ⭐ 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(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;
|
||||
|
||||
status = await permission.request();
|
||||
if (status.isGranted || status.isLimited) return true;
|
||||
if (status.isPermanentlyDenied || (Platform.isIOS && status.isDenied)) {
|
||||
|
||||
if (status.isPermanentlyDenied) {
|
||||
await _showSettingsDialog(name);
|
||||
return false;
|
||||
}
|
||||
|
||||
await _showSettingsDialog(name);
|
||||
return false;
|
||||
} catch (e) {
|
||||
debugPrint("Permission error: $e");
|
||||
debugPrint("❌ Permission error: $e");
|
||||
// Fallback to let the picker try on iOS, or return false on Android
|
||||
return Platform.isIOS;
|
||||
}
|
||||
}
|
||||
@@ -611,10 +627,7 @@ class _ServiceRequestScreenState extends ConsumerState<ServiceRequestScreen> {
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
border: Border.all(
|
||||
color: const Color(0xFFDFDFDF),
|
||||
width: 1,
|
||||
),
|
||||
border: Border.all(color: const Color(0xFFDFDFDF), width: 1),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 21),
|
||||
child: Column(
|
||||
|
||||
Reference in new issue
Block a user