Problem on Android (not iOS) with Permissions.askAsync(Permissions.LOCATION)

  1. SDK Version: “^37.0.0”
  2. Platforms(Android/iOS/web/all): Android

I have a weird problem on my Android (simulator and with the .apk also) whereas it works perfectly in iOS.

When I ask Location permission to a user, the app crash directly.

See the code below:

import * as Permissions from "expo-permissions";

const LocationListener = () => {
  useEffect(() => {
    AppState.addEventListener("change", _handleAppStateChange);
    _getLocationAsync();
    return () => {
      AppState.removeEventListener("change", _handleAppStateChange);
    };
  }, []);

  const _handleAppStateChange = nextAppState => {
    if (nextAppState === "active") _getLocationAsync();
  };

  const _getLocationAsync = async () => {
    const { canAskAgain } = await Permissions.getAsync(Permissions.LOCATION);
    ///// PERMISSIONS.GETASYNC IS WORKING

    if (canAskAgain) {
      ///// IF I PUT A CONSOLE.LOG HERE, I CAN SEE IT
      const { status } = await Permissions.askAsync(Permissions.LOCATION);
      ///// THE APP IS CRASHING HERE

      if (status === "granted") {
        try {
          // ...
        } catch (error) {
          // ...
        }
      }
    }
  };
};

Do you know what did I do wrong?

Thank you in advance

Has anybody experienced this issue?

We can close this issue. The real problem was somewhere else :slight_smile: Not related at all with permissions.

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