0

I'm developing a react-native app with Expo, and using expo-location for getting a phone's location. Here are all my dependencies, in case there are conflicts unknown to me: Dependencies

In the current setup, I'm using a loading screen to request both foreground and background permissions (and some other things, for example establishing a firebase connection and getting push permissions). After the permissions, a Location.startLocationUpdatesAsync is started, which is what I need these permissions for.

The problems only occur on a real device via Expo Go (device used iPhone 12 mini, iOS 15.3.1). On an iOS Emulator, real and emulated Android devices, none of these problems occur.

If I try to request both location permissions, the app ends in the loading screen, because Location.requestBackgroundPermissionsAsny never resolves with the following error: Error, when asking for backgroundPermission

If I comment the background permission request out, I get the Foreground permission, but I get the following warning: Warning, when only asking for foregroundPermissions

I already included both UIBackgroundModes and UsageDescription in my json. app json

1 Answers1

0

you can try requestforegroundpermissionsasync

  • Asks the user to grant permissions for location while the app is in the foreground.

Example

 let { status } = await Location.requestForegroundPermissionsAsync();
      if (status !== 'granted') {
        setErrorMsg('Permission to access location was denied');
        return;
      }
hong developer
  • 13,291
  • 4
  • 38
  • 68
  • My Task needs to work while the app is in the background as well. I want to send possible Push Notifactions, if the user reaches a location. – CodeCodeCode Feb 23 '22 at 16:37
  • It indeed does request locations permissions but even after allowing, it still shows that the location permissions are not granted – Reznov Oct 01 '22 at 10:41