Asking for location permissions hangs forever on iOS standalone


#1

Permissions.askAsync(Permissions.LOCATION) never resolves on iOS standalone app, and causing app store rejection. Works in iphone simulator, when ran via expo client on iphone device, as well as android devices.

the first alert is seen, but then no alert to ask for permissions nor the one after saying the status.

expo 23.0.6, react-native 0.50.4, iOS 11.2.1

The code:

static async getCurrentLocation() {
        Alert.alert(
            'ABOUT TO ASK FOR LOCATION PERMISSION',
            '',
            [
                {text: 'Yup', onPress: () => null},
            ]
        )
        let { status } = await Permissions.askAsync(Permissions.LOCATION)
        Alert.alert(
            'LOCATION PERMISSION STATUS',
            status,
            [
                {text: 'Yup', onPress: () => null},
            ]
        )
        if (status !== 'granted') {
            return "location error"
        } else {
            let promise = new Promise((resolve, reject) => {
                navigator.geolocation.getCurrentPosition(
                    (position) => {
                        resolve({
                            latitude: position.coords.latitude,
                            longitude: position.coords.longitude
                        })
                    },
                    (error) => {
                        reject("location error")
                    },
                    { timeout: 14000, maximumAge: 100000 },
                )
            })
            return promise
        }
    }```

#2

I have the same problem - it’s been driving me crazy for the last few days. Using SDK 26, React Native Expo build 26


#3

package.json for reference

{
  "name": "App",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "react-native-scripts": "1.5.0",
    "jest-expo": "^25.0.0",
    "react-test-renderer": "16.0.0-alpha.12"
  },
  "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
  "scripts": {
    "start": "react-native-scripts start",
    "eject": "react-native-scripts eject",
    "android": "react-native-scripts android",
    "ios": "react-native-scripts ios",
    "test": "node node_modules/jest/bin/jest.js --watch"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "expo": "^25.0.0",
    "immutable": "^3.8.2",
    "moment": "^2.19.3",
    "moment-range": "^3.1.0",
    "phoenix": "^1.3.0",
    "react": "16.2.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-25.0.0.tar.gz",
    "react-native-animatable": "^1.2.4",
    "react-native-aws3": "0.0.8",
    "react-native-gifted-chat": "^0.3.0",
    "react-native-google-places-autocomplete": "git+https://github.com/Devtron718/react-native-google-places-autocomplete.git",
    "react-native-keyboard-aware-scroll-view": "^0.4.3",
    "react-native-keyboard-spacer": "^0.4.1",
    "react-native-material-ui": "^1.19.0",
    "react-native-sentry": "^0.33.0",
    "react-native-slowlog": "^1.0.2",
    "react-native-spinkit": "^1.1.1",
    "react-native-swipe-gestures": "git+https://github.com/Devtron718/react-native-swipe-gestures.git",
    "react-navigation": "^1.0.0-beta.27",
    "react-redux": "^5.0.6",
    "react-thunk": "^1.0.0",
    "redux": "^3.7.2",
    "redux-logger": "^3.0.6",
    "redux-persist": "^5.4.0",
    "redux-promise": "^0.5.3",
    "redux-thunk": "^2.2.0",
    "sentry-expo": "~1.7.0"
  }
}

#4

It’s hard to say without more info on the code. If it works in dev then it should work in prod unless you added some extra native libraries.
You can debug how the app runs in prod by running

exp start --no-dev --minify

Can you try it with this and let me know if any errors surface.
It’s also worth noting that this permission hasn’t changed in a bit and these incidents seem isolated.


#5

Thanks for your help.

I posted too much code on that original post, I apologize for that. The error doesnt happen when running the app via the expo client (and everything worked as expected when running it in prod mode with the above command). It only happens in iOS standalone apps. There’s also added no native libraries, only JS.

In this code:

async function locationPermission() {
    Alert.alert(
        'ABOUT TO ASK FOR LOCATION PERMISSION',
        '',
        [
            {text: 'Yup', onPress: () => null},
        ]
    )
    let { status } = await Permissions.askAsync(Permissions.LOCATION)
    Alert.alert(
        'LOCATION PERMISSION STATUS',
        status,
        [
            {text: 'Yup', onPress: () => null},
        ]
    )
}

let { status } = await Permissions.askAsync(Permissions.LOCATION) never resolves and hangs indefinitely. If this permission hasnt changed on expo’s side, could this be related to the newer iOS version?


#6

it looks like removing

"ios": {
  "infoPlist": {
    "NSLocationAlwaysUsageDescription": "stuff",
    "NSLocationWhenInUseUsageDescription": "stuff"
  }
}

from my app.json resolved the issue


closed #7

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