Skip to content

Commit 7e50dbf

Browse files
v4.0.8
1 parent 8940e4d commit 7e50dbf

File tree

4 files changed

+150
-133
lines changed

4 files changed

+150
-133
lines changed

CometChat.d.ts

Lines changed: 136 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,6 +1670,12 @@ export class CometChat {
16701670
* @memberof CometChat
16711671
*/
16721672
static getActiveCall(): Call;
1673+
/**
1674+
* Function to clear any active call.
1675+
* @returns {void}
1676+
* @memberof CometChat
1677+
*/
1678+
static clearActiveCall(): void;
16731679
/**
16741680
* Function to start a call.
16751681
* @param {CallSettings | string} callSettings
@@ -1989,31 +1995,64 @@ export class CometChatNotifications {
19891995
static MutedConversationType: typeof MutedConversationType;
19901996
static PushPlatforms: typeof PushPlatforms;
19911997
static DaySchedule: typeof DaySchedule;
1998+
/**
1999+
* @deprecated This property is deprecated as of version 4.0.8 due to newer property 'NotificationPreferences'.
2000+
* It will be removed in subsequent versions.
2001+
*/
19922002
static PushPreferences: typeof PushPreferences;
19932003
static GroupPreferences: typeof GroupPreferences;
19942004
static OneOnOnePreferences: typeof OneOnOnePreferences;
19952005
static MutePreferences: typeof MutePreferences;
19962006
static MutedConversation: typeof MutedConversation;
19972007
static UnmutedConversation: typeof UnmutedConversation;
2008+
static NotificationPreferences: typeof NotificationPreferences;
19982009
/**
19992010
* Function to get preferences set for the logged-in user.
20002011
* @returns {Promise<PushPreferences>}
20012012
* @memberof CometChatNotifications
2013+
* @deprecated
2014+
*
2015+
* This method is deprecated as of version 4.0.8 due to newer method 'fetchPreferences'. It will be removed in subsequent versions.
20022016
*/
20032017
static fetchPushPreferences(): Promise<PushPreferences>;
2018+
/**
2019+
* Function to get preferences set for the logged-in user.
2020+
* @returns {Promise<NotificationPreferences>}
2021+
* @memberof CometChatNotifications
2022+
*/
2023+
static fetchPreferences(): Promise<NotificationPreferences>;
20042024
/**
20052025
* Function to update preferences for the logged-in user.
20062026
* @param {PushPreferences} pushPreferences
20072027
* @returns {Promise<PushPreferences>}
20082028
* @memberof CometChatNotifications
2029+
* @deprecated
2030+
*
2031+
* This method is deprecated as of version 4.0.8 due to newer method 'updatePreferences'. It will be removed in subsequent versions.
20092032
*/
20102033
static updatePushPreferences(pushPreferences: PushPreferences): Promise<PushPreferences>;
2034+
/**
2035+
* Function to update preferences for the logged-in user.
2036+
* @param {NotificationPreferences} notificationPreferences
2037+
* @returns {Promise<NotificationPreferences>}
2038+
* @memberof CometChatNotifications
2039+
*/
2040+
static updatePreferences(notificationPreferences: NotificationPreferences): Promise<NotificationPreferences>;
20112041
/**
20122042
* Function to reset preferences for the logged-in user.
20132043
* @returns {Promise<PushPreferences>}
20142044
* @memberof CometChatNotifications
2045+
* @deprecated
2046+
*
2047+
* This method is deprecated as of version 4.0.8 due to newer method 'resetPreferences'. It will be removed in subsequent versions.
20152048
*/
20162049
static resetPushPreferences(): Promise<PushPreferences>;
2050+
/**
2051+
* Function to reset preferences for the logged-in user.
2052+
* @returns {Promise<NotificationPreferences>}
2053+
* @memberof CometChatNotifications
2054+
*/
2055+
static resetPreferences(): Promise<NotificationPreferences>;
20172056
/**
20182057
* Function to register push token for the current authToken of the logged-in user.
20192058
* @returns {Promise<string>}
@@ -2049,6 +2088,21 @@ export class CometChatNotifications {
20492088
* @memberof CometChatNotifications
20502089
*/
20512090
static getMutedConversations(): Promise<MutedConversation[]>;
2091+
/**
2092+
* Function to update timezone for the logged-in user.
2093+
* @returns {Promise<string>}
2094+
* @param {string} timezone
2095+
* @memberof CometChatNotifications
2096+
*/
2097+
static updateTimezone(timezone: String): Promise<string>;
2098+
/**
2099+
* Function to get timezone for the logged-in user.
2100+
* @returns {Promise<{timezone: string} | string>} A promise that resolves to an object containing the timezone or a string in case of an error.
2101+
* @memberof CometChatNotifications
2102+
*/
2103+
static getTimezone(): Promise<{
2104+
timezone: string;
2105+
} | string>;
20522106
}
20532107

20542108
/**
@@ -4423,6 +4477,8 @@ export class CallController {
44234477
/** @internal */
44244478
onCallStarted(call: Call): Promise<Call>;
44254479
/** @internal */
4480+
clearActiveCall(): void;
4481+
/** @internal */
44264482
endCallSession(): void;
44274483
/** @internal */
44284484
startCall(callsettings: CallSettings, view: HTMLElement): void;
@@ -5188,8 +5244,8 @@ export class ConversationsRequestBuilder {
51885244
/** @private */ WithTags: boolean;
51895245
/** @private */ groupTags: Array<String>;
51905246
/** @private */ userTags: Array<String>;
5191-
/** @private */ includeBlockedUsers: boolean;
5192-
/** @private */ withBlockedInfo: boolean;
5247+
/** @private */ IncludeBlockedUsers: boolean;
5248+
/** @private */ WithBlockedInfo: boolean;
51935249
/**
51945250
*
51955251
* @param {number} limit
@@ -5237,16 +5293,33 @@ export class ConversationsRequestBuilder {
52375293
setUserTags(userTags: Array<String>): this;
52385294
/**
52395295
* A method to include blocked users in the list of conversations.
5240-
* @param {boolean} userTags
5296+
* @param {boolean} _includeBlockedUsers
5297+
* @returns
5298+
* @deprecated This method is deprecated as of version 4.0.8 due to newer method 'includeBlockedUsers'.
5299+
* It will be removed in subsequent versions.
5300+
*/
5301+
setIncludeBlockedUsers(_includeBlockedUsers: boolean): this;
5302+
/**
5303+
* A method to include blocked users in the list of conversations.
5304+
* @param {boolean} _includeBlockedUsers
52415305
* @returns
52425306
*/
5243-
setIncludeBlockedUsers(_includeBlockedUsers: any): this;
5307+
includeBlockedUsers(_includeBlockedUsers: boolean): this;
52445308
/**
52455309
* A method to include blocked users information in the list of conversations.
5246-
* @param {boolean} userTags
5310+
* @param {boolean} _withBlockedInfo
5311+
* @returns
5312+
*
5313+
* @deprecated This method is deprecated as of version 4.0.8 due to newer method 'withBlockedInfo'.
5314+
* It will be removed in subsequent versions.
5315+
*/
5316+
setWithBlockedInfo(_withBlockedInfo: boolean): this;
5317+
/**
5318+
* A method to include blocked users information in the list of conversations.
5319+
* @param {boolean} _withBlockedInfo
52475320
* @returns
52485321
*/
5249-
setWithBlockedInfo(_withBlockedInfo: any): this;
5322+
withBlockedInfo(_withBlockedInfo: boolean): this;
52505323
/**
52515324
* This method will return an object of the ConversationsRequest class.
52525325
* @returns {ConversationsRequest}
@@ -7060,6 +7133,8 @@ export const APIConstants: {
70607133
KEY_MUTED_CONVERSATIONS: string;
70617134
KEY_FROM: string;
70627135
KEY_TO: string;
7136+
KEY_GET_TIMEZONE: string;
7137+
KEY_UPDATE_TIMEZONE: string;
70637138
};
70647139
export const APIResponseConstants: {
70657140
TOKEN_REGISTER_SUCCESS: string;
@@ -7070,6 +7145,9 @@ export const APIResponseConstants: {
70707145
MUTE_CONVERSATION_ERROR: string;
70717146
UNMUTE_CONVERSATION_SUCCESS: string;
70727147
UNMUTE_CONVERSATION_ERROR: string;
7148+
TIMEZONE_UPDATE_SUCCESS: string;
7149+
TIMEZONE_UPDATE_ERROR: string;
7150+
TIMEZONE_FETCH_ERROR: string;
70737151
};
70747152
export const DEFAULT_PROVIDER_ID = "default";
70757153

@@ -7291,6 +7369,54 @@ export class MutePreferences {
72917369
static fromJSON(jsonData: Object): MutePreferences;
72927370
}
72937371

7372+
export class NotificationPreferences {
7373+
/**
7374+
* Get the OneOnOne preferences.
7375+
* @returns {OneOnOnePreferences}
7376+
*/
7377+
getOneOnOnePreferences(): OneOnOnePreferences;
7378+
/**
7379+
* @param {OneOnOnePreferences} oneOnOnePreferences
7380+
* Set the OneOnOne preferences.
7381+
*/
7382+
setOneOnOnePreferences(oneOnOnePreferences: OneOnOnePreferences): void;
7383+
/**
7384+
* Get the Muted preferences.
7385+
* @returns {MutePreferences}
7386+
*/
7387+
getMutePreferences(): MutePreferences;
7388+
/**
7389+
* @param {MutePreferences} mutePreferences
7390+
* Set the Mute preferences.
7391+
*/
7392+
setMutePreferences(mutePreferences: MutePreferences): void;
7393+
/**
7394+
* Get the Group preferences.
7395+
* @returns {GroupPreferences}
7396+
*/
7397+
getGroupPreferences(): GroupPreferences;
7398+
/**
7399+
* @param {GroupPreferences} groupPreferences
7400+
* Set the Group preferences.
7401+
*/
7402+
setGroupPreferences(groupPreferences: GroupPreferences): void;
7403+
/**
7404+
* Returns whether to use privacy template or not.
7405+
* @returns {boolean}
7406+
*/
7407+
getUsePrivacyTemplate(): boolean;
7408+
/**
7409+
* @param {boolean} usePrivacyTemplate
7410+
* Set whether to use privacy template or not.
7411+
*/
7412+
setUsePrivacyTemplate(usePrivacyTemplate: boolean): void;
7413+
/**
7414+
* @param {Object} jsonData
7415+
* Convert JSON object to NotificationPreferences.
7416+
*/
7417+
static fromJSON(jsonData: Object): NotificationPreferences;
7418+
}
7419+
72947420
export class OneOnOnePreferences {
72957421
/**
72967422
* Get the reactions preferences for groups.
@@ -7329,6 +7455,10 @@ export class OneOnOnePreferences {
73297455
static fromJSON(jsonData: Object): OneOnOnePreferences;
73307456
}
73317457

7458+
/**
7459+
* @deprecated This class is deprecated as of version 4.0.8 due to newer class 'NotificationPreferences'.
7460+
* It will be removed in subsequent versions.
7461+
*/
73327462
export class PushPreferences {
73337463
/**
73347464
* Get the OneOnOne preferences.

CometChat.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 12 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -2,134 +2,21 @@
22
<img alt="CometChat" src="https://assets.cometchat.io/website/images/logos/banner.png">
33
</p>
44

5-
# CometChat Javascript SDK
5+
# CometChat SDK for Javascript
6+
The CometChat SDK is a robust toolkit that developers can utilize to swiftly incorporate a reliable and fully-featured chat functionality into an existing or new application. It removes the complexity of building a chat infrastructure from scratch, thus accelerating the development process and reducing time to market.
67

7-
CometChat enables you to add voice, video & text chat for your website & app.
8-
This guide demonstrates how to add chat to a WebSite using CometChat.
8+
## Prerequisites
9+
- [`Visual Studio Code`](https://code.visualstudio.com/) or any other code editor
10+
- [`npm`](https://www.npmjs.com/get-npm)
911

1012

11-
## Prerequisites :star:
12-
Before you begin, ensure you have met the following requirements:<br/>
13-
&nbsp; You have [`Visual Studio Code`](https://code.visualstudio.com/) or any other code editor installed in your machine.<br/>
14-
&nbsp; You have [`npm`](https://www.npmjs.com/get-npm) installed in your machine.<br/>
15-
&nbsp; You have read [CometChat Key Concepts](https://prodocs.cometchat.com/docs/concepts).<br/>
16-
17-
<hr/>
18-
19-
## Installing CometChat Javascript SDK
20-
## Setup :wrench:
21-
22-
To setup Javascript SDK, you need to first register on CometChat Dashboard. [Click here to sign up](https://app.cometchat.com/login).
23-
24-
### i. Get your Application Keys :key:
25-
26-
<a href="https://app.cometchat.io" target="_blank">Signup for CometChat</a> and then:
27-
28-
1. Create a new app: Click **Add App** option available → Enter App Name & other information → Create App
29-
2. At the Top in **QuickStart** section you will find **Auth Key** & **App ID** or else you can head over to the **API & Auth Keys** section and note the **Auth Key** and **App ID**
30-
<img align="center" src="https://files.readme.io/4b771c5-qs_copy.jpg"/>
31-
32-
<hr/>
33-
34-
### ii. Add the CometChat Dependency
35-
<ul>
36-
<li>
37-
<b>Install via NPM</b><br/>
38-
1. Run the following command to install the CometChat Javascript SDK<br/>
39-
40-
```javascript
41-
npm install @cometchat/chat-sdk-javascript@latest --save
42-
```
43-
</li>
44-
45-
<li>
46-
<b>Import via CDN</b><br/>
47-
1. Include the CometChat Javascript library in your HTML code.<br/>
48-
49-
```html
50-
<script type="text/javascript" src="https://unpkg.com/@cometchat/chat-sdk-javascript@latest/CometChat.js"></script>
51-
```
52-
53-
You can refer to the below link for instructions on how to do so:<br/>
54-
[📝 Add CometChat Dependency](https://prodocs.cometchat.com/docs/js-quick-start#add-the-cometchat-dependency)
55-
</li>
56-
</ul>
57-
<hr/>
58-
59-
## Configure CometChat Javascript SDK
60-
61-
### i. Initialize CometChat 🌟
62-
We suggest you call the init() method on app startup, preferably in the index.js file.
63-
64-
```javascript
65-
var appID = "APP_ID";
66-
var region = "REGION";
67-
var appSetting = new CometChat.AppSettingsBuilder().subscribePresenceForAllUsers().setRegion(region).build();
68-
CometChat.init(appID, appSetting).then(
69-
() => {
70-
console.log("Initialization completed successfully");
71-
},
72-
error => {
73-
console.log("Initialization failed with error:", error);
74-
}
75-
);
76-
```
77-
78-
| :information_source: &nbsp; <b> Note: Make sure to replace `region` and `appID` with your credentials.</b> |
79-
|------------------------------------------------------------------------------------------------------------|
80-
81-
### ii. Create User 👤
82-
Once initialisation is successful, you will need to create a user. You need to use createUser() method to create user on the fly.
83-
```javascript
84-
let authKey = "AUTH_KEY";
85-
var uid = "user1";
86-
var name = "Kevin";
87-
88-
var user = new CometChat.User(uid);
89-
90-
user.setName(name);
91-
92-
CometChat.createUser(user, authKey).then(
93-
user => {
94-
console.log("user created", user);
95-
},error => {
96-
console.log("error", error);
97-
}
98-
);
99-
```
100-
>:information_source: <b>Note: Make sure that UID and name are specified as these are mandatory fields to create a user.</b>
101-
<hr/>
102-
103-
### iii. Login User 👤
104-
Once you have created the user successfully, you will need to log the user into CometChat using the login() method.
105-
```javascript
106-
var UID = "SUPERHERO1";
107-
var authKey = "AUTH_KEY";
108-
109-
CometChat.getLoggedinUser().then(
110-
user => {
111-
if(!user){
112-
CometChat.login(UID, authKey).then(
113-
user => {
114-
console.log("Login Successful:", { user });
115-
},
116-
error => {
117-
console.log("Login failed with exception:", { error });
118-
}
119-
);
120-
}else{
121-
// User already logged in
122-
}
123-
}, error => {
124-
console.log("getLoggedinUser failed with exception:", { error });
125-
}
126-
);
127-
```
128-
129-
| :information_source: &nbsp; <b>Note - The login() method needs to be called only once. Also replace `AUTH_KEY` with Auth Key from your app.</b> |
130-
|------------------------------------------------------------------------------------------------------------|
131-
13+
## Getting Started
13214

15+
To set up Javascript SDK and utilize CometChat for your chat and calls functionality, you'll need to follow these steps:
16+
- Register at the [CometChat Dashboard](https://app.cometchat.com/) to create an account.
17+
- After registering, log into your CometChat account and create a new app. Once created, CometChat will generate an Auth Key and App ID for you. Keep these credentials secure as you'll need them later.
18+
- Check the [key concepts](https://cometchat.com/docs/sdk/javascript/key-concepts) to understand the basic components of CometChat.
19+
- Refer to the [Integration Steps](https://cometchat.com/docs/sdk/javascript/setup) in our documentation to integrate the SDK into your app.
13320

13421
## Help and Support
135-
For issues running the project or integrating with our UI Kits, consult our [documentation](https://www.cometchat.com/docs/javascript-chat-sdk/overview) or create a [support ticket](https://help.cometchat.com/hc/en-us) or seek real-time support via the [CometChat Dashboard](https://app.cometchat.com/).
22+
For issues running the project or integrating with our SDK, consult our [documentation](https://www.cometchat.com/docs/sdk/javascript/overview) or create a [support ticket](https://help.cometchat.com/hc/en-us) or seek real-time support via the [CometChat Dashboard](https://app.cometchat.com/).

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cometchat/chat-sdk-javascript",
3-
"version": "4.0.7",
3+
"version": "4.0.8",
44
"description": "A complete chat solution.",
55
"main": "CometChat.js",
66
"scripts": {

0 commit comments

Comments
 (0)