react-native-azure-communication-services
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

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


Package Sidebar

Install

npm i react-native-azure-communication-services

Weekly Downloads

0

Version

0.1.2

License

MIT

Unpacked Size

96.2 kB

Total Files

26

Last publish

Collaborators

  • francoding