React native Image picker grabs picture with path started with ‘file://’, but CometChat asks for ‘content://’. iOS works well though
Hello @prgnwegiwveinwe,
Can you please share the CometChat SDK version you are using? Also, can you please share your code snippet of image picker and sendMessage()?
Warm Regards,
CometChat Pro
Mayur Bhandari
Thanks for reply.
“@cometchat-pro/react-native-calls”: “^1.0.0”,
“@cometchat-pro/react-native-chat”: “^2.1.0”,
“react”: “16.13.1”,
“react-native”: “0.63.2”,
“react-native-image-crop-picker”: “^0.34.1”,
“react-native-image-picker”: “^2.3.3”,
Snippet:
ImagePicker.showImagePicker(options, (response) => {
if (response.didCancel) {
console.log(‘User cancelled photo picker’);
} else if (response.error) {
console.log('ImagePicker Error: ', response.error);
} else if (response.customButton) {
console.log('User tapped custom button: ', response.customButton);
} else {
console.log(‘ImagePicker Response: ‘, response);
if (Platform.OS === ‘ios’ && response.fileName != undefined) {
var ext = response.fileName.split(’.’)[1].toLowerCase();
var type = getMimeType(ext);
var name = response.fileName;
} else {
var type = response.type;
var name = ‘Camera_001.jpeg’;
}
var file = {
name: Platform.OS === “android” ? response.fileName : name,
type: Platform.OS === “android” ? response.type : type,
uri: Platform.OS === “android” ? response.uri : response.uri.replace(“file://”, “”),
}
console.log('file: ', file);
resolve( file );
}
});
}
At the moment on iOS I receive path format as ''file://", and on Android it is “content://” (with various image pickers I can receive “file://” as well).
But any of these path formats on Android just have been ignored by CometChat.sendMessage method as well as CometChat.sendMediaMessage. This method does not return nothing, not success nor error. iOS works well.
Hello @prgnwegiwveinwe,
Let me check and get this tested on my end and I will get back to you with an update.
Warm Regards,
CometChat Pro
Mayur Bhandari
Hello @prgnwegiwveinwe,
Can you please let me know if you are react-native-image-picker or react-native-image-crop-picker? Since both, the packages are mentioned in the list of packages you have provided above.
Warm Regards,
CometChat Pro
Mayur Bhandari
I tried both of them and they work fine for iOS, but for Android they provide different formats - ‘file://’ and ‘content://’ and both of these formats are ignored by ‘sendMessage’ method. I tried image picker v0.28.1 as in example, but results are still the same. It works in example with RN v61, but refuses with RN v63
Hello @prgnwegiwveinwe,
Can you please share log of the what are you getting in the image picker response. Are there any errors?
Warm Regards,
CometChat Pro
Mayur Bhandari
Hello @prgnwegiwveinwe,
I did test this on my end and i am able to send images using the "react-native-image-crop-picker": "^0.35.0"
with "react-native": "0.61.3"
and "react-native": "0.63.2"
.
Warm Regards,
CometChat Pro
Mayur Bhandari
Hi @prgnwegiwveinwe,
I hope the information shared by Mayur was helpful. I am closing out this ticket due to inactivity. Please feel free to write to us at help@cometchat.com if you require any further assistance.
Regards,
Rahul
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.