Skip to content

Commit 7d68759

Browse files
authored
Merge pull request #2 from commt/adj/initialization
Adjustment Initialization
2 parents 449497a + 8a3246e commit 7d68759

File tree

2 files changed

+25
-30
lines changed

2 files changed

+25
-30
lines changed

Readme.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# COMMT: Secure Chat Plugin for React Native
1+
# COMMT: Chat Plugin for React Native
22

3-
![npm](https://img.shields.io/npm/dw/%40commt%2Fcommt-rn-sdk)
4-
![npm](https://img.shields.io/npm/v/%40commt%2Fcommt-rn-sdk)
5-
![NPM](https://img.shields.io/npm/l/%40commt%2Fcommt-rn-sdk?color=blue)
3+
![npm](https://img.shields.io/npm/dw/%40commt%2Frn-sdk)
4+
![npm](https://img.shields.io/npm/v/%40commt%2Frn-sdk)
5+
![NPM](https://img.shields.io/npm/l/%40commt%2Frn-sdk?color=blue)
66

77

88
<p align="center">
99
<img src="https://commt.co/images/logo/commt-logo.png" width="300" />
1010
</p>
1111
<br />
1212

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.
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 real-time communication experience for your users.
1414

1515
## Features
1616
- Written in **TypeScript**
@@ -25,8 +25,8 @@ Welcome to Commt, a powerful chat plugin designed to seamlessly integrate secure
2525

2626
## Installation
2727

28-
- NPM: `npm i -S @commt/commt-rn-sdk`
29-
- Yarn: `yarn add @commt/commt-rn-sdk`
28+
- NPM: `npm i -S @commt/rn-sdk`
29+
- Yarn: `yarn add @commt/rn-sdk`
3030

3131
For detailed installation instructions and configuration options, please refer to our [documentation](https://commt.co/doc/react-native#installation).
3232

@@ -46,14 +46,13 @@ You can get client configs info from [Commt Dashboard](https://dashboard.commt.c
4646

4747
**App.tsx**
4848
```
49-
import CommtProvider from "@commt/commt-rn-sdk";
50-
import useInitiate from "@commt/commt-rn-sdk/hooks/useInitiate";
49+
import CommtProvider from "@commt/rn-sdk";
50+
import { useInitiate } from "@commt/rn-sdk/hooks";
5151
5252
const ClientConfig = {
5353
apiKey: "123456789?",
5454
subscriptionKey: "0987654321?",
55-
tenantId: "AD768342asdf?9892",
56-
secret: "123456789018A_7JzPo?23F+4y#erPL"
55+
secret: "123456789018A_7JzPo?23F+4y#erPL" // This is just and example you don't have to add secret here for initialization
5756
};
5857
5958
function App(): JSX.Element {
@@ -69,7 +68,7 @@ function App(): JSX.Element {
6968

7069
**Home.tsx**
7170
```
72-
import { useSetMessages, useSetRooms, useSetUsers } from "@commt/commt-rn-sdk/hooks";
71+
import { useSetMessages, useSetRooms, useSetUsers } from "@commt/rn-sdk/hooks";
7372
7473
const Home = () => {
7574
// ...
@@ -100,7 +99,7 @@ import {
10099
MessageList,
101100
SearchInput,
102101
MessagesHeader
103-
} from "@commt/commt-rn-sdk/components";
102+
} from "@commt/rn-sdk/components";
104103
105104
const Messages = () => {
106105
// ...
@@ -123,7 +122,7 @@ const Messages = () => {
123122

124123
**Chat.tsx**
125124
```
126-
import { ChatHeader, Chat } from "@commt/commt-rn-sdk/components";
125+
import { ChatHeader, Chat } from "@commt/rn-sdk/components";
127126
128127
const Chats = () => {
129128
const route = useRoute<RouteProp<RootStackParamList, "Chats">>();

service/index.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,22 @@ const project = {
3737
};
3838

3939
export const initiate = async (props: InitiateProps) => {
40-
const { tenantId, apiKey, subscriptionKey } = props;
40+
const { apiKey, subscriptionKey } = props;
4141

4242
try {
43-
const response = await axios.get<ConfigsProps>(
44-
`/api/v1/tenant/config/${tenantId}`,
45-
{
46-
params: {
47-
tenantId,
48-
plugin: true, // This is for backend compatibility
49-
project: project.name, // This is for backend compatibility & analytics
50-
version: project.version, // This is for backend compatibility & analytics
51-
},
52-
headers: {
53-
apiKey,
54-
subscriptionKey,
55-
},
43+
const response = await axios.get<ConfigsProps>(`/api/v1/tenant/config/`, {
44+
params: {
45+
plugin: true, // This is for backend compatibility
46+
project: project.name, // This is for backend compatibility & analytics
47+
version: project.version, // This is for backend compatibility & analytics
5648
},
57-
);
49+
headers: {
50+
apiKey,
51+
subscriptionKey,
52+
},
53+
});
5854

59-
if (response.data.tenantId === tenantId) {
55+
if (response.data.tenantId) {
6056
return response.data;
6157
}
6258

0 commit comments

Comments
 (0)