[Unhandled promise rejection: Error: One of the `NSLocation*UsageDescription` keys must be present in Info.plist to be able to use geolocation.]

Viewed 41

I am building an app in expo that tracks a user's background location. When I used requestForegroundPositionAsync() it worked properly, but when I switched to requestBackgroundPositionAsync() I get this error:

[Unhandled promise rejection: Error: One of the `NSLocation*UsageDescription` keys must be present in Info.plist to be able to use geolocation.]
at node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:106:50 in promiseMethodWrapper
at node_modules/expo-modules-core/build/NativeModulesProxy.native.js:15:23 in moduleName.methodInfo.name
at node_modules/expo-location/build/Location.js:228:17 in requestBackgroundPermissionsAsync
at node_modules/expo-location/build/Location.js:227:7 in requestBackgroundPermissionsAsync
at App.tsx:34:10 in onClick
at App.tsx:33:2 in onClick
at App.tsx:52:35 in Button.props.onPress
at node_modules/react-native/Libraries/Pressability/Pressability.js:702:17 in _performTransitionSideEffects
at node_modules/react-native/Libraries/Pressability/Pressability.js:639:6 in _receiveSignal
at node_modules/react-native/Libraries/Pressability/Pressability.js:520:8 in responderEventHandlers.onResponderRelease

Here is the function that requests permission:

 async function onClick() {
    await Location.requestBackgroundPermissionsAsync();
    var location = await Location.getLastKnownPositionAsync();
    var dist = 0;
    setInterval(async () => {
      var obj = await getLocation(location!, dist);
      dist = obj.dist;
      location = obj.location;
    }, 5000);
  }

And here is my ios plist in app.json:

"ios": {
      "supportsTablet": true,
      "infoPlist": {
        "UIBackgroundModes": ["location", "fetch"],
        "NSLocationUsageDescription": "App requires geolocation to improve the quality of the service",
        "NSLocationAlwaysAndWhenInUseUsageDescription": "App requires geolocation to improve the quality of the service",
        "NSLocationWhenInUseUsageDescription": "App requires geolocation to improve the quality of the service",
        "NSLocationAlwaysUsageDescription": "App requires geolocation to improve the quality of the service"
      }
    },

I've taken a look at this post but it was never resolved and this one, but neither were resolved.

0 Answers
Related