const pickImage = async () => {
const { status: cameraStatus } = await ImagePicker.requestCameraPermissionsAsync();
const { status: mediaStatus } = await ImagePicker.requestMediaLibraryPermissionsAsync();
if (cameraStatus !== 'granted' || mediaStatus !== 'granted') {
alert('Lo siento, necesitamos permisos para acceder a la cámara y la galería para continuar.');
return;
}
Alert.alert(
'Seleccionar fuente de imagen',
'¿Desde dónde desea seleccionar la imagen?',
[
{
text: 'Galería',
onPress: async () => {
const result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.All,
allowsEditing: true,
aspect: [4, 3],
quality: 1,
});
if (!result.canceled) {
setImage(result.assets[0].uri);
}
},
},
{
text: 'Cámara',
onPress: async () => {
const result = await ImagePicker.launchCameraAsync({
mediaTypes: ImagePicker.MediaTypeOptions.All,
allowsEditing: true,
aspect: [4, 3],
quality: 1,
});
if (!result.canceled) {
setImage(result.assets[0].uri);
}
},
},
],
{ cancelable: true }
);
};
I have this function that I am using the expo image-picker library, it works fine it selects the images from the gallery or camera but the problem I have is that if I upload the photo with iOS it doesn't show in android and if I upload it with android it doesn't show in iOS.
How can I fix it?
I have already tried everything but I can not get the solution if someone would know why that happens to me, I'm working with firebase and the uri that I get to the database is the following example:
file:///var/mobile/Containers/Data/Application/B83F9F94-B037-4826-BA01-8257644F4BE5/Library/Caches/ExponentExperienceData/%2540anonymous%252Fmy-book-app-1538cc5d-94e3-4e10-8427-e56605d7c3f3/ImagePicker/DCA74DD0-FFB8-40A5-8F9E-694B68DD0D1E. png
I do not know if it has something to do and that the format of both is different.