|
@@ -739,7 +739,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
|
|
|
const bgStatus = await Location.getBackgroundPermissionsAsync();
|
|
|
if (bgStatus.status !== 'granted') {
|
|
|
- const { status } = await Location.requestBackgroundPermissionsAsync();
|
|
|
+ const { status } = await requestBackgroundPermissionSafe();
|
|
|
if (status === Location.PermissionStatus.GRANTED) {
|
|
|
await startBackgroundLocationUpdates();
|
|
|
} else {
|
|
@@ -806,6 +806,11 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
}
|
|
|
}, [userInfo]);
|
|
|
|
|
|
+ const requestBackgroundPermissionSafe = async () => {
|
|
|
+ await new Promise((resolve) => setTimeout(resolve, 300));
|
|
|
+ return await Location.requestBackgroundPermissionsAsync();
|
|
|
+ };
|
|
|
+
|
|
|
const handlePress = () => {
|
|
|
if (isExpanded) {
|
|
|
setSearchInput('');
|
|
@@ -865,7 +870,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
|
|
|
const currentZoom = await mapRef.current.getZoom();
|
|
|
setZoom(currentZoom);
|
|
|
-
|
|
|
+
|
|
|
if (mapRef.current) {
|
|
|
const currentCenter = await mapRef.current?.getCenter();
|
|
|
setCenter(currentCenter);
|
|
@@ -1022,7 +1027,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
if (status === 'granted' && isServicesEnabled) {
|
|
|
const bgStatus = await Location.getBackgroundPermissionsAsync();
|
|
|
if (bgStatus.status !== 'granted') {
|
|
|
- const { status } = await Location.requestBackgroundPermissionsAsync();
|
|
|
+ const { status } = await requestBackgroundPermissionSafe();
|
|
|
if (status === Location.PermissionStatus.GRANTED) {
|
|
|
await startBackgroundLocationUpdates();
|
|
|
} else {
|