react-native-azure-communication-services
v0.1.2
Published
test
Downloads
4
Readme
react-native-azure-communication-services
Used to link azure communication services modules with react native
Installation
npm install react-native-azure-communication-services --save
or
yarn add react-native-azure-communication-services
Refer to:
https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/chat/get-started?tabs=windows&pivots=programming-language-swift
To add configurations for Swift and Android.
Usage
import { initChatClient } from 'react-native-azure-communication-services';
initChatClient(response.data.acsEndpoint, response.data.userToken)
import { createChatThread } from 'react-native-azure-communication-services';
createChatThread(topic, [
{
id: userId,
name: senderDisplayName,
},
])
import { addParticipant } from 'react-native-azure-communication-services';
addParticipant(threadId, userId, userName);
import {
eventKeys,
sendChatMessage,
stopRealTimeNotifications,
startRealTimeNotifications
} from 'react-native-azure-communication-services';
useEffect(() => {
startRealTimeNotifications();
const eventEmitter = new NativeEventEmitter(
NativeModules.AzureCommunicationServices
);
const event = eventEmitter.addListener(
eventKeys.MESSAGE_RECEIVED,
(message) => {
console.log('MESSAGE RECEIVED!', message);
message &&
setMessageHistory((state: string[]) => [...state, message.content]);
}
);
return () => {
stopRealTimeNotifications();
};
}, []);
...
sendChatMessage(threadId, content, senderDisplayName, 'text', {
hasAttachment: 'true',
attachmentUrl: 'https://contoso.com/files/attachment.docx',
});
License
MIT