|
1 | | -# COMMT React Native SDK |
| 1 | +# COMMT: Secure Chat Plugin for React Native |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +<p align="center"> |
| 9 | +<img src="https://commt.co/images/logo/commt-logo.png" width="300" /> |
| 10 | +</p> |
| 11 | +<br /> |
| 12 | + |
| 13 | +Welcome to Commt, a powerful chat plugin designed to seamlessly integrate secure and customizable chat functionalities into your React Native applications. Offering AES encryption as the default and end-to-end (E2E) support, Commt ensures a secure and reliable communication experience for your users. |
| 14 | + |
| 15 | +## Features |
| 16 | +- Written in **TypeScript** |
| 17 | +- Fully customizable pre-build components |
| 18 | +- Multiple projects support with only one client configuration |
| 19 | +- AES encryption as default and end-to-end (E2E) support |
| 20 | +- Webhooks usage flexibility |
| 21 | +- Customizable and easy to manage system messages |
| 22 | +- `Typing`, `user online` and `message read` indicators |
| 23 | +- Emoji keyboard and all emoji types support |
| 24 | +- Hooks usage flexibility |
| 25 | + |
| 26 | +## Installation |
| 27 | + |
| 28 | +- NPM: `npm i -S @commt/commt-rn-sdk` |
| 29 | +- Yarn: `yarn add @commt/commt-rn-sdk` |
| 30 | + |
| 31 | +For detailed installation instructions and configuration options, please refer to our [documentation](https://commt.co/doc). |
| 32 | + |
| 33 | +## Usage |
| 34 | + |
| 35 | +Get started with Commt in just a few steps: |
| 36 | + |
| 37 | +- Initialize Commt: Import the Provider module and set up the chat plugin in your application by wrap your app with it. |
| 38 | +- Customize UI: Tailor the UI elements to match your app's aesthetics. Trigger the `useTheme` hook by passing theme values and make the components custom. |
| 39 | +- Implement Secure Chat: Utilize the secure and encrypted chat functionalities. |
| 40 | + |
| 41 | +Check out our [documentation](https://commt.co/doc) for comprehensive usage examples and API reference. |
| 42 | + |
| 43 | +## Example |
| 44 | + |
| 45 | +You can get client configs info from [Commt Dashboard](https://dashboard.commt.co) |
| 46 | + |
| 47 | +**App.tsx** |
| 48 | +``` |
| 49 | +import CommtProvider from "@commt/commt-rn-sdk"; |
| 50 | +import useInitiate from "@commt/commt-rn-sdk/hooks/useInitiate"; |
| 51 | +
|
| 52 | +const ClientConfig = { |
| 53 | + apiKey: "123456789?", |
| 54 | + subscriptionKey: "0987654321?", |
| 55 | + tenantId: "AD768342asdf?9892", |
| 56 | + secret: "123456789018A_7JzPo?23F+4y#erPL" |
| 57 | +}; |
| 58 | +
|
| 59 | +function App(): JSX.Element { |
| 60 | + useInitiate(ClientConfig); // Initiate a client |
| 61 | +
|
| 62 | + return ( |
| 63 | + <CommtProvider> |
| 64 | + {/* All your ThemeProvider, NavigationContainer, etc. */} |
| 65 | + </CommtProvider> |
| 66 | + ); |
| 67 | +} |
| 68 | +``` |
| 69 | + |
| 70 | +**Home.tsx** |
| 71 | +``` |
| 72 | +import { useSetMessages, useSetRooms, useSetUsers } from "@commt/commt-rn-sdk/hooks"; |
| 73 | +
|
| 74 | +const Home = () => { |
| 75 | + // ... |
| 76 | +
|
| 77 | + useEffect(async () => { |
| 78 | + await useSetUsers(usersArray); // Set users for commt |
| 79 | + await useSetRooms(roomsArray); // Set rooms for commt |
| 80 | + useSetMessages(messagesArray); // Set messages for commt |
| 81 | + }, [usersArray, roomsArray, messagesArray]); |
| 82 | +
|
| 83 | + // ... |
| 84 | +
|
| 85 | + return ( |
| 86 | + <SafeAreaView> |
| 87 | + <Text |
| 88 | + style={styles.buttonText} |
| 89 | + onPress={() => navigation.navigate("Messages")}> |
| 90 | + Go Messages |
| 91 | + </Text> |
| 92 | + </SafeAreaView> |
| 93 | + ); |
| 94 | +}; |
| 95 | +``` |
| 96 | +**Messages-List.tsx** |
| 97 | +``` |
| 98 | +import { |
| 99 | + QuickChat, |
| 100 | + MessageList, |
| 101 | + SearchInput, |
| 102 | + MessagesHeader |
| 103 | +} from "@commt/commt-rn-sdk/components"; |
| 104 | +
|
| 105 | +const Messages = () => { |
| 106 | + // ... |
| 107 | +
|
| 108 | + return ( |
| 109 | + <Container> |
| 110 | + <MessagesHeader /> |
| 111 | + <SearchInput /> |
| 112 | + <InnerContainer> |
| 113 | + <QuickChat onPress={navigateToChat} /> |
| 114 | + <MessageList onPress={navigateToChat} /> |
| 115 | + </InnerContainer> |
| 116 | + </Container> |
| 117 | + ); |
| 118 | +}; |
| 119 | +``` |
| 120 | +<p align="center"> |
| 121 | +<img src="https://commt.co/images/media/Messages-List-Screen.png" width="200" /> |
| 122 | +</p> |
| 123 | + |
| 124 | +**Chat.tsx** |
| 125 | +``` |
| 126 | +import { ChatHeader, Chat } from "@commt/commt-rn-sdk/components"; |
| 127 | +
|
| 128 | +const Chats = () => { |
| 129 | + const route = useRoute<RouteProp<RootStackParamList, "Chats">>(); |
| 130 | + const roomId = route.params.roomId; |
| 131 | + const participants = route.params.participants; |
| 132 | +
|
| 133 | + return ( |
| 134 | + <Container> |
| 135 | + <ChatHeader roomId={roomId} participants={participants} /> |
| 136 | + <Chat |
| 137 | + roomId={roomId} |
| 138 | + participants={participants} |
| 139 | + loadMoreMessages={YOUR_LOAD_MORE_MESSAGES_ACTION} |
| 140 | + /> |
| 141 | + </Container> |
| 142 | + ); |
| 143 | +}; |
| 144 | +``` |
| 145 | + |
| 146 | +<p align="center"> |
| 147 | +<img src="https://commt.co/images/media/Chat-Screen.png" width="200" /> |
| 148 | +</p> |
| 149 | + |
| 150 | +## Compatibility |
| 151 | + |
| 152 | +Commt is compatible with: |
| 153 | + |
| 154 | +- [React Native](https://commt.co/doc#react-native) |
| 155 | +- [ReactJS](https://commt.co/doc#reactjs) |
| 156 | +- [NodeJS](https://commt.co/doc#nodejs) |
| 157 | + |
| 158 | +## Support and Feedback |
| 159 | + |
| 160 | +For any questions, feedback or issues, feel free to reach out to us via <[email protected]>. |
| 161 | + |
| 162 | +## License |
| 163 | + |
| 164 | +[MIT](https://github.com/commt/commt-rn/blob/master/LICENSE) |
| 165 | + |
| 166 | +## Contributors |
| 167 | + |
| 168 | +- Mesut KILINCASLAN [mkilincaslan](https://github.com/mkilincaslan) |
| 169 | +- Sedanur Akçil [sedanurakcil](https://github.com/sedanurakcil) |
0 commit comments