Can Rocket.Chat LiveChat be integrated into React Native project?


#21

I created new RN project and installed the sdk. I still have no luck. :frowning: pls see my node and npm versions.

sorry for stupid question but how do i know if my npm is corrupted?


#22

i still get this error.


#23

@diego.mello Do you have any clue about this? It seems like an issue with React Native’s packager.


#24

i got the error when I import this:

import Livechat from '@rocket.chat/sdk/clients/Livechat';


#26

On sdk, running npm install doesn’t seem to install paho-mqtt and yarn does.


#27

hi @diego.mello @tasso.evangelista, it worked using yarn. Thank you both! :slight_smile:

I have another concern though… Hope you can still help me… I can now get the config, register user, get the room and send a message. Now I am trying to implement the new message observer and I can’t get it to work. Maybe there is missing on my end which I don’t know.

Is this the observer for new message?

SDK.onMessage((message) => {
      console.log('Message = ', message);
});

What I am doing is after SDK.config() i call SDK.onMessage() and it does not work… do I have to call SDK.subscribeRoom() first?

Appreciate your help. Thanks :slight_smile:


#28

If I understand it right, in order for the observers like the New Message observer SDK.onMessage() to work, I need to connect first and subscribe to the room, is that correct?

But when I do SDK.connect() I got this error: Malformed calls from JS: field sizes are different.

This is my sample code:

async initRoom(){
        if(!stream){
            stream = await SDK.connect();
        }
        
        SDK.unsubscribeAll();
        SDK.subscribeRoom(roomId);
}

and I am using now the @rocket.chat/sdk@1.0.0-alpha.21

Do you have any idea @diego.mello @tasso.evangelista about the error?


#29

Hi @diego.mello @jmagdada I have taken the git repo of react native rocket chat and after doing npm install the project is build successfully but I also receive paho-mqtt error. And I am not really sure where to run this yarn command… Can you please tell me exactly where to run this command?


#30

@owais The repo uses yarn. npm won’t work.
yarn is a package manager just like npm.
You must install yarn before.

@jmagdada can you try again in @rocket.chat/sdk@1.0.0-alpha.25?
This issue was fixed.


#31

Yes diego… Thanks for your help… I was trying yarn in project root directory… Now it is working fine after running the command in node_modules/@rocket.chat/sdk.