-
Notifications
You must be signed in to change notification settings - Fork 362
Open
Labels
Description
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
mediaTypeas setting on expo-stream-chat - Read
microphonePermissionfromexpo-image-pickerand if it isfalsethen passimageinstead ofmixed - Especially if (2) is not possible. Then filter out
videoinside ofexpo-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
# N/AOffline support
- I have enabled offline support.
- The feature I'm having does not occur when offline support is disabled. (stripe out if not applicable)
Environment
Click To Expand
package.json:
# N/Areact-native info output:
# N/A
- Platform that you're experiencing the issue on:
- iOS
- Android
- iOS but have not tested behavior on Android
- Android but have not tested behavior on iOS
- Both
stream-chat-react-nativeversion you're using that has this issue:8.12.2
- Device/Emulator info:
- I am using a physical device
- OS version:
16.7.10 - Device:
iPhone 8
Additional context
Screenshots
Click To Expand
Reactions are currently unavailable