ConnectyCube / connectycube-reactnative-samples

Chat and Video Chat code samples for React Native, ConnectyCube
https://connectycube.com
Apache License 2.0
125 stars 111 forks source link

Whenever i try to use CreateAndUpload i get this error TypeError: Attempted to assign to readonly property. #121

Closed sami3898 closed 3 years ago

sami3898 commented 3 years ago

So i'm using ConnectyCube for Chat in React Native. Normal Messages are working fine but when i try to upload image i'm getting warning and rest of the code is not executing

here is the code of preparing and send attachments

async sendChatWithAttachment() {
        const fileParams = {
            name: this.state.imageArr.filename,
            file: this.state.imageArr.path,
            type: this.state.imageArr.mime,
            size: this.state.imageArr.size
        }
        //alert(JSON.stringify(fileParams))
        await ConnectyCube.storage
        .createAndUpload(fileParams)
        .then(file => {
            alert(JSON.stringify(file))
        })
        .catch(error => {
            alert(JSON.stringify(error))
        });
  }
prepareChatWithAttachment = file => {
        const oppentId = [parseInt(this.state.userData.user.id)]
        const message = {
            type: 'chat',
            body: 'attachment',
            extension: {
                save_to_history: 1,
                dialog_id: this.state.dialogData._id,
                attachments: [{ uid: file.uid, id: file.id, type: "photo" }]
                //attachments: [{ latitude, longitude, type: "place" }]
            }
        }

        message.id = ConnectyCube.chat.send(oppentId, message)
        this.getChatHistory()
        ConnectyCube.chat.onSentMessageCallback = function(messageLost, messageSent) {
            alert(JSON.stringify(messageSent)) 
        };

this is the warning i'm getting

Simulator Screen Shot - iPhone 8 - 2020-09-14 at 16 52 05

React Native Version: 0.61.2 ConnectyCube Version: 2.0.0

DaveLomber commented 3 years ago

Hi @sami3898 , just a quick check - does it work well with latest SDK 3.7.0 ?

sami3898 commented 3 years ago

Hi @sami3898 , just a quick check - does it work well with latest SDK 3.7.0 ?

i did not check yet!! okay i first check with version 3.7.0

but the problem is latest version is not working for IOS, React Native

sami3898 commented 3 years ago

@DaveLomber So now i have check using ConnectyCube Version 3.7.0 in Android still i'm getting same message

sami3898 commented 3 years ago

hey, @DaveLomber @Kachanov-dev any update on this? please I'm stuck at this help me

DaveLomber commented 3 years ago

I guess this line produces an error:

file: this.state.imageArr.path

it seems you pass a string, but SDK expects an object

Please double check it an compare with https://github.com/ConnectyCube/connectycube-reactnative-samples/blob/master/RNChat/src/services/chat-service.js#L273

sami3898 commented 3 years ago

I guess this line produces an error:

file: this.state.imageArr.path

it seems you pass a string, but SDK expects an object

Please double check it an compare with https://github.com/ConnectyCube/connectycube-reactnative-samples/blob/master/RNChat/src/services/chat-service.js#L273

now my file is being uploaded on the server but I didn't get a callback from ConnectyCube.createAndUpload()

DaveLomber commented 3 years ago

@sami3898 please provide SDK logs when you call this method

sami3898 commented 3 years ago

I have solved this. now I'm closing the issue.