Ver Fonte

sentry small fix

Viktoriia há 1 dia atrás
pai
commit
db53544b40

+ 7 - 2
src/screens/InAppScreens/MapScreen/FilterModal/index.tsx

@@ -433,6 +433,11 @@ const FilterModal = ({
     }
   };
 
+  const requestBackgroundPermissionSafe = async () => {
+    await new Promise((resolve) => setTimeout(resolve, 300));
+    return await Location.requestBackgroundPermissionsAsync();
+  };
+
   const handleGetLocation = async () => {
     let { status, canAskAgain } = await Location.getForegroundPermissionsAsync();
     const isServicesEnabled = await Location.hasServicesEnabledAsync();
@@ -440,7 +445,7 @@ const FilterModal = ({
     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 {
@@ -488,7 +493,7 @@ const FilterModal = ({
       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 {

+ 8 - 3
src/screens/InAppScreens/MapScreen/index.tsx

@@ -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 {

+ 7 - 2
src/screens/LocationSharingScreen/index.tsx

@@ -151,6 +151,11 @@ const LocationSharingScreen = ({ navigation }: { navigation: any }) => {
     }
   };
 
+  const requestBackgroundPermissionSafe = async () => {
+    await new Promise((resolve) => setTimeout(resolve, 300));
+    return await Location.requestBackgroundPermissionsAsync();
+  };
+
   const handleGetLocation = async (isSettings: boolean) => {
     let { status, canAskAgain } = await Location.getForegroundPermissionsAsync();
     const isServicesEnabled = await Location.hasServicesEnabledAsync();
@@ -159,7 +164,7 @@ const LocationSharingScreen = ({ navigation }: { navigation: any }) => {
       getLocationToggle(isSettings);
       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 {
@@ -220,7 +225,7 @@ const LocationSharingScreen = ({ navigation }: { navigation: any }) => {
       getLocation();
       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 {