Closed yogitaV-dev closed 4 years ago
Yes, you are able to send/receive any attachment file by the same way as an image attachment. You just have to use react-native libs that would play your video/audio attachments
will you please give me the documentation for audio/video attachment and how can we send it on chat and receive from backend because i am not able to find video/audio attachment doc in connectycube documentation
From or docs: https://developers.connectycube.com/js/messaging?id=attachments
For example you would use use the react-native-document-picker:
import DocumentPicker from 'react-native-document-picker';
import ConnectyCube from 'react-native-connectycube';
...
// For sender
const file = await DocumentPicker.pick({ type: [DocumentPicker.types.allFiles] });
const fileParams = {
file: file,
name: file.name, // or any you want
type: file.type, // mime-type ('video/mp4', 'audio/mp3', 'image/jpeg' etc.)
size: file.size, // bytes (number)
public: false // or true
}
ConnectyCube.storage.createAndUpload(params)
.then(result => {
const message = {
type: "chat",
body: "attachment",
extension: {
save_to_history: 1,
dialog_id: dialog._id,
attachments: [{ uid: result.uid, type: "*" }] // set type you what: 'image', 'video', 'audio' else...
}
};
ConnectyCube.chat.send(opponentId, message);
});
// For receiver
ConnectyCube.chat.onMessageListener = (userId, message) => {
if (message.extension.hasOwnProperty("attachments")) {
if (message.extension.attachments.length > 0) {
const fileUID = message.extension.attachments[0].uid;
const fileType = message.extension.attachments[0].type; //
const fileURL = ConnectyCube.storage.privateUrl(fileUID);
// const fileURL = ConnectyCube.storage.pablicUrl(fileUID); - if fileParams.pablic = true
...
// get file by 'fileURL'
}
}
};
Since there is no activity I’m going to close the issue. Please raise a separate issue in case of any other questions.
Yes, you are able to send/receive any attachment file by the same way as an image attachment. You just have to use react-native libs that would play your video/audio attachments