
Security News
Opengrep Adds Apex Support and New Rule Controls in Latest Updates
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
@cometchat/chat-sdk-javascript
Advanced tools
CometChat Pro enables you to add voice, video & text chat for your website & app. This guide demonstrates how to add chat to a WebSite using CometChat Pro.
Push Notification | Email Notification | SMS Notification | Thumbnail Generation | Link Preview | Rich Media Preview | Voice Transcription | Smart Reply | Message Translation | Emojis | Polls | Reactions | Stickers | Video Broadcasting | Collaborative Documents | Collaborative Whiteboards | Data Masking Filter | Profanity Filter | Image Moderation| Sentiment Analysis | In-flight Message Moderation | Virus & Malware Scanner | XSS Filter
Before you begin, ensure you have met the following requirements:
✅ You have Visual Studio Code
or any other code editor installed in your machine.
✅ You have npm
installed in your machine.
✅ You have read CometChat Key Concepts.
To setup Javascript SDK, you need to first register on CometChat Dashboard. Click here to sign up.
Signup for CometChat and then:
npm install @cometchat-pro/chat@3.0.0-beta1 --save
<script type="text/javascript" src="https://unpkg.com/@cometchat-pro/chat@3.0.0-beta1/CometChat.js"></script>
You can refer to the below link for instructions on how to do so:
📝 Add CometChat Dependency
We suggest you call the init() method on app startup, preferably in the index.js file.
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: Note: Make sure to replace region and appID with your credentials. |
---|
Once initialisation is successful, you will need to create a user. You need to use createUser() method to create user on the fly.
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: Note: Make sure that UID and name are specified as these are mandatory fields to create a user.
Once you have created the user successfully, you will need to log the user into CometChat using the login() method.
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: Note - The login() method needs to be called only once. Also replace AUTH_KEY with your App Auth Key. |
---|
📝 Please refer to our Developer Documentation for more information on how to configure the CometChat Pro SDK and implement various features using the same.
Angular UI Kit | React UI Kit | Vue UI Kit
Thanks to the following people who have contributed to this project: 👨💻 @ajaygajra 👨💻 @mayur-bhandari
Contact us via real time support present in CometChat Dashboard.
FAQs
A complete chat solution.
The npm package @cometchat/chat-sdk-javascript receives a total of 13,156 weekly downloads. As such, @cometchat/chat-sdk-javascript popularity was classified as popular.
We found that @cometchat/chat-sdk-javascript demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 12 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.