- SDK Version: “^37.0.0”
- 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