import React from 'react';
import * as TalkRn from '@talkjs/react-native';
function ChatComponent(props) {
const me = {
id: '123456789',
name: 'Alice',
email: 'alice@example.com',
photoUrl: 'https://talkjs.com/images/avatar-1.jpg',
welcomeMessage: 'Hey there! How are you? :-)',
};
const other = {
id: '987654321',
name: 'Sebastian',
email: 'Sebastian@example.com',
photoUrl: 'https://talkjs.com/images/avatar-5.jpg',
welcomeMessage: 'Hey, how can I help? https://google.com',
};
const conversationBuilder = TalkRn.getConversationBuilder(
TalkRn.oneOnOneId(me, other)
);
conversationBuilder.setParticipant(me);
conversationBuilder.setParticipant(other);
return (
<TalkRn.Session appId="<APP_ID>" me={me}>
<TalkRn.Chatbox conversationBuilder={conversationBuilder} />
</TalkRn.Session>
);
}
<script>
// Synchronize user data and set up
import React from 'react';
import * as TalkRn from '@talkjs/react-native';
function ChatComponent(props) {
const me = {
id: '123456789',
name: 'Alice',
email: 'alice@example.com',
photoUrl: 'https://talkjs.com/images/avatar-1.jpg',
welcomeMessage: 'Hey there! How are you? :-)',
};
const other = {
id: '987654321',
name: 'Sebastian',
email: 'Sebastian@example.com',
photoUrl: 'https://talkjs.com/images/avatar-5.jpg',
welcomeMessage: 'Hey, how can I help? https://google.com',
};
const conversationBuilder = TalkRn.getConversationBuilder(
TalkRn.oneOnOneId(me, other)
);
conversationBuilder.setParticipant(me);
conversationBuilder.setParticipant(other);
return (
<TalkRn.Session appId='YOUR_APP_ID' me={me}>
<TalkRn.Chatbox conversationBuilder={conversationBuilder} />
</TalkRn.Session>
);
}
</script>
Because implementing TalkJS was as fast and easy as it was, we were able to greenlight and move this project along very quickly. Had we not chosen this path, the feature would have either been delayed, or shelved due to the resources needed to implement it.