Skip to content

Commit fc5da65

Browse files
Banyel3claude
andcommitted
feat(customer): prompt to enable location when GPS permission is off
Tapping "Use my current location" with location denied showed a passive error toast. Now it prompts: if iOS can still ask, a simple heads-up; if it was permanently denied, an "Open Settings" action (the only way back). Treats a missing permission as "turn it on", not "you did something wrong". Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent c1f017e commit fc5da65

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

apps/customer-mobile/src/app/book.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { router } from 'expo-router';
22
import * as Location from 'expo-location';
33
import React, { useCallback, useEffect, useMemo, useState } from 'react';
4-
import { Pressable, StyleSheet, Text, TextInput, View } from 'react-native';
4+
import { Alert, Linking, Pressable, StyleSheet, Text, TextInput, View } from 'react-native';
55
import type { AddressView } from '@wash-and-go/domain';
66
import {
77
Card,
@@ -93,9 +93,20 @@ export default function BookScreen() {
9393
const useMyLocation = useCallback(async () => {
9494
setGpsLoading(true);
9595
try {
96-
const { status } = await Location.requestForegroundPermissionsAsync();
96+
const { status, canAskAgain } = await Location.requestForegroundPermissionsAsync();
9797
if (status !== 'granted') {
98-
toast.error('Location permission is needed to set your pickup point.');
98+
// Not an error — prompt them to turn it on. If iOS won't re-ask
99+
// (previously denied), the only way back is Settings, so offer it.
100+
Alert.alert(
101+
'Location is off',
102+
'Turn on location access to drop your pickup pin automatically.',
103+
canAskAgain
104+
? [{ text: 'OK' }]
105+
: [
106+
{ text: 'Not now', style: 'cancel' },
107+
{ text: 'Open Settings', onPress: () => void Linking.openSettings() },
108+
],
109+
);
99110
return;
100111
}
101112
const pos = await Location.getCurrentPositionAsync({

0 commit comments

Comments
 (0)