Issue
I use expo-stream-chat with expo-image-picker.
My app does not need mic permissions so in app.json I explicitly set "microphonePermission": false for expo-image-picker.
I can see the photo icon on msg input. However, when I press on it, it freezes and camera never shows.
The issue is that mediaType is always hardcoded to mixed when calling takeAndUploadImage on iOS:
takeAndUploadImage(Platform.OS === 'android' ? 'image' : 'mixed');
And then used as both 'images', 'videos' in takePhoto:
const mediaTypeMap = {
image: 'images',
mixed: ['images', 'videos'], // Maps to array for expo-image-picker
video: 'videos',
};
const result = await ImagePicker.launchCameraAsync({
mediaTypes: mediaTypeMap[mediaType], // ['images', 'videos'] when mixed
quality: Math.min(Math.max(0, compressImageQuality), 1),
});
Workaround is to override takePhoto:
const takePhotoModule = require("stream-chat-expo/src/optionalDependencies/takePhoto");
const originalTakePhoto = takePhotoModule.takePhoto;
registerNativeHandlers({
takePhoto: originalTakePhoto
? async (options) => originalTakePhoto?.({ ...options, mediaType: "image" })
: undefined,
});
but that's more of a hack since internals of the lib are imported (and require is needed)
Potential solutions:
- Expose
mediaType as setting on expo-stream-chat
- Read
microphonePermission from expo-image-picker and if it is false then pass image instead of mixed
- Especially if (2) is not possible. Then filter out
video inside of expo-image-picker
Note that expo-image-picker supports microphonePermission: false (it was added in expo/expo#29749)
Steps to reproduce
Steps to reproduce the behavior:
- On iOS, go to Chat
- On msg input, click on actions then click on photo icon
Expected behavior
Camera app opens
Project Related Information
Customization
Click To Expand
Offline support
Environment
Click To Expand
package.json:
react-native info output:
- Platform that you're experiencing the issue on:
stream-chat-react-native version you're using that has this issue:
- Device/Emulator info:
Additional context
Screenshots
Click To Expand
Issue
I use
expo-stream-chatwithexpo-image-picker.My app does not need mic permissions so in
app.jsonI explicitly set"microphonePermission": falseforexpo-image-picker.I can see the photo icon on msg input. However, when I press on it, it freezes and camera never shows.
The issue is that
mediaTypeis always hardcoded tomixedwhen callingtakeAndUploadImageon iOS:And then used as both
'images', 'videos'intakePhoto:Workaround is to override
takePhoto:but that's more of a hack since internals of the lib are imported (and
requireis needed)Potential solutions:
mediaTypeas setting on expo-stream-chatmicrophonePermissionfromexpo-image-pickerand if it isfalsethen passimageinstead ofmixedvideoinside ofexpo-image-pickerNote that
expo-image-pickersupportsmicrophonePermission: false(it was added in expo/expo#29749)Steps to reproduce
Steps to reproduce the behavior:
Expected behavior
Camera app opens
Project Related Information
Customization
Click To Expand
Offline support
Environment
Click To Expand
package.json:# N/Areact-native infooutput:stream-chat-react-nativeversion you're using that has this issue:8.12.216.7.10iPhone 8Additional context
Screenshots
Click To Expand