ayman_rahmon
ayman_rahmon

Reputation: 140

react native expo app ACCESS_BACKGROUND_LOCATION needs to be added to the manifest Problem

i'm building an expo app with the managed flow (so i don't have a direct access to the manifest in android) and i did read and even memorize the documentations and it said that i need to add the permission to the android.permissions in my app.config.json file which i did as follows:

"android": {
  "permissions": [
    "ACCESS_BACKGROUND_LOCATION",
    "ACCESS_COARSE_LOCATION",
    "ACCESS_FINE_LOCATION"
  ]
},

and it's still telling me the same thing , even though according to the doccumentations this is the only thing i need to do to include the permission. but for some reason either the android device is ignoring this or expo is not adding it in the manifest they're building in the background or for whatever reason the app acts just as if i didn't add these lines to the config file.

things i tried :

1- issue raised on github
2- issue raised on expo forums

i also of course read the following

expo permissions docs
android config docs on expo

the code i'm using to ask for the permission:

    try {
// at the following line it just breaks and jumps to the catch block
      const { status } = await Location.requestBackgroundPermissionsAsync();
      console.log(
        "@@@@@@@@@@@@@@@@@@@@@@ requestBackgroundPermissionsAsync @@@@@@@@@@@@@@@@@@@@@@"
      );
      console.log(status);
      console.log(
        "@@@@@@@@@@@@@@@@@@@@@@ requestBackgroundPermissionsAsync @@@@@@@@@@@@@@@@@@@@@@"
      );
      if (status === "granted") // ... the rest of the code

    } catch (error) {
      console.log(error);
    }

the code just breaks with an error at this line and tells me the following :

    You need to add `ACCESS_BACKGROUND_LOCATION` to the AndroidManifest.
at node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:103:50 in promiseMethodWrapper
at node_modules/@unimodules/react-native-adapter/build/NativeModulesProxy.native.js:15:23 in moduleName.methodInfo.name
at node_modules/expo-location/build/Location.js:142:7 in requestBackgroundPermissionsAsync
at node_modules/expo-location/build/Location.js:142:22 in requestBackgroundPermissionsAsync
at screens/home/GoToLocation.tsx:156:25 in onGoToLocation
at http://192.168.8.102:19000/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false&minify=false:191029:39 in onGoToLocation
at node_modules/react-native/Libraries/Pressability/Pressability.js:691:17 in _performTransitionSideEffects
at node_modules/react-native/Libraries/Pressability/Pressability.js:628:6 in _receiveSignal
at node_modules/react-native/Libraries/Pressability/Pressability.js:524:8 in responderEventHandlers.onResponderRelease

the question is : is this like a bug in expo, and they need to fix it or is it something that i'm doing wrong? and if i'm doing something wrong. PLEASE HELP.

Upvotes: 3

Views: 4227

Answers (1)

ayman_rahmon
ayman_rahmon

Reputation: 140

after batteling with it for a couple of days it turned out to be a bug in the new version of the expo go app 2.22.3 which doesn't read or register this type of permission at all . so i just downgraded to the version 2.21.5 and it worked just fine.

this was confirmed by one of expo's maintainers on the issue opened on github

github issue and confirmation

anyways , it seems they're working on it but up until it's fixed just use the older version of the app if you're testing with android.

Upvotes: 5

Related Questions