- SDK Version: 46 (Managed)
- Platforms(Android/iOS/web/all): Android
- expo-image-picker: 13.3.1
- eas-cli: 2.3.0
We are using below code to get image either from Camera or Image Library and followed ImagePicker - Expo Documentation for the same:
import * as ImagePicker from 'expo-image-picker';
const pickImage = async () => {
const hasPermission = await getMediaPermission();
if (hasPermission) {
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
aspect: [4, 3],
base64: true
});
if (!result.cancelled) {
setImage(result);
}
Alert.alert('', result?.uri); // Prints blank uri
}
else {
Alert.alert('Grant Permission', 'Please grant Media Gallery permission.')
}
};
const pickCamera = async () => {
const hasPermission = await getCameraPermission();
if (hasPermission) {
let result = await ImagePicker.launchCameraAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
aspect: [4, 3],
base64: true
});
if (!result.cancelled) {
setImage(result);
}
Alert.alert('', result?.uri); // Prints blank uri
}
else {
Alert.alert('Grant Permission', 'Please grant Camera permission.')
}
};
const getMediaPermission = async () => {
const { status: existingStatus } = await ImagePicker.getMediaLibraryPermissionsAsync();
let finalStatus = existingStatus;
if (existingStatus !== 'granted') {
const { status } = await ImagePicker.requestMediaLibraryPermissionsAsync();
finalStatus = status;
}
return finalStatus === 'granted';
}
const getCameraPermission = async () => {
const { status: existingStatus } = await ImagePicker.getCameraPermissionsAsync();
let finalStatus = existingStatus;
if (existingStatus !== 'granted') {
const { status } = await ImagePicker.requestCameraPermissionsAsync();
finalStatus = status;
}
return finalStatus === 'granted';
}
All works in Expo Go app but does not work in standalone apk or Google Play store published app. result
object returned from both launchImageLibraryAsync
and launchCameraAsync
have empty uri
. We are using EAS to build.
We also tried adding below to app.json
under expo.android
:
"permissions": [
"CAMERA",
"READ_EXTERNAL_STORAGE",
"WRITE_EXTERNAL_STORAGE"
]
and below under expo.plugins
:
[
"expo-image-picker",
{
"photosPermission": "The app needs photos access to add screenshot to support ticket.",
"cameraPermission": "The app needs camera access to add screenshot to support ticket."
}
]