Error: One of the NSLocation*UsageDescription keys must be present in Info.plist to be able to use geolocation."

  1. SDK Version: 48
  2. Platforms(Android/iOS/web/all): Android, iOS

I’m building an Expo application which requires background location fetching. It is working properly on Android, but on iOS, I receive the error message “Error: One of the NSLocation*UsageDescription keys must be present in Info.plist to be able to use geolocation.” When using Expo Go to run the application on iOS, I do not have the option to enable location “Always.”

Here is my app.json file:

{
  "expo": {
    "name": "***",
    "slug": "***",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "***",
    "userInterfaceStyle": "light",
    "splash": {
      "image": "./assets/logo-transparent.png",
      "backgroundColor": "#566ff9"
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true,
      "splash": {
        "image": "./assets/logo-transparent.png",
        "backgroundColor": "#566ff9"
      },
      "bundleIdentifier": "***",
      "googleServicesFile": "./GoogleService-Info.plist",
      "infoPlist": {
        "NSLocationWhenInUseUsageDescription": "This app needs access to your location to show you nearby places.",
        "NSLocationAlwaysUsageDescription": "This app needs access to your location to show you nearby places.",
        "NSLocationUsageDescription": "This app needs access to your location to show you nearby places.",
        "NSLocationAlwaysAndWhenInUseUsageDescription": "This app needs access to your location to show you nearby places.",
        "UIBackgroundModes": [
          "location",
          "fetch"
        ]
      }
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "***",
        "backgroundColor": "#566ff9"
      },
      "package": "***",
      "googleServicesFile": "./google-services.json",
      "permissions": [
        "ACCESS_FINE_LOCATION",
        "ACCESS_COARSE_LOCATION",
        "READ_EXTERNAL_STORAGE",
        "WRITE_EXTERNAL_STORAGE",
        "ACCESS_NETWORK_STATE",
        "ACCESS_WIFI_STATE",
        "INTERNET",
        "LOCATION",
        "NOTIFICATIONS",
        "BACKGROUND_FETCH",
        "FOREGROUND_SERVICE",
        "ACCESS_BACKGROUND_LOCATION"
      ]
    },
    "plugins": [
      "expo-localization",
      [
        "expo-location",
        {
          "locationAlwaysAndWhenInUsePermission": "Allow *** to use your location.",
          "locationAlwaysPermission": "Allow *** to use your location.",
          "locationWhenInUsePermission": "Allow *** to use your location."
        }
      ]     
    ]
  }
}

Here is my package.json file:

{
  "name": "***",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "@expo/config-plugins": "~6.0.0",
    "@react-native-async-storage/async-storage": "1.17.11",
    "@react-native-community/datetimepicker": "6.7.3",
    "@react-native-firebase/app": "^17.4.2",
    "@react-native-firebase/database": "^17.4.2",
    "@react-navigation/bottom-tabs": "^6.5.7",
    "@react-navigation/drawer": "^6.6.2",
    "@react-navigation/native": "^6.1.6",
    "@react-navigation/native-stack": "^6.9.12",
    "@react-navigation/stack": "^6.3.16",
    "@rneui/themed": "^4.0.0-rc.7",
    "axios": "^1.3.4",
    "expo": "^48.0.0",
    "expo-background-fetch": "~11.1.1",
    "expo-image-multiple-picker": "^4.8.3",
    "expo-image-picker": "~14.1.1",
    "expo-keep-awake": "~12.0.1",
    "expo-linear-gradient": "~12.1.2",
    "expo-localization": "~14.1.1",
    "expo-location": "~15.1.1",
    "expo-media-library": "~15.2.3",
    "expo-notifications": "~0.18.1",
    "expo-radio-button": "^1.0.8",
    "expo-status-bar": "~1.4.4",
    "expo-task-manager": "~11.1.1",
    "firebase": "^9.18.0",
    "i18n-js": "^4.2.3",
    "lottie-react-native": "5.1.4",
    "radio-buttons-react-native-expo": "^1.1.0",
    "react": "18.2.0",
    "react-native": "0.71.8",
    "react-native-action-button": "^2.8.5",
    "react-native-actionsheet": "^2.4.2",
    "react-native-calendars": "^1.1294.0",
    "react-native-dropdown-select-list": "^2.0.4",
    "react-native-gesture-handler": "~2.9.0",
    "react-native-image-zoom-viewer": "^3.0.1",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-linear-gradient": "^2.6.2",
    "react-native-modern-datepicker": "^1.0.0-beta.91",
    "react-native-paper": "^3.12.0",
    "react-native-radio-buttons-group": "^2.3.2",
    "react-native-reanimated": "^2.14.4",
    "react-native-round-flags": "^1.0.4",
    "react-native-safe-area-context": "4.5.0",
    "react-native-screens": "~3.20.0",
    "react-native-svg": "^13.4.0",
    "react-native-swipe-list-view": "^3.2.9",
    "react-native-vector-icons": "^9.2.0",
    "react-navigation": "^4.4.4",
    "react-navigation-material-bottom-tabs": "^2.3.5",
    "save": "^2.9.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0"
  },
  "resolutions": {
    "@expo/config-plugins": "~6.0.0",
    "@expo/prebuild-config": "~6.0.0"
  },
  "private": true
}

I am using the following code to request location permission:

  useEffect(() => {
    const requestPermissions = async () => {
      const foreground = await Location.requestForegroundPermissionsAsync()
      if (foreground.granted) await Location.requestBackgroundPermissionsAsync()
    }
    requestPermissions()
  }, [])

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.