Skip to content

Commit

Permalink
v4.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
mathews-cometchat committed Jul 10, 2024
1 parent 8940e4d commit 7e50dbf
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 133 deletions.
142 changes: 136 additions & 6 deletions CometChat.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,12 @@ export class CometChat {
* @memberof CometChat
*/
static getActiveCall(): Call;
/**
* Function to clear any active call.
* @returns {void}
* @memberof CometChat
*/
static clearActiveCall(): void;
/**
* Function to start a call.
* @param {CallSettings | string} callSettings
Expand Down Expand Up @@ -1989,31 +1995,64 @@ export class CometChatNotifications {
static MutedConversationType: typeof MutedConversationType;
static PushPlatforms: typeof PushPlatforms;
static DaySchedule: typeof DaySchedule;
/**
* @deprecated This property is deprecated as of version 4.0.8 due to newer property 'NotificationPreferences'.
* It will be removed in subsequent versions.
*/
static PushPreferences: typeof PushPreferences;
static GroupPreferences: typeof GroupPreferences;
static OneOnOnePreferences: typeof OneOnOnePreferences;
static MutePreferences: typeof MutePreferences;
static MutedConversation: typeof MutedConversation;
static UnmutedConversation: typeof UnmutedConversation;
static NotificationPreferences: typeof NotificationPreferences;
/**
* Function to get preferences set for the logged-in user.
* @returns {Promise<PushPreferences>}
* @memberof CometChatNotifications
* @deprecated
*
* This method is deprecated as of version 4.0.8 due to newer method 'fetchPreferences'. It will be removed in subsequent versions.
*/
static fetchPushPreferences(): Promise<PushPreferences>;
/**
* Function to get preferences set for the logged-in user.
* @returns {Promise<NotificationPreferences>}
* @memberof CometChatNotifications
*/
static fetchPreferences(): Promise<NotificationPreferences>;
/**
* Function to update preferences for the logged-in user.
* @param {PushPreferences} pushPreferences
* @returns {Promise<PushPreferences>}
* @memberof CometChatNotifications
* @deprecated
*
* This method is deprecated as of version 4.0.8 due to newer method 'updatePreferences'. It will be removed in subsequent versions.
*/
static updatePushPreferences(pushPreferences: PushPreferences): Promise<PushPreferences>;
/**
* Function to update preferences for the logged-in user.
* @param {NotificationPreferences} notificationPreferences
* @returns {Promise<NotificationPreferences>}
* @memberof CometChatNotifications
*/
static updatePreferences(notificationPreferences: NotificationPreferences): Promise<NotificationPreferences>;
/**
* Function to reset preferences for the logged-in user.
* @returns {Promise<PushPreferences>}
* @memberof CometChatNotifications
* @deprecated
*
* This method is deprecated as of version 4.0.8 due to newer method 'resetPreferences'. It will be removed in subsequent versions.
*/
static resetPushPreferences(): Promise<PushPreferences>;
/**
* Function to reset preferences for the logged-in user.
* @returns {Promise<NotificationPreferences>}
* @memberof CometChatNotifications
*/
static resetPreferences(): Promise<NotificationPreferences>;
/**
* Function to register push token for the current authToken of the logged-in user.
* @returns {Promise<string>}
Expand Down Expand Up @@ -2049,6 +2088,21 @@ export class CometChatNotifications {
* @memberof CometChatNotifications
*/
static getMutedConversations(): Promise<MutedConversation[]>;
/**
* Function to update timezone for the logged-in user.
* @returns {Promise<string>}
* @param {string} timezone
* @memberof CometChatNotifications
*/
static updateTimezone(timezone: String): Promise<string>;
/**
* Function to get timezone for the logged-in user.
* @returns {Promise<{timezone: string} | string>} A promise that resolves to an object containing the timezone or a string in case of an error.
* @memberof CometChatNotifications
*/
static getTimezone(): Promise<{
timezone: string;
} | string>;
}

/**
Expand Down Expand Up @@ -4423,6 +4477,8 @@ export class CallController {
/** @internal */
onCallStarted(call: Call): Promise<Call>;
/** @internal */
clearActiveCall(): void;
/** @internal */
endCallSession(): void;
/** @internal */
startCall(callsettings: CallSettings, view: HTMLElement): void;
Expand Down Expand Up @@ -5188,8 +5244,8 @@ export class ConversationsRequestBuilder {
/** @private */ WithTags: boolean;
/** @private */ groupTags: Array<String>;
/** @private */ userTags: Array<String>;
/** @private */ includeBlockedUsers: boolean;
/** @private */ withBlockedInfo: boolean;
/** @private */ IncludeBlockedUsers: boolean;
/** @private */ WithBlockedInfo: boolean;
/**
*
* @param {number} limit
Expand Down Expand Up @@ -5237,16 +5293,33 @@ export class ConversationsRequestBuilder {
setUserTags(userTags: Array<String>): this;
/**
* A method to include blocked users in the list of conversations.
* @param {boolean} userTags
* @param {boolean} _includeBlockedUsers
* @returns
* @deprecated This method is deprecated as of version 4.0.8 due to newer method 'includeBlockedUsers'.
* It will be removed in subsequent versions.
*/
setIncludeBlockedUsers(_includeBlockedUsers: boolean): this;
/**
* A method to include blocked users in the list of conversations.
* @param {boolean} _includeBlockedUsers
* @returns
*/
setIncludeBlockedUsers(_includeBlockedUsers: any): this;
includeBlockedUsers(_includeBlockedUsers: boolean): this;
/**
* A method to include blocked users information in the list of conversations.
* @param {boolean} userTags
* @param {boolean} _withBlockedInfo
* @returns
*
* @deprecated This method is deprecated as of version 4.0.8 due to newer method 'withBlockedInfo'.
* It will be removed in subsequent versions.
*/
setWithBlockedInfo(_withBlockedInfo: boolean): this;
/**
* A method to include blocked users information in the list of conversations.
* @param {boolean} _withBlockedInfo
* @returns
*/
setWithBlockedInfo(_withBlockedInfo: any): this;
withBlockedInfo(_withBlockedInfo: boolean): this;
/**
* This method will return an object of the ConversationsRequest class.
* @returns {ConversationsRequest}
Expand Down Expand Up @@ -7060,6 +7133,8 @@ export const APIConstants: {
KEY_MUTED_CONVERSATIONS: string;
KEY_FROM: string;
KEY_TO: string;
KEY_GET_TIMEZONE: string;
KEY_UPDATE_TIMEZONE: string;
};
export const APIResponseConstants: {
TOKEN_REGISTER_SUCCESS: string;
Expand All @@ -7070,6 +7145,9 @@ export const APIResponseConstants: {
MUTE_CONVERSATION_ERROR: string;
UNMUTE_CONVERSATION_SUCCESS: string;
UNMUTE_CONVERSATION_ERROR: string;
TIMEZONE_UPDATE_SUCCESS: string;
TIMEZONE_UPDATE_ERROR: string;
TIMEZONE_FETCH_ERROR: string;
};
export const DEFAULT_PROVIDER_ID = "default";

Expand Down Expand Up @@ -7291,6 +7369,54 @@ export class MutePreferences {
static fromJSON(jsonData: Object): MutePreferences;
}

export class NotificationPreferences {
/**
* Get the OneOnOne preferences.
* @returns {OneOnOnePreferences}
*/
getOneOnOnePreferences(): OneOnOnePreferences;
/**
* @param {OneOnOnePreferences} oneOnOnePreferences
* Set the OneOnOne preferences.
*/
setOneOnOnePreferences(oneOnOnePreferences: OneOnOnePreferences): void;
/**
* Get the Muted preferences.
* @returns {MutePreferences}
*/
getMutePreferences(): MutePreferences;
/**
* @param {MutePreferences} mutePreferences
* Set the Mute preferences.
*/
setMutePreferences(mutePreferences: MutePreferences): void;
/**
* Get the Group preferences.
* @returns {GroupPreferences}
*/
getGroupPreferences(): GroupPreferences;
/**
* @param {GroupPreferences} groupPreferences
* Set the Group preferences.
*/
setGroupPreferences(groupPreferences: GroupPreferences): void;
/**
* Returns whether to use privacy template or not.
* @returns {boolean}
*/
getUsePrivacyTemplate(): boolean;
/**
* @param {boolean} usePrivacyTemplate
* Set whether to use privacy template or not.
*/
setUsePrivacyTemplate(usePrivacyTemplate: boolean): void;
/**
* @param {Object} jsonData
* Convert JSON object to NotificationPreferences.
*/
static fromJSON(jsonData: Object): NotificationPreferences;
}

export class OneOnOnePreferences {
/**
* Get the reactions preferences for groups.
Expand Down Expand Up @@ -7329,6 +7455,10 @@ export class OneOnOnePreferences {
static fromJSON(jsonData: Object): OneOnOnePreferences;
}

/**
* @deprecated This class is deprecated as of version 4.0.8 due to newer class 'NotificationPreferences'.
* It will be removed in subsequent versions.
*/
export class PushPreferences {
/**
* Get the OneOnOne preferences.
Expand Down
2 changes: 1 addition & 1 deletion CometChat.js

Large diffs are not rendered by default.

137 changes: 12 additions & 125 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,134 +2,21 @@
<img alt="CometChat" src="https://assets.cometchat.io/website/images/logos/banner.png">
</p>

# CometChat Javascript SDK
# CometChat SDK for Javascript
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.

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


## Prerequisites :star:
Before you begin, ensure you have met the following requirements:<br/>
&nbsp; You have [`Visual Studio Code`](https://code.visualstudio.com/) or any other code editor installed in your machine.<br/>
&nbsp; You have [`npm`](https://www.npmjs.com/get-npm) installed in your machine.<br/>
&nbsp; You have read [CometChat Key Concepts](https://prodocs.cometchat.com/docs/concepts).<br/>

<hr/>

## Installing CometChat Javascript SDK
## Setup :wrench:

To setup Javascript SDK, you need to first register on CometChat Dashboard. [Click here to sign up](https://app.cometchat.com/login).

### i. Get your Application Keys :key:

<a href="https://app.cometchat.io" target="_blank">Signup for CometChat</a> and then:

1. Create a new app: Click **Add App** option available → Enter App Name & other information → Create App
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**
<img align="center" src="https://files.readme.io/4b771c5-qs_copy.jpg"/>

<hr/>

### ii. Add the CometChat Dependency
<ul>
<li>
<b>Install via NPM</b><br/>
1. Run the following command to install the CometChat Javascript SDK<br/>

```javascript
npm install @cometchat/chat-sdk-javascript@latest --save
```
</li>

<li>
<b>Import via CDN</b><br/>
1. Include the CometChat Javascript library in your HTML code.<br/>

```html
<script type="text/javascript" src="https://unpkg.com/@cometchat/chat-sdk-javascript@latest/CometChat.js"></script>
```

You can refer to the below link for instructions on how to do so:<br/>
[📝 Add CometChat Dependency](https://prodocs.cometchat.com/docs/js-quick-start#add-the-cometchat-dependency)
</li>
</ul>
<hr/>

## Configure CometChat Javascript SDK

### i. Initialize CometChat 🌟
We suggest you call the init() method on app startup, preferably in the index.js file.

```javascript
var appID = "APP_ID";
var region = "REGION";
var appSetting = new CometChat.AppSettingsBuilder().subscribePresenceForAllUsers().setRegion(region).build();
CometChat.init(appID, appSetting).then(
() => {
console.log("Initialization completed successfully");
},
error => {
console.log("Initialization failed with error:", error);
}
);
```

| :information_source: &nbsp; <b> Note: Make sure to replace `region` and `appID` with your credentials.</b> |
|------------------------------------------------------------------------------------------------------------|

### ii. Create User 👤
Once initialisation is successful, you will need to create a user. You need to use createUser() method to create user on the fly.
```javascript
let authKey = "AUTH_KEY";
var uid = "user1";
var name = "Kevin";

var user = new CometChat.User(uid);

user.setName(name);

CometChat.createUser(user, authKey).then(
user => {
console.log("user created", user);
},error => {
console.log("error", error);
}
);
```
>:information_source: <b>Note: Make sure that UID and name are specified as these are mandatory fields to create a user.</b>
<hr/>
### iii. Login User 👤
Once you have created the user successfully, you will need to log the user into CometChat using the login() method.
```javascript
var UID = "SUPERHERO1";
var authKey = "AUTH_KEY";

CometChat.getLoggedinUser().then(
user => {
if(!user){
CometChat.login(UID, authKey).then(
user => {
console.log("Login Successful:", { user });
},
error => {
console.log("Login failed with exception:", { error });
}
);
}else{
// User already logged in
}
}, error => {
console.log("getLoggedinUser failed with exception:", { error });
}
);
```

| :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> |
|------------------------------------------------------------------------------------------------------------|

## Getting Started

To set up Javascript SDK and utilize CometChat for your chat and calls functionality, you'll need to follow these steps:
- Register at the [CometChat Dashboard](https://app.cometchat.com/) to create an account.
- 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.
- Check the [key concepts](https://cometchat.com/docs/sdk/javascript/key-concepts) to understand the basic components of CometChat.
- Refer to the [Integration Steps](https://cometchat.com/docs/sdk/javascript/setup) in our documentation to integrate the SDK into your app.

## Help and Support
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/).
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/).
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cometchat/chat-sdk-javascript",
"version": "4.0.7",
"version": "4.0.8",
"description": "A complete chat solution.",
"main": "CometChat.js",
"scripts": {
Expand Down

0 comments on commit 7e50dbf

Please sign in to comment.