diff --git a/.gitignore b/.gitignore index 722f3e7c4..d8b3254ca 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ __pycache__/ /prompts /docs-comparison-tool /node_modules +/legacy-docs diff --git a/ai-chatbots/ai-bots/bots.mdx b/ai-chatbots/ai-bots/bots.mdx deleted file mode 100644 index b92344118..000000000 --- a/ai-chatbots/ai-bots/bots.mdx +++ /dev/null @@ -1,178 +0,0 @@ ---- -title: "AI Bots" ---- - -AI Bots in CometChat are designed to facilitate conversations with users. Each AI Bot is associated with a specific [AI Instruction](/ai/instructions). - -## Before you begin - - - - - -1. Configure the AI settings through the CometChat dashboard as detailed in the [Overview section](/ai-chatbots/overview). -2. Navigate to AI Bots section and add a new bot by clicking on the **"+"** button. -3. Enter bot details like `UID`, `Avatar`, `Bot name` and assign a `Instruction` from the dropdown. Then "Enable" the bot. -4. These details can be edited by clicking on the three dots. Similarly, you can also delete a bot. - -## How does it work? - -### Direct Conversation - -Users can engage in direct conversations with bots by typing messages or asking questions. Bots respond in real-time, providing relevant information or responses based on their configured personality. - -### Ask for Suggestions in a Conversation - -Users can also request suggestions or recommendations from bots. Bots analyze user input and provide suggestions accordingly. For example, a user may ask a bot for movie recommendations, and the bot will respond with a list of movie suggestions. - - - -Bots Suggestion are request-response based, so they will not know about the previous questions asked when asking for a suggestion. However, an end-user can converse with a Bot in a Direct Conversation. - - - -CometChat AI Bot goes through the messages of a conversation to understand the context of a conversation & answer a question asked to the Bot. The CometChat SDK has a method to ask a question to the CometChat AI Bot. It returns a string response. - -The number of messages to be fetched to generate relevant suggestion is configurable. By default the CometChat AI Bot takes the recent `1000` messages of a conversation. It can be configured to timestamp specific or for unread messages only. - -| Configuration | Value | -| ------------- | ------------------------------------------------------ | -| lastNMessages | This will fetch specific number of messages. | -| fromTimestamp | This will fetch messages from a particular timestamp. | -| toTimestamp | This will fetch messages until a particular timestamp. | -| unreadOnly | This will fetch only the unread messages. | - - - -While using any configuration mentioned above a maximum of **only** `1000` messages will be fetched. - - - -## Implementation - -### SDKs - -To implement AI Bots in the platform of your choice, you may utilize the following code samples: - - - -```js -const receiverId = "UID/GUID"; -const receiverType = "user/group"; -const botUid = "UID"; -const question = "Question for Bot"; -const configuration = { lastNMessages: 100 }; - -CometChat.askBot( - receiverId, - receiverType, - botUid, - question, - configuration -).then( - (answer) => { - console.log("Bot Reply", answer); - }, - (error) => { - console.log("An error occurred while fetching bot response.", error); - } -); -``` - - - - -```java -String receiverId = 'UID/GUID'; -String receiverType = CometChatConstants.RECEIVER_TYPE_USER; //'user/group' -String bootId = ""; //'user/group' -String question = ""; -JSONObject configuration = new JSONObject(); -try { - configuration.put("lastNMessages", 100); -} catch (JSONException e) { - throw new RuntimeException(e); -} - -CometChat.askBot(receiverId, receiverType, bootId, question, configuration, new CometChat.CallbackListener() { - @Override - public void onSuccess(String s) { - Logger.error(TAG, "aiFeature: " + s); - } - - @Override - public void onError(CometChatException e) { - Logger.error(TAG, e.getMessage()); - } -}); -``` - - - - -```kotlin -val receiverId = "UID/GUID" -val receiverType = CometChatConstants.RECEIVER_TYPE_USER // 'user/group' -val bootId = "" -val question = "" -val configuration = JSONObject() - -try { - configuration.put("lastNMessages", 100) -} catch (e: JSONException) { - throw RuntimeException(e) -} - -CometChat.askBot(receiverId, receiverType, bootId, question, configuration, - object : CometChat.CallbackListener() { - override fun onSuccess(s: String) { - Log.e(TAG, "aiFeature: $s") - } - - override fun onError(e: CometChatException) { - Log.e(TAG, e.localizedMessage) - } -})// Click to edit code -``` - - - - -```dart -String receiveId = ""; -String receiverType = CometChatConversationType.user; -String question = ""; -String botID = ""; -Map configuration = { "lastNMessages": 100 }; - -CometChat.askBot(receiveId, receiverType, botID, question, configuration: configuration, onSuccess: (String assistance) { - debugPrint("askBot assistance success: ==>>> 3.1: $assistance"); -}, onError: (CometChatException e) { - debugPrint("askBot assistance failed: ==>>> 4: $e"); -}); -``` - - - - -```swift -let receiverId = "" -let receiverType = CometChat.ReceiverType.group -let configuration = [ "lastNMessages": 100 ] -let botId = "" -let question = "" - -CometChat.askBot(receiverId: receiverId, receiverType: receiverType, botID: botId, question: question, configuration: configuration) { suggestion in - print("askBot Success: \(suggestion)") -} onError: { error in - print("askBot error") -} -``` - - - - - -### UI Kits - -Assuming the necessary pre-requisites are met, AI Bots function seamlessly in the latest v4 Chat UI Kits. diff --git a/ai-chatbots/ai-bots/instructions.mdx b/ai-chatbots/ai-bots/instructions.mdx deleted file mode 100644 index ef1148586..000000000 --- a/ai-chatbots/ai-bots/instructions.mdx +++ /dev/null @@ -1,51 +0,0 @@ ---- -title: "AI Instructions" ---- - -CometChat AI Instructions can be linked to a bot to confer specific characteristics upon it. - -## Default Instructions - -* Login to your [CometChat dashboard](https://app.cometchat.com/login) and choose your app. -* Navigate to **AI Agents** > **Custom Bots** > **AI Instructions** in the left-hand menu. - - - - - -By default we create 8 instructions. These instructions are as below: - -1. English Coach -2. Travel Guide -3. Motivational Coach -4. Relationship Coach -5. Life Coach -6. Career Counselor -7. Personal Trainer -8. Mental Health Adviser - - - -The default instructions cannot be edited or deleted. - - - -## Adding new instructions - -Add new instructions by clicking on "+" icon. - - - - - -Configure the instruction by giving it a name and an appropriate prompt. - -This prompt enables you to add a unique instruction to a CometChat Bot. Providing a brief description of its character, tone, or style will be helpful. You can refer to our Default Instructions to understand how you can create a custom instruction that suits your use case. - -Newly added instructions can be edited as well as deleted. - - - -Instructions are soft-deleted to avoid issues when a instruction is attached to a particular bot. - - diff --git a/ai-chatbots/ai-bots/overview.mdx b/ai-chatbots/ai-bots/overview.mdx deleted file mode 100644 index 552654f59..000000000 --- a/ai-chatbots/ai-bots/overview.mdx +++ /dev/null @@ -1,38 +0,0 @@ ---- -title: "Overview" ---- - -## AI-Enabled Messaging Experience - -For users seeking guidance or insights from automated assistants, the **AI Bots** and **Ask Bot** features are designed to maintain conversational momentum. - -## Pre-requisite - -* Login to your [CometChat dashboard](https://app.cometchat.com/login) and choose your app. -* Navigate to **AI Agents** > **Custom Bots** > **AI Bots** in the left-hand menu. - - - - - -### Set the GPT Model - -Enter the name of the Open AI ChatGPT model that you intend to use. - -### Save the Open AI Key - -You can get the Open AI Key from your [Open AI Account](https://platform.openai.com/account/api-keys). This will be used by CometChat to interact with the Open AI APIs. - -### Set a Custom Instruction - -Custom Instruction is an information which gets added in each and every ChatGPT prompt made by the CometChat AI. Custom Instruction is app-level information you can add to describe your use-case & inform what kind of responses you need from the CometChat AI. - -### Set the Temperature - -The API is non-deterministic by default. This means that you might get a slightly different completion every time you call it, even if your prompt stays the same. Setting temperature to 0 will make the outputs mostly deterministic, but a small amount of variability will remain. - -Lower values for temperature result in more consistent outputs, while higher values generate more diverse and creative results. Select a temperature value based on the desired trade-off between coherence and creativity for your specific application. - -### Enable AI - -Toggle on AI. diff --git a/docs.json b/docs.json index 25b4ec400..5ce54fa36 100644 --- a/docs.json +++ b/docs.json @@ -220,8 +220,7 @@ "pages": [ "fundamentals/webhooks-overview", "fundamentals/webhooks-management", - "fundamentals/webhooks-events", - "fundamentals/webhooks-legacy" + "fundamentals/webhooks-events" ] }, { @@ -253,13 +252,7 @@ "pages": [ "/widget/html/overview", "/widget/html/integration", - "/widget/html/advanced", - { - "group": " ", - "pages": [ - "/widget/html/legacy" - ] - } + "/widget/html/advanced" ] }, { @@ -267,13 +260,7 @@ "icon": "/images/icons/wordpress.svg", "pages": [ "/widget/wordpress/overview", - "/widget/wordpress/integration", - { - "group": " ", - "pages": [ - "/widget/wordpress/legacy" - ] - } + "/widget/wordpress/integration" ] }, { @@ -938,7 +925,7 @@ "icon": "/images/icons/react.svg", "versions": [ { - "version": "v5\u200e", + "version": "v5‎", "groups": [ { "group": " ", @@ -1049,7 +1036,7 @@ ] }, { - "version": "v4\u200e", + "version": "v4‎", "groups": [ { "group": " ", @@ -1212,7 +1199,7 @@ ] }, { - "version": "v3\u200e", + "version": "v3‎", "groups": [ { "group": " ", @@ -1234,7 +1221,7 @@ ] }, { - "version": "v2\u200e", + "version": "v2‎", "groups": [ { "group": " ", @@ -1262,7 +1249,7 @@ "icon": "/images/icons/swift.svg", "versions": [ { - "version": "v5\u200e\u200e", + "version": "v5‎‎", "groups": [ { "group": " ", @@ -1369,7 +1356,7 @@ ] }, { - "version": "v4\u200e\u200e", + "version": "v4‎‎", "groups": [ { "group": " ", @@ -1533,7 +1520,7 @@ ] }, { - "version": "v3\u200e\u200e", + "version": "v3‎‎", "groups": [ { "group": " ", @@ -1555,7 +1542,7 @@ ] }, { - "version": "v2\u200e\u200e", + "version": "v2‎‎", "groups": [ { "group": " ", @@ -1583,7 +1570,7 @@ "icon": "/images/icons/android.svg", "versions": [ { - "version": "v5\u200e\u200e\u200e", + "version": "v5‎‎‎", "groups": [ { "group": " ", @@ -1700,7 +1687,7 @@ ] }, { - "version": "v6\u200e\u200e\u200e", + "version": "v6‎‎‎", "groups": [ { "group": " ", @@ -1813,7 +1800,7 @@ ] }, { - "version": "v4\u200e\u200e\u200e", + "version": "v4‎‎‎", "groups": [ { "group": " ", @@ -1970,7 +1957,7 @@ ] }, { - "version": "v3\u200e\u200e\u200e", + "version": "v3‎‎‎", "groups": [ { "group": " ", @@ -1995,7 +1982,7 @@ ] }, { - "version": "v2\u200e\u200e\u200e", + "version": "v2‎‎‎", "groups": [ { "group": " ", @@ -2024,7 +2011,7 @@ "icon": "/images/icons/flutter.svg", "versions": [ { - "version": "v5\u200e\u200e\u200e\u200e", + "version": "v5‎‎‎‎", "groups": [ { "group": " ", @@ -2128,7 +2115,7 @@ ] }, { - "version": "v6\u200e\u200e\u200e\u200e", + "version": "v6‎‎‎‎", "groups": [ { "group": " ", @@ -2242,7 +2229,7 @@ ] }, { - "version": "v4\u200e\u200e\u200e\u200e", + "version": "v4‎‎‎‎", "groups": [ { "group": " ", @@ -2803,7 +2790,7 @@ ] }, { - "version": "v3\u200e\u200e\u200e\u200e\u200e", + "version": "v3‎‎‎‎‎", "groups": [ { "group": " ", @@ -2824,7 +2811,7 @@ ] }, { - "version": "v2\u200e\u200e\u200e\u200e\u200e", + "version": "v2‎‎‎‎‎", "groups": [ { "group": " ", @@ -2851,7 +2838,7 @@ "icon": "/images/icons/vuejs.svg", "versions": [ { - "version": "v4\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v4‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -2944,7 +2931,7 @@ ] }, { - "version": "v3\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v3‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -2966,7 +2953,7 @@ ] }, { - "version": "v2\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v2‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -2998,7 +2985,7 @@ "icon": "/images/icons/js.svg", "versions": [ { - "version": "v4\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v4‎‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -3091,7 +3078,7 @@ ] }, { - "version": "v3\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v3‎‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -3214,7 +3201,7 @@ ] }, { - "version": "v2\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v2‎‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -3317,7 +3304,7 @@ "icon": "/images/icons/react.svg", "versions": [ { - "version": "v4\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v4‎‎‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -3405,7 +3392,7 @@ ] }, { - "version": "v3\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v3‎‎‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -3519,7 +3506,7 @@ ] }, { - "version": "v2\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v2‎‎‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -3621,7 +3608,7 @@ "icon": "/images/icons/swift.svg", "versions": [ { - "version": "v4\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v4‎‎‎‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -3710,7 +3697,7 @@ ] }, { - "version": "v3\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v3‎‎‎‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -3828,7 +3815,7 @@ ] }, { - "version": "v2\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v2‎‎‎‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -3935,7 +3922,7 @@ "icon": "/images/icons/android.svg", "versions": [ { - "version": "v5\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v5‎‎‎‎‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -4036,7 +4023,7 @@ ] }, { - "version": "v4\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v4‎‎‎‎‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -4130,7 +4117,7 @@ ] }, { - "version": "v3\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v3‎‎‎‎‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -4250,7 +4237,7 @@ ] }, { - "version": "v2\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v2‎‎‎‎‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -4353,7 +4340,7 @@ "icon": "/images/icons/flutter.svg", "versions": [ { - "version": "v4\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v4‎‎‎‎‎‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -4445,7 +4432,7 @@ ] }, { - "version": "v5\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v5‎‎‎‎‎‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -4536,7 +4523,7 @@ ] }, { - "version": "v3\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v3‎‎‎‎‎‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -4637,313 +4624,14 @@ ] }, { - "dropdown": "Ionic (Deprecated)", + "dropdown": "Ionic (Legacy)", "icon": "/images/icons/ionic.svg", - "versions": [ - { - "version": "v4\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", - "groups": [ - { - "group": " ", - "pages": [ - { - "group": "Overview", - "pages": [ - "sdk/ionic-legacy/overview", - "sdk/ionic-legacy/key-concepts", - "sdk/ionic-legacy/message-structure-and-hierarchy", - "sdk/ionic-legacy/rate-limits" - ] - }, - "sdk/ionic-legacy/setup", - { - "group": "Authentication", - "pages": [ - "sdk/ionic-legacy/authentication", - "sdk/ionic-legacy/login-listeners" - ] - }, - { - "group": "Messaging", - "pages": [ - "sdk/ionic-legacy/messaging-overview", - "sdk/ionic-legacy/send-message", - "sdk/ionic-legacy/receive-messages", - "sdk/ionic-legacy/additional-message-filtering", - "sdk/ionic-legacy/retrieve-conversations", - "sdk/ionic-legacy/threaded-messages", - "sdk/ionic-legacy/edit-message", - "sdk/ionic-legacy/delete-message", - "sdk/ionic-legacy/delete-conversation", - "sdk/ionic-legacy/typing-indicators", - "sdk/ionic-legacy/interactive-messages", - "sdk/ionic-legacy/transient-messages", - "sdk/ionic-legacy/delivery-read-receipts", - "sdk/ionic-legacy/mentions", - "sdk/ionic-legacy/reactions" - ] - }, - { - "group": "Users", - "pages": [ - "sdk/ionic-legacy/users-overview", - "sdk/ionic-legacy/retrieve-users", - "sdk/ionic-legacy/user-management", - "sdk/ionic-legacy/block-users" - ] - }, - "sdk/ionic-legacy/user-presence", - { - "group": "Groups", - "pages": [ - "sdk/ionic-legacy/groups-overview", - "sdk/ionic-legacy/retrieve-groups", - "sdk/ionic-legacy/create-group", - "sdk/ionic-legacy/update-group", - "sdk/ionic-legacy/join-group", - "sdk/ionic-legacy/leave-group", - "sdk/ionic-legacy/delete-group", - "sdk/ionic-legacy/retrieve-group-members", - "sdk/ionic-legacy/group-add-members", - "sdk/ionic-legacy/group-kick-member", - "sdk/ionic-legacy/group-change-member-scope", - "sdk/ionic-legacy/transfer-group-ownership" - ] - }, - { - "group": "Resources", - "pages": [ - "sdk/ionic-legacy/resources-overview", - "sdk/ionic-legacy/real-time-listeners", - "sdk/ionic-legacy/upgrading-from-v3-guide" - ] - }, - { - "group": "Advanced", - "pages": [ - "sdk/ionic-legacy/advanced", - "sdk/ionic-legacy/connection-status", - "sdk/ionic-legacy/connection-behaviour", - "sdk/ionic-legacy/managing-connections-manually" - ] - }, - "sdk/ionic-legacy/extensions-overview", - "sdk/ionic-legacy/ai-user-copilot-overview", - "sdk/ionic-legacy/ai-chatbots-overview", - "sdk/ionic-legacy/webhooks-overview", - "sdk/ionic-legacy/changelog" - ] - } - ] - }, - { - "version": "v3\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", - "groups": [ - { - "group": " ", - "pages": [ - { - "group": "Overview", - "pages": [ - "sdk/ionic-legacy/3.0/overview", - "sdk/ionic-legacy/3.0/key-concepts", - "sdk/ionic-legacy/3.0/message-structure-and-hierarchy", - "sdk/ionic-legacy/3.0/rate-limits" - ] - }, - "sdk/ionic-legacy/3.0/setup", - { - "group": "Authentication", - "pages": [ - "sdk/ionic-legacy/3.0/authentication", - "sdk/ionic-legacy/3.0/authentication-login-listeners" - ] - }, - { - "group": "Messaging", - "pages": [ - "sdk/ionic-legacy/3.0/messaging", - "sdk/ionic-legacy/3.0/messaging-send-message", - "sdk/ionic-legacy/3.0/messaging-receive-messages", - "sdk/ionic-legacy/3.0/messaging-additional-message-filtering", - "sdk/ionic-legacy/3.0/messaging-retrieve-conversations", - "sdk/ionic-legacy/3.0/threaded-messages", - "sdk/ionic-legacy/3.0/messaging-edit-message", - "sdk/ionic-legacy/3.0/messaging-delete-message", - "sdk/ionic-legacy/3.0/messaging-delete-conversation", - "sdk/ionic-legacy/3.0/messaging-typing-indicators", - "sdk/ionic-legacy/3.0/transient-messages", - "sdk/ionic-legacy/3.0/messaging-receipts" - ] - }, - { - "group": "Calling v3", - "pages": [ - "sdk/ionic-legacy/3.0/calling-v3", - "sdk/ionic-legacy/3.0/v3-setup", - "sdk/ionic-legacy/3.0/v3-start-call-session", - "sdk/ionic-legacy/3.0/v3-video-view-customisation", - "sdk/ionic-legacy/3.0/v3-calling-recording" - ] - }, - { - "group": "Calling", - "pages": [ - "sdk/ionic-legacy/3.0/calling", - "sdk/ionic-legacy/3.0/calling-direct-calling", - "sdk/ionic-legacy/3.0/calling-default-calling", - "sdk/ionic-legacy/3.0/calling-recording", - "sdk/ionic-legacy/3.0/video-view-customisation" - ] - }, - { - "group": "Users", - "pages": [ - "sdk/ionic-legacy/3.0/users", - "sdk/ionic-legacy/3.0/users-retrieve-users", - "sdk/ionic-legacy/3.0/users-user-management", - "sdk/ionic-legacy/3.0/users-block-users" - ] - }, - "sdk/ionic-legacy/3.0/user-presence", - { - "group": "Groups", - "pages": [ - "sdk/ionic-legacy/3.0/groups", - "sdk/ionic-legacy/3.0/groups-retrieve-groups", - "sdk/ionic-legacy/3.0/groups-create-group", - "sdk/ionic-legacy/3.0/groups-update-group", - "sdk/ionic-legacy/3.0/groups-join-group", - "sdk/ionic-legacy/3.0/groups-leave-group", - "sdk/ionic-legacy/3.0/groups-delete-group", - "sdk/ionic-legacy/3.0/groups-retrieve-group-members", - "sdk/ionic-legacy/3.0/groups-add-members-to-group", - "sdk/ionic-legacy/3.0/groups-kick-ban-members", - "sdk/ionic-legacy/3.0/groups-change-member-scope", - "sdk/ionic-legacy/3.0/groups-transfer-group-ownership" - ] - }, - "sdk/ionic-legacy/3.0/bots", - "sdk/ionic-legacy/3.0/webhooks", - { - "group": "Resources", - "pages": [ - "sdk/ionic-legacy/3.0/resources", - "sdk/ionic-legacy/3.0/resources-all-real-time-listeners", - "sdk/ionic-legacy/3.0/resources-upgrading-from-v2" - ] - }, - { - "group": "Advanced", - "pages": [ - "sdk/ionic-legacy/3.0/advanced", - "sdk/ionic-legacy/3.0/advanced-connection-listener", - "sdk/ionic-legacy/3.0/advanced-managing-web-socket-connections-manually" - ] - }, - "sdk/ionic-legacy/extensions-overview" - ] - } - ] - }, - { - "version": "v2\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", - "groups": [ - { - "group": " ", - "pages": [ - { - "group": "Overview", - "pages": [ - "sdk/ionic-legacy/2.0/overview", - "sdk/ionic-legacy/2.0/key-concepts", - "sdk/ionic-legacy/2.0/message-structure-and-hierarchy", - "sdk/ionic-legacy/2.0/rate-limits" - ] - }, - "sdk/ionic-legacy/2.0/setup", - { - "group": "Authentication", - "pages": [ - "sdk/ionic-legacy/2.0/authentication", - "sdk/ionic-legacy/2.0/authentication-login-listeners" - ] - }, - { - "group": "Messaging", - "pages": [ - "sdk/ionic-legacy/2.0/messaging", - "sdk/ionic-legacy/2.0/messaging-send-message", - "sdk/ionic-legacy/2.0/messaging-receive-messages", - "sdk/ionic-legacy/2.0/messaging-additional-message-filtering", - "sdk/ionic-legacy/2.0/messaging-retrieve-conversations", - "sdk/ionic-legacy/2.0/threaded-messages", - "sdk/ionic-legacy/2.0/messaging-edit-message", - "sdk/ionic-legacy/2.0/messaging-delete-message", - "sdk/ionic-legacy/2.0/messaging-delete-conversation", - "sdk/ionic-legacy/2.0/messaging-typing-indicators", - "sdk/ionic-legacy/2.0/messaging-receipts" - ] - }, - { - "group": "Calling", - "pages": [ - "sdk/ionic-legacy/2.0/calling", - "sdk/ionic-legacy/2.0/calling-direct-calling", - "sdk/ionic-legacy/2.0/calling-default-calling" - ] - }, - { - "group": "Users", - "pages": [ - "sdk/ionic-legacy/2.0/users", - "sdk/ionic-legacy/2.0/users-retrieve-users", - "sdk/ionic-legacy/2.0/users-user-management", - "sdk/ionic-legacy/2.0/users-block-users" - ] - }, - "sdk/ionic-legacy/2.0/user-presence", - { - "group": "Groups", - "pages": [ - "sdk/ionic-legacy/2.0/groups", - "sdk/ionic-legacy/2.0/groups-retrieve-groups", - "sdk/ionic-legacy/2.0/groups-create-group", - "sdk/ionic-legacy/2.0/groups-update-group", - "sdk/ionic-legacy/2.0/groups-join-group", - "sdk/ionic-legacy/2.0/groups-leave-group", - "sdk/ionic-legacy/2.0/groups-delete-group", - "sdk/ionic-legacy/2.0/groups-retrieve-group-members", - "sdk/ionic-legacy/2.0/groups-add-members-to-group", - "sdk/ionic-legacy/2.0/groups-kick-ban-members", - "sdk/ionic-legacy/2.0/groups-change-member-scope", - "sdk/ionic-legacy/2.0/groups-transfer-group-ownership" - ] - }, - "sdk/ionic-legacy/2.0/bots", - "sdk/ionic-legacy/2.0/webhooks", - { - "group": "Resources", - "pages": [ - "sdk/ionic-legacy/2.0/resources", - "sdk/ionic-legacy/2.0/resources-all-real-time-listeners", - "sdk/ionic-legacy/2.0/resources-upgrading-from-v1" - ] - }, - { - "group": "Advanced", - "pages": [ - "sdk/ionic-legacy/2.0/advanced", - "sdk/ionic-legacy/2.0/advanced-connection-listener" - ] - } - ] - } - ] - } + "pages": [ + "sdk/ionic-legacy/overview" ] } - ] + ], + "pages": [] }, { "tab": "APIs", @@ -5453,7 +5141,7 @@ "icon": "/images/icons/js.svg", "versions": [ { - "version": "v4\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v4‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -5495,7 +5183,7 @@ ] }, { - "version": "v5\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v5‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎", "groups": [ { "group": "Overview", @@ -5579,7 +5267,7 @@ "icon": "/images/icons/react.svg", "versions": [ { - "version": "v4\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v4‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -5620,7 +5308,7 @@ ] }, { - "version": "v5\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v5‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎", "groups": [ { "group": "Overview", @@ -5694,7 +5382,7 @@ "icon": "/images/icons/swift.svg", "versions": [ { - "version": "v4\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v4‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -5735,7 +5423,7 @@ ] }, { - "version": "v5\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v5‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎", "groups": [ { "group": "Overview", @@ -5809,7 +5497,7 @@ "icon": "/images/icons/android.svg", "versions": [ { - "version": "v4\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v4‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -5849,7 +5537,7 @@ ] }, { - "version": "v5\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v5‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎", "groups": [ { "group": "Overview", @@ -5923,7 +5611,7 @@ "icon": "/images/icons/flutter.svg", "versions": [ { - "version": "v4\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v4‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎", "groups": [ { "group": " ", @@ -5963,7 +5651,7 @@ ] }, { - "version": "v5\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e\u200e", + "version": "v5‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎", "groups": [ { "group": "Overview", @@ -6260,15 +5948,6 @@ "/ai-chatbots/custom-bots" ] }, - { - "tab": "AI Bots (Legacy)", - "hidden": true, - "pages": [ - "/ai-chatbots/ai-bots/overview", - "/ai-chatbots/ai-bots/instructions", - "/ai-chatbots/ai-bots/bots" - ] - }, { "tab": "APIs", "groups": [ @@ -6443,8 +6122,7 @@ { "group": "Resources", "pages": [ - "moderation/api-explorer", - "moderation/legacy-extensions" + "moderation/api-explorer" ] } ] @@ -6487,12 +6165,6 @@ "notifications/logs", "notifications/constraints-and-limits" ] - }, - { - "group": " ", - "pages": [ - "notifications/push-notifications-extension-legacy" - ] } ] }, @@ -6503,13 +6175,7 @@ "notifications/email-integration", "notifications/email-preferences", "notifications/email-templates", - "notifications/email-custom-providers", - { - "group": " ", - "pages": [ - "notifications/email-notifications-extension-legacy" - ] - } + "notifications/email-custom-providers" ] }, { @@ -6519,13 +6185,7 @@ "notifications/sms-integration", "notifications/sms-preferences", "notifications/sms-templates", - "notifications/sms-custom-providers", - { - "group": " ", - "pages": [ - "notifications/sms-notifications-extension-legacy" - ] - } + "notifications/sms-custom-providers" ] } ] @@ -6624,30 +6284,6 @@ "source": "/webhooks/webhooks-events", "destination": "/fundamentals/webhooks-events" }, - { - "source": "/webhooks/webhooks-legacy-overview", - "destination": "/fundamentals/webhooks-legacy" - }, - { - "source": "/webhooks/webhooks-legacy-management", - "destination": "/fundamentals/webhooks-legacy" - }, - { - "source": "/webhooks/webhooks-legacy-events", - "destination": "/fundamentals/webhooks-legacy" - }, - { - "source": "/fundamentals/webhooks-legacy-overview", - "destination": "/fundamentals/webhooks-legacy" - }, - { - "source": "/fundamentals/webhooks-legacy-management", - "destination": "/fundamentals/webhooks-legacy" - }, - { - "source": "/fundamentals/webhooks-legacy-events", - "destination": "/fundamentals/webhooks-legacy" - }, { "source": "/ai/bots", "destination": "/ai-chatbots/bots" @@ -6837,1316 +6473,1784 @@ "destination": "/notifications/token-management" }, { - "source": "/extensions/legacy-push-notifications", - "destination": "/notifications/legacy-push-notifications" + "source": "/ui-kit/react/v6", + "destination": "/ui-kit/react" }, { - "source": "/extensions/push-notifications-overview", - "destination": "/notifications/push-notifications-extension-legacy" + "source": "/ui-kit/react/v6/:slug*", + "destination": "/ui-kit/react/:slug*" }, { - "source": "/extensions/email-notifications", - "destination": "/notifications/email-notifications-extension-legacy" + "source": "/ui-kit/react/6.0", + "destination": "/ui-kit/react" }, { - "source": "/extensions/sms-notifications", - "destination": "/notifications/sms-notifications-extension-legacy" + "source": "/ui-kit/react/6.0/:slug*", + "destination": "/ui-kit/react/:slug*" }, { - "source": "/extensions/slow-mode", - "destination": "/moderation/legacy-extensions" + "source": "/ui-kit/react/v6/integration/next-js", + "destination": "/ui-kit/react/next-js-integration" }, { - "source": "/extensions/xss-filter", - "destination": "/moderation/legacy-extensions" + "source": "/ui-kit/react", + "destination": "/ui-kit/react/overview" }, { - "source": "/extensions/report-user", - "destination": "/moderation/legacy-extensions" + "source": "/ui-kit/react/5.0", + "destination": "/ui-kit/react/v5" }, { - "source": "/extensions/report-message", - "destination": "/moderation/legacy-extensions" + "source": "/ui-kit/react/5.0/:slug*", + "destination": "/ui-kit/react/v5/:slug*" }, { - "source": "/extensions/data-masking-filter", - "destination": "/moderation/legacy-extensions" + "source": "/ui-kit/react/4.0", + "destination": "/ui-kit/react/v4" }, { - "source": "/extensions/profanity-filter", - "destination": "/moderation/legacy-extensions" + "source": "/ui-kit/react/4.0/:slug*", + "destination": "/ui-kit/react/v4/:slug*" }, { - "source": "/extensions/image-moderation", - "destination": "/moderation/legacy-extensions" + "source": "/ui-kit/react/3.0", + "destination": "/ui-kit/react/v3" }, { - "source": "/extensions/sentiment-analysis", - "destination": "/moderation/legacy-extensions" + "source": "/ui-kit/react/3.0/:slug*", + "destination": "/ui-kit/react/v3/:slug*" }, { - "source": "/extensions/in-flight-message-moderation", - "destination": "/moderation/legacy-extensions" + "source": "/ui-kit/react/2.0", + "destination": "/ui-kit/react/v2" }, { - "source": "/extensions/virus-malware-scanner", - "destination": "/moderation/legacy-extensions" + "source": "/ui-kit/react/2.0/:slug*", + "destination": "/ui-kit/react/v2/:slug*" }, { - "source": "/moderation/slow-mode", - "destination": "/moderation/legacy-extensions" + "source": "/ui-kit/ios/v5", + "destination": "/ui-kit/ios" }, { - "source": "/moderation/xss-filter", - "destination": "/moderation/legacy-extensions" + "source": "/ui-kit/ios/v5/:slug*", + "destination": "/ui-kit/ios/:slug*" }, { - "source": "/moderation/report-user", - "destination": "/moderation/legacy-extensions" + "source": "/ui-kit/ios/5.0", + "destination": "/ui-kit/ios" }, { - "source": "/moderation/report-message", - "destination": "/moderation/legacy-extensions" + "source": "/ui-kit/ios/5.0/:slug*", + "destination": "/ui-kit/ios/:slug*" }, { - "source": "/moderation/data-masking-filter", - "destination": "/moderation/legacy-extensions" + "source": "/ui-kit/ios/4.0", + "destination": "/ui-kit/ios/v4" }, { - "source": "/moderation/profanity-filter", - "destination": "/moderation/legacy-extensions" + "source": "/ui-kit/ios/4.0/:slug*", + "destination": "/ui-kit/ios/v4/:slug*" }, { - "source": "/moderation/image-moderation", - "destination": "/moderation/legacy-extensions" + "source": "/ui-kit/ios/3.0", + "destination": "/ui-kit/ios/v3" }, { - "source": "/moderation/sentiment-analysis", - "destination": "/moderation/legacy-extensions" + "source": "/ui-kit/ios/3.0/:slug*", + "destination": "/ui-kit/ios/v3/:slug*" }, { - "source": "/moderation/in-flight-message-moderation", - "destination": "/moderation/legacy-extensions" + "source": "/ui-kit/ios/2.0", + "destination": "/ui-kit/ios/v2" }, { - "source": "/moderation/virus-malware-scanner", - "destination": "/moderation/legacy-extensions" + "source": "/ui-kit/ios/2.0/:slug*", + "destination": "/ui-kit/ios/v2/:slug*" }, { - "source": "/ui-kit/react/v6", - "destination": "/ui-kit/react" + "source": "/ui-kit/android/v5", + "destination": "/ui-kit/android" }, { - "source": "/ui-kit/react/v6/:slug*", - "destination": "/ui-kit/react/:slug*" + "source": "/ui-kit/android/v5/:slug*", + "destination": "/ui-kit/android/:slug*" }, { - "source": "/ui-kit/react/6.0", - "destination": "/ui-kit/react" + "source": "/ui-kit/android/5.0", + "destination": "/ui-kit/android" }, { - "source": "/ui-kit/react/6.0/:slug*", - "destination": "/ui-kit/react/:slug*" + "source": "/ui-kit/android/5.0/:slug*", + "destination": "/ui-kit/android/:slug*" }, { - "source": "/ui-kit/react/v6/integration/next-js", - "destination": "/ui-kit/react/next-js-integration" + "source": "/ui-kit/android/4.0", + "destination": "/ui-kit/android/v4" }, { - "source": "/ui-kit/react", - "destination": "/ui-kit/react/overview" + "source": "/ui-kit/android/4.0/:slug*", + "destination": "/ui-kit/android/v4/:slug*" }, { - "source": "/ui-kit/react/5.0", - "destination": "/ui-kit/react/v5" + "source": "/ui-kit/android/3.0", + "destination": "/ui-kit/android/v3" }, { - "source": "/ui-kit/react/5.0/:slug*", - "destination": "/ui-kit/react/v5/:slug*" + "source": "/ui-kit/android/3.0/:slug*", + "destination": "/ui-kit/android/v3/:slug*" }, { - "source": "/ui-kit/react/4.0", - "destination": "/ui-kit/react/v4" + "source": "/ui-kit/android/2.0", + "destination": "/ui-kit/android/v2" }, { - "source": "/ui-kit/react/4.0/:slug*", - "destination": "/ui-kit/react/v4/:slug*" + "source": "/ui-kit/android/2.0/:slug*", + "destination": "/ui-kit/android/v2/:slug*" }, { - "source": "/ui-kit/react/3.0", - "destination": "/ui-kit/react/v3" + "source": "/ui-kit/flutter/v5", + "destination": "/ui-kit/flutter" }, { - "source": "/ui-kit/react/3.0/:slug*", - "destination": "/ui-kit/react/v3/:slug*" + "source": "/ui-kit/flutter/v5/:slug*", + "destination": "/ui-kit/flutter/:slug*" }, { - "source": "/ui-kit/react/2.0", - "destination": "/ui-kit/react/v2" + "source": "/ui-kit/flutter/5.0", + "destination": "/ui-kit/flutter" }, { - "source": "/ui-kit/react/2.0/:slug*", - "destination": "/ui-kit/react/v2/:slug*" + "source": "/ui-kit/flutter/5.0/:slug*", + "destination": "/ui-kit/flutter/:slug*" }, { - "source": "/ui-kit/ios/v5", - "destination": "/ui-kit/ios" + "source": "/ui-kit/flutter/4.0", + "destination": "/ui-kit/flutter/v4" }, { - "source": "/ui-kit/ios/v5/:slug*", - "destination": "/ui-kit/ios/:slug*" + "source": "/ui-kit/flutter/4.0/:slug*", + "destination": "/ui-kit/flutter/v4/:slug*" }, { - "source": "/ui-kit/ios/5.0", - "destination": "/ui-kit/ios" + "source": "/ui-kit/react-native/5.0/:slug*", + "destination": "/ui-kit/react-native/:slug*" }, { - "source": "/ui-kit/ios/5.0/:slug*", - "destination": "/ui-kit/ios/:slug*" + "source": "/ui-kit/react-native/4.0", + "destination": "/ui-kit/react-native/v4" }, { - "source": "/ui-kit/ios/4.0", - "destination": "/ui-kit/ios/v4" + "source": "/ui-kit/react-native/4.0/:slug*", + "destination": "/ui-kit/react-native/v4/:slug*" }, { - "source": "/ui-kit/ios/4.0/:slug*", - "destination": "/ui-kit/ios/v4/:slug*" + "source": "/ai-chatbots/non-ai-bots", + "destination": "/ai-chatbots/custom-agents" }, { - "source": "/ui-kit/ios/3.0", - "destination": "/ui-kit/ios/v3" + "source": "/widget/wordpress-buddypress", + "destination": "/widget/legacy/wordpress-buddypress" + }, + { + "source": "/widget/html-bootstrap-jquery", + "destination": "/widget/legacy/html-bootstrap-jquery" + }, + { + "source": "/ui-kit/react/builder-integration", + "destination": "/chat-builder/react/integration" + }, + { + "source": "/ui-kit/react/builder-integration-nextjs", + "destination": "/chat-builder/nextjs/integration" + }, + { + "source": "/ui-kit/react/builder-integration-react-router", + "destination": "/chat-builder/react-router/integration" + }, + { + "source": "/ui-kit/react/builder-customisations", + "destination": "/chat-builder/react/builder-customisations" + }, + { + "source": "/ui-kit/react/builder-dir-structure", + "destination": "/chat-builder/react/builder-dir-structure" + }, + { + "source": "/ui-kit/react/builder-settings", + "destination": "/chat-builder/react/builder-settings" + }, + { + "source": "/widget/overview", + "destination": "/widget/html/overview" + }, + { + "source": "/widget/builder-guide-html", + "destination": "/widget/html/integration" + }, + { + "source": "/widget/builder-guide-wordpress", + "destination": "/widget/wordpress/integration" + }, + { + "source": "/widget/builder-guide-squarespace", + "destination": "/widget/squarespace/integration" + }, + { + "source": "/widget/builder-guide-wix", + "destination": "/widget/wix/integration" + }, + { + "source": "/widget/builder-guide-webflow", + "destination": "/widget/webflow/integration" + }, + { + "source": "/widget/ai-agents", + "destination": "/ai-agents/chat-widget" + }, + { + "source": "/ai-agents/actions", + "destination": "/ai-agents/mastra-actions" + }, + { + "source": "/ai-agents/tools", + "destination": "/ai-agents/mastra-tools" + }, + { + "source": "/sdk/android/setup-calling", + "destination": "/calls/v4/android/setup" + }, + { + "source": "/sdk/ios/calling-integration", + "destination": "/calls/v4/ios/setup" + }, + { + "source": "/articles/docker", + "destination": "/on-premise-deployment/docker/overview" + }, + { + "source": "/notifications/react-native-push-notifications", + "destination": "/notifications/react-native-push-notifications-android" + }, + { + "source": "/fundamentals/webhooks-legacy", + "destination": "https://assets.cometchat.io/legacy-docs/fundamentals/webhooks-legacy.html" + }, + { + "source": "/moderation/legacy-extensions", + "destination": "https://assets.cometchat.io/legacy-docs/moderation/legacy-extensions.html" + }, + { + "source": "/notifications/push-notifications-extension-legacy", + "destination": "https://assets.cometchat.io/legacy-docs/notifications/push-notifications-extension-legacy.html" + }, + { + "source": "/notifications/legacy-push-notifications", + "destination": "https://assets.cometchat.io/legacy-docs/notifications/legacy-push-notifications.html" + }, + { + "source": "/notifications/email-notifications-extension-legacy", + "destination": "https://assets.cometchat.io/legacy-docs/notifications/email-notifications-extension-legacy.html" + }, + { + "source": "/notifications/sms-notifications-extension-legacy", + "destination": "https://assets.cometchat.io/legacy-docs/notifications/sms-notifications-extension-legacy.html" + }, + { + "source": "/widget/html/legacy", + "destination": "https://assets.cometchat.io/legacy-docs/widget/html/legacy.html" + }, + { + "source": "/widget/wordpress/legacy", + "destination": "https://assets.cometchat.io/legacy-docs/widget/wordpress/legacy.html" + }, + { + "source": "/ai-chatbots/ai-bots/overview", + "destination": "https://assets.cometchat.io/legacy-docs/ai-chatbots/ai-bots/overview.html" + }, + { + "source": "/ai-chatbots/ai-bots/instructions", + "destination": "https://assets.cometchat.io/legacy-docs/ai-chatbots/ai-bots/instructions.html" + }, + { + "source": "/ai-chatbots/ai-bots/bots", + "destination": "https://assets.cometchat.io/legacy-docs/ai-chatbots/ai-bots/bots.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/advanced-connection-listener", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/advanced-connection-listener.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/advanced", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/advanced.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/authentication-login-listeners", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/authentication-login-listeners.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/authentication", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/authentication.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/bots", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/bots.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/calling-default-calling", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/calling-default-calling.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/calling-direct-calling", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/calling-direct-calling.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/calling", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/calling.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/groups-add-members-to-group", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups-add-members-to-group.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/groups-change-member-scope", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups-change-member-scope.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/groups-create-group", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups-create-group.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/groups-delete-group", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups-delete-group.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/groups-join-group", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups-join-group.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/groups-kick-ban-members", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups-kick-ban-members.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/groups-leave-group", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups-leave-group.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/groups-retrieve-group-members", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups-retrieve-group-members.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/groups-retrieve-groups", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups-retrieve-groups.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/groups-transfer-group-ownership", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups-transfer-group-ownership.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/groups-update-group", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups-update-group.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/groups", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/key-concepts", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/key-concepts.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/message-structure-and-hierarchy", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/message-structure-and-hierarchy.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/messaging-additional-message-filtering", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/messaging-additional-message-filtering.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/messaging-delete-conversation", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/messaging-delete-conversation.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/messaging-delete-message", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/messaging-delete-message.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/messaging-edit-message", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/messaging-edit-message.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/messaging-receipts", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/messaging-receipts.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/messaging-receive-messages", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/messaging-receive-messages.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/messaging-retrieve-conversations", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/messaging-retrieve-conversations.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/messaging-send-message", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/messaging-send-message.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/messaging-typing-indicators", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/messaging-typing-indicators.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/messaging", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/messaging.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/overview", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/overview.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/rate-limits", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/rate-limits.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/resources-all-real-time-listeners", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/resources-all-real-time-listeners.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/resources-upgrading-from-v1", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/resources-upgrading-from-v1.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/resources", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/resources.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/setup", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/setup.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/threaded-messages", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/threaded-messages.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/user-presence", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/user-presence.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/users-block-users", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/users-block-users.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/users-retrieve-users", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/users-retrieve-users.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/users-user-management", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/users-user-management.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/users", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/users.html" + }, + { + "source": "/sdk/ionic-legacy/2.0/webhooks", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/webhooks.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/advanced-connection-listener", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/advanced-connection-listener.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/advanced-managing-web-socket-connections-manually", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/advanced-managing-web-socket-connections-manually.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/advanced", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/advanced.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/authentication-login-listeners", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/authentication-login-listeners.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/authentication", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/authentication.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/bots", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/bots.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/calling-default-calling", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/calling-default-calling.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/calling-direct-calling", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/calling-direct-calling.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/calling-recording", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/calling-recording.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/calling-v3", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/calling-v3.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/calling", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/calling.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/groups-add-members-to-group", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups-add-members-to-group.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/groups-change-member-scope", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups-change-member-scope.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/groups-create-group", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups-create-group.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/groups-delete-group", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups-delete-group.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/groups-join-group", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups-join-group.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/groups-kick-ban-members", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups-kick-ban-members.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/groups-leave-group", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups-leave-group.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/groups-retrieve-group-members", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups-retrieve-group-members.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/groups-retrieve-groups", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups-retrieve-groups.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/groups-transfer-group-ownership", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups-transfer-group-ownership.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/groups-update-group", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups-update-group.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/groups", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/key-concepts", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/key-concepts.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/message-structure-and-hierarchy", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/message-structure-and-hierarchy.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/messaging-additional-message-filtering", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/messaging-additional-message-filtering.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/messaging-delete-conversation", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/messaging-delete-conversation.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/messaging-delete-message", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/messaging-delete-message.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/messaging-edit-message", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/messaging-edit-message.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/messaging-receipts", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/messaging-receipts.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/messaging-receive-messages", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/messaging-receive-messages.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/messaging-retrieve-conversations", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/messaging-retrieve-conversations.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/messaging-send-message", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/messaging-send-message.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/messaging-typing-indicators", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/messaging-typing-indicators.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/messaging", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/messaging.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/overview", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/overview.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/rate-limits", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/rate-limits.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/resources-all-real-time-listeners", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/resources-all-real-time-listeners.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/resources-upgrading-from-v2", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/resources-upgrading-from-v2.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/resources", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/resources.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/setup", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/setup.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/threaded-messages", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/threaded-messages.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/transient-messages", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/transient-messages.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/user-presence", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/user-presence.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/users-block-users", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/users-block-users.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/users-retrieve-users", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/users-retrieve-users.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/users-user-management", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/users-user-management.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/users", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/users.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/v3-calling-recording", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/v3-calling-recording.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/v3-setup", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/v3-setup.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/v3-start-call-session", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/v3-start-call-session.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/v3-video-view-customisation", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/v3-video-view-customisation.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/video-view-customisation", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/video-view-customisation.html" + }, + { + "source": "/sdk/ionic-legacy/3.0/webhooks", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/webhooks.html" + }, + { + "source": "/sdk/ionic-legacy/additional-message-filtering", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/additional-message-filtering.html" + }, + { + "source": "/sdk/ionic-legacy/advanced", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/advanced.html" + }, + { + "source": "/sdk/ionic-legacy/ai-chatbots-overview", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/ai-chatbots-overview.html" + }, + { + "source": "/sdk/ionic-legacy/ai-user-copilot-overview", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/ai-user-copilot-overview.html" + }, + { + "source": "/sdk/ionic-legacy/authentication", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/authentication.html" + }, + { + "source": "/sdk/ionic-legacy/block-users", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/block-users.html" + }, + { + "source": "/sdk/ionic-legacy/calling-overview", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/calling-overview.html" + }, + { + "source": "/sdk/ionic-legacy/calling-setup", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/calling-setup.html" + }, + { + "source": "/sdk/ionic-legacy/changelog", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/changelog.html" + }, + { + "source": "/sdk/ionic-legacy/connection-behaviour", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/connection-behaviour.html" + }, + { + "source": "/sdk/ionic-legacy/connection-status", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/connection-status.html" + }, + { + "source": "/sdk/ionic-legacy/create-group", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/create-group.html" + }, + { + "source": "/sdk/ionic-legacy/default-call", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/default-call.html" + }, + { + "source": "/sdk/ionic-legacy/delete-conversation", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/delete-conversation.html" + }, + { + "source": "/sdk/ionic-legacy/delete-group", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/delete-group.html" + }, + { + "source": "/sdk/ionic-legacy/delete-message", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/delete-message.html" + }, + { + "source": "/sdk/ionic-legacy/delivery-read-receipts", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/delivery-read-receipts.html" + }, + { + "source": "/sdk/ionic-legacy/direct-call", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/direct-call.html" + }, + { + "source": "/sdk/ionic-legacy/edit-message", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/edit-message.html" + }, + { + "source": "/sdk/ionic-legacy/extensions-overview", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/extensions-overview.html" + }, + { + "source": "/sdk/ionic-legacy/group-add-members", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/group-add-members.html" + }, + { + "source": "/sdk/ionic-legacy/group-change-member-scope", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/group-change-member-scope.html" + }, + { + "source": "/sdk/ionic-legacy/group-kick-member", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/group-kick-member.html" + }, + { + "source": "/sdk/ionic-legacy/groups-overview", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/groups-overview.html" + }, + { + "source": "/sdk/ionic-legacy/interactive-messages", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/interactive-messages.html" + }, + { + "source": "/sdk/ionic-legacy/join-group", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/join-group.html" + }, + { + "source": "/sdk/ionic-legacy/key-concepts", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/key-concepts.html" + }, + { + "source": "/sdk/ionic-legacy/leave-group", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/leave-group.html" + }, + { + "source": "/sdk/ionic-legacy/login-listeners", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/login-listeners.html" + }, + { + "source": "/sdk/ionic-legacy/managing-connections-manually", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/managing-connections-manually.html" + }, + { + "source": "/sdk/ionic-legacy/mentions", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/mentions.html" + }, + { + "source": "/sdk/ionic-legacy/message-structure-and-hierarchy", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/message-structure-and-hierarchy.html" + }, + { + "source": "/sdk/ionic-legacy/messaging-overview", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/messaging-overview.html" + }, + { + "source": "/sdk/ionic-legacy/presenter-mode", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/presenter-mode.html" + }, + { + "source": "/sdk/ionic-legacy/rate-limits", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/rate-limits.html" + }, + { + "source": "/sdk/ionic-legacy/reactions", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/reactions.html" + }, + { + "source": "/sdk/ionic-legacy/real-time-listeners", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/real-time-listeners.html" + }, + { + "source": "/sdk/ionic-legacy/receive-messages", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/receive-messages.html" + }, + { + "source": "/sdk/ionic-legacy/recording", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/recording.html" + }, + { + "source": "/sdk/ionic-legacy/resources-overview", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/resources-overview.html" + }, + { + "source": "/sdk/ionic-legacy/retrieve-conversations", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/retrieve-conversations.html" + }, + { + "source": "/sdk/ionic-legacy/retrieve-group-members", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/retrieve-group-members.html" + }, + { + "source": "/sdk/ionic-legacy/retrieve-groups", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/retrieve-groups.html" + }, + { + "source": "/sdk/ionic-legacy/retrieve-users", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/retrieve-users.html" + }, + { + "source": "/sdk/ionic-legacy/send-message", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/send-message.html" + }, + { + "source": "/sdk/ionic-legacy/setup", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/setup.html" + }, + { + "source": "/sdk/ionic-legacy/threaded-messages", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/threaded-messages.html" + }, + { + "source": "/sdk/ionic-legacy/transfer-group-ownership", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/transfer-group-ownership.html" + }, + { + "source": "/sdk/ionic-legacy/transient-messages", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/transient-messages.html" + }, + { + "source": "/sdk/ionic-legacy/typing-indicators", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/typing-indicators.html" }, { - "source": "/ui-kit/ios/3.0/:slug*", - "destination": "/ui-kit/ios/v3/:slug*" + "source": "/sdk/ionic-legacy/update-group", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/update-group.html" }, { - "source": "/ui-kit/ios/2.0", - "destination": "/ui-kit/ios/v2" + "source": "/sdk/ionic-legacy/upgrading-from-v3-guide", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/upgrading-from-v3-guide.html" }, { - "source": "/ui-kit/ios/2.0/:slug*", - "destination": "/ui-kit/ios/v2/:slug*" + "source": "/sdk/ionic-legacy/user-management", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/user-management.html" }, { - "source": "/ui-kit/android/v5", - "destination": "/ui-kit/android" + "source": "/sdk/ionic-legacy/user-presence", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/user-presence.html" }, { - "source": "/ui-kit/android/v5/:slug*", - "destination": "/ui-kit/android/:slug*" + "source": "/sdk/ionic-legacy/users-overview", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/users-overview.html" }, { - "source": "/ui-kit/android/5.0", - "destination": "/ui-kit/android" + "source": "/sdk/ionic-legacy/video-view-customisation", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/video-view-customisation.html" }, { - "source": "/ui-kit/android/5.0/:slug*", - "destination": "/ui-kit/android/:slug*" + "source": "/sdk/ionic-legacy/webhooks-overview", + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/webhooks-overview.html" }, { - "source": "/ui-kit/android/4.0", - "destination": "/ui-kit/android/v4" + "source": "/webhooks/webhooks-legacy-overview", + "destination": "https://assets.cometchat.io/legacy-docs/fundamentals/webhooks-legacy.html" }, { - "source": "/ui-kit/android/4.0/:slug*", - "destination": "/ui-kit/android/v4/:slug*" + "source": "/webhooks/webhooks-legacy-management", + "destination": "https://assets.cometchat.io/legacy-docs/fundamentals/webhooks-legacy.html" }, { - "source": "/ui-kit/android/3.0", - "destination": "/ui-kit/android/v3" + "source": "/webhooks/webhooks-legacy-events", + "destination": "https://assets.cometchat.io/legacy-docs/fundamentals/webhooks-legacy.html" }, { - "source": "/ui-kit/android/3.0/:slug*", - "destination": "/ui-kit/android/v3/:slug*" + "source": "/fundamentals/webhooks-legacy-overview", + "destination": "https://assets.cometchat.io/legacy-docs/fundamentals/webhooks-legacy.html" }, { - "source": "/ui-kit/android/2.0", - "destination": "/ui-kit/android/v2" + "source": "/fundamentals/webhooks-legacy-management", + "destination": "https://assets.cometchat.io/legacy-docs/fundamentals/webhooks-legacy.html" }, { - "source": "/ui-kit/android/2.0/:slug*", - "destination": "/ui-kit/android/v2/:slug*" + "source": "/fundamentals/webhooks-legacy-events", + "destination": "https://assets.cometchat.io/legacy-docs/fundamentals/webhooks-legacy.html" }, { - "source": "/ui-kit/flutter/v5", - "destination": "/ui-kit/flutter" + "source": "/extensions/legacy-push-notifications", + "destination": "https://assets.cometchat.io/legacy-docs/notifications/legacy-push-notifications.html" }, { - "source": "/ui-kit/flutter/v5/:slug*", - "destination": "/ui-kit/flutter/:slug*" + "source": "/extensions/push-notifications-overview", + "destination": "https://assets.cometchat.io/legacy-docs/notifications/push-notifications-extension-legacy.html" }, { - "source": "/ui-kit/flutter/5.0", - "destination": "/ui-kit/flutter" + "source": "/extensions/email-notifications", + "destination": "https://assets.cometchat.io/legacy-docs/notifications/email-notifications-extension-legacy.html" }, { - "source": "/ui-kit/flutter/5.0/:slug*", - "destination": "/ui-kit/flutter/:slug*" + "source": "/extensions/sms-notifications", + "destination": "https://assets.cometchat.io/legacy-docs/notifications/sms-notifications-extension-legacy.html" }, { - "source": "/ui-kit/flutter/4.0", - "destination": "/ui-kit/flutter/v4" + "source": "/extensions/slow-mode", + "destination": "https://assets.cometchat.io/legacy-docs/moderation/legacy-extensions.html" }, { - "source": "/ui-kit/flutter/4.0/:slug*", - "destination": "/ui-kit/flutter/v4/:slug*" + "source": "/extensions/xss-filter", + "destination": "https://assets.cometchat.io/legacy-docs/moderation/legacy-extensions.html" }, { - "source": "/ui-kit/react-native/5.0/:slug*", - "destination": "/ui-kit/react-native/:slug*" + "source": "/extensions/report-user", + "destination": "https://assets.cometchat.io/legacy-docs/moderation/legacy-extensions.html" }, { - "source": "/ui-kit/react-native/4.0", - "destination": "/ui-kit/react-native/v4" + "source": "/extensions/report-message", + "destination": "https://assets.cometchat.io/legacy-docs/moderation/legacy-extensions.html" }, { - "source": "/ui-kit/react-native/4.0/:slug*", - "destination": "/ui-kit/react-native/v4/:slug*" + "source": "/extensions/data-masking-filter", + "destination": "https://assets.cometchat.io/legacy-docs/moderation/legacy-extensions.html" }, { - "source": "/ai-chatbots/non-ai-bots", - "destination": "/ai-chatbots/custom-agents" + "source": "/extensions/profanity-filter", + "destination": "https://assets.cometchat.io/legacy-docs/moderation/legacy-extensions.html" }, { - "source": "/widget/wordpress-buddypress", - "destination": "/widget/legacy/wordpress-buddypress" + "source": "/extensions/image-moderation", + "destination": "https://assets.cometchat.io/legacy-docs/moderation/legacy-extensions.html" }, { - "source": "/widget/html-bootstrap-jquery", - "destination": "/widget/legacy/html-bootstrap-jquery" + "source": "/extensions/sentiment-analysis", + "destination": "https://assets.cometchat.io/legacy-docs/moderation/legacy-extensions.html" }, { - "source": "/widget/custom-build", - "destination": "/widget/html/legacy" + "source": "/extensions/in-flight-message-moderation", + "destination": "https://assets.cometchat.io/legacy-docs/moderation/legacy-extensions.html" }, { - "source": "/ui-kit/react/builder-integration", - "destination": "/chat-builder/react/integration" + "source": "/extensions/virus-malware-scanner", + "destination": "https://assets.cometchat.io/legacy-docs/moderation/legacy-extensions.html" }, { - "source": "/ui-kit/react/builder-integration-nextjs", - "destination": "/chat-builder/nextjs/integration" + "source": "/moderation/slow-mode", + "destination": "https://assets.cometchat.io/legacy-docs/moderation/legacy-extensions.html" }, { - "source": "/ui-kit/react/builder-integration-react-router", - "destination": "/chat-builder/react-router/integration" + "source": "/moderation/xss-filter", + "destination": "https://assets.cometchat.io/legacy-docs/moderation/legacy-extensions.html" }, { - "source": "/ui-kit/react/builder-customisations", - "destination": "/chat-builder/react/builder-customisations" + "source": "/moderation/report-user", + "destination": "https://assets.cometchat.io/legacy-docs/moderation/legacy-extensions.html" }, { - "source": "/ui-kit/react/builder-dir-structure", - "destination": "/chat-builder/react/builder-dir-structure" + "source": "/moderation/report-message", + "destination": "https://assets.cometchat.io/legacy-docs/moderation/legacy-extensions.html" }, { - "source": "/ui-kit/react/builder-settings", - "destination": "/chat-builder/react/builder-settings" + "source": "/moderation/data-masking-filter", + "destination": "https://assets.cometchat.io/legacy-docs/moderation/legacy-extensions.html" }, { - "source": "/widget/overview", - "destination": "/widget/html/overview" + "source": "/moderation/profanity-filter", + "destination": "https://assets.cometchat.io/legacy-docs/moderation/legacy-extensions.html" }, { - "source": "/widget/builder-guide-html", - "destination": "/widget/html/integration" + "source": "/moderation/image-moderation", + "destination": "https://assets.cometchat.io/legacy-docs/moderation/legacy-extensions.html" }, { - "source": "/widget/builder-guide-wordpress", - "destination": "/widget/wordpress/integration" + "source": "/moderation/sentiment-analysis", + "destination": "https://assets.cometchat.io/legacy-docs/moderation/legacy-extensions.html" }, { - "source": "/widget/builder-guide-squarespace", - "destination": "/widget/squarespace/integration" + "source": "/moderation/in-flight-message-moderation", + "destination": "https://assets.cometchat.io/legacy-docs/moderation/legacy-extensions.html" }, { - "source": "/widget/builder-guide-wix", - "destination": "/widget/wix/integration" + "source": "/moderation/virus-malware-scanner", + "destination": "https://assets.cometchat.io/legacy-docs/moderation/legacy-extensions.html" }, { - "source": "/widget/builder-guide-webflow", - "destination": "/widget/webflow/integration" + "source": "/widget/custom-build", + "destination": "https://assets.cometchat.io/legacy-docs/widget/html/legacy.html" }, { "source": "/widget/legacy/overview", - "destination": "/widget/html/legacy" + "destination": "https://assets.cometchat.io/legacy-docs/widget/html/legacy.html" }, { "source": "/widget/legacy/wordpress-buddypress", - "destination": "/widget/wordpress/legacy" + "destination": "https://assets.cometchat.io/legacy-docs/widget/wordpress/legacy.html" }, { "source": "/widget/legacy/html-bootstrap-jquery", - "destination": "/widget/html/legacy" + "destination": "https://assets.cometchat.io/legacy-docs/widget/html/legacy.html" }, { "source": "/widget/legacy/custom-build", - "destination": "/widget/html/legacy" + "destination": "https://assets.cometchat.io/legacy-docs/widget/html/legacy.html" }, { "source": "/widget/html/legacy/overview", - "destination": "/widget/html/legacy" + "destination": "https://assets.cometchat.io/legacy-docs/widget/html/legacy.html" }, { "source": "/widget/html/legacy/html-bootstrap-jquery", - "destination": "/widget/html/legacy" + "destination": "https://assets.cometchat.io/legacy-docs/widget/html/legacy.html" }, { "source": "/widget/wordpress/legacy/overview", - "destination": "/widget/wordpress/legacy" + "destination": "https://assets.cometchat.io/legacy-docs/widget/wordpress/legacy.html" }, { "source": "/widget/wordpress/legacy/wordpress-buddypress", - "destination": "/widget/wordpress/legacy" - }, - { - "source": "/widget/ai-agents", - "destination": "/ai-agents/chat-widget" - }, - { - "source": "/ai-agents/actions", - "destination": "/ai-agents/mastra-actions" - }, - { - "source": "/ai-agents/tools", - "destination": "/ai-agents/mastra-tools" + "destination": "https://assets.cometchat.io/legacy-docs/widget/wordpress/legacy.html" }, { "source": "/ai-chatbots/overview", - "destination": "/ai-chatbots/ai-bots/overview" + "destination": "https://assets.cometchat.io/legacy-docs/ai-chatbots/ai-bots/overview.html" }, { "source": "/ai-chatbots/instructions", - "destination": "/ai-chatbots/ai-bots/instructions" + "destination": "https://assets.cometchat.io/legacy-docs/ai-chatbots/ai-bots/instructions.html" }, { "source": "/ai-chatbots/bots", - "destination": "/ai-chatbots/ai-bots/bots" - }, - { - "source": "/sdk/android/setup-calling", - "destination": "/calls/v4/android/setup" - }, - { - "source": "/sdk/ios/calling-integration", - "destination": "/calls/v4/ios/setup" - }, - { - "source": "/articles/docker", - "destination": "/on-premise-deployment/docker/overview" + "destination": "https://assets.cometchat.io/legacy-docs/ai-chatbots/ai-bots/bots.html" }, { "source": "/notifications/push-notification-extension-overview", - "destination": "/notifications/push-notification-extension-legacy" + "destination": "https://assets.cometchat.io/legacy-docs/notifications/push-notification-extension-legacy.html" }, { "source": "/notifications/push-notification-extension-legacy", - "destination": "/notifications/push-notifications-extension-legacy" + "destination": "https://assets.cometchat.io/legacy-docs/notifications/push-notifications-extension-legacy.html" }, { "source": "/notifications/web-push-notifications-legacy", - "destination": "/notifications/push-notifications-extension-legacy" + "destination": "https://assets.cometchat.io/legacy-docs/notifications/push-notifications-extension-legacy.html" }, { "source": "/notifications/android-push-notifications-legacy", - "destination": "/notifications/push-notifications-extension-legacy" + "destination": "https://assets.cometchat.io/legacy-docs/notifications/push-notifications-extension-legacy.html" }, { "source": "/notifications/android-connection-service", - "destination": "/notifications/push-notifications-extension-legacy" + "destination": "https://assets.cometchat.io/legacy-docs/notifications/push-notifications-extension-legacy.html" }, { "source": "/notifications/ios-fcm-push-notifications-legacy", - "destination": "/notifications/push-notifications-extension-legacy" + "destination": "https://assets.cometchat.io/legacy-docs/notifications/push-notifications-extension-legacy.html" }, { "source": "/notifications/ios-apns-push-notifications-legacy", - "destination": "/notifications/push-notifications-extension-legacy" + "destination": "https://assets.cometchat.io/legacy-docs/notifications/push-notifications-extension-legacy.html" }, { "source": "/notifications/flutter-push-notifications", - "destination": "/notifications/push-notifications-extension-legacy" + "destination": "https://assets.cometchat.io/legacy-docs/notifications/push-notifications-extension-legacy.html" }, { "source": "/notifications/react-native-push-notifications-legacy", - "destination": "/notifications/push-notifications-extension-legacy" + "destination": "https://assets.cometchat.io/legacy-docs/notifications/push-notifications-extension-legacy.html" }, { "source": "/notifications/capacitor-cordova-ionic-push-notifications", - "destination": "/notifications/push-notifications-extension-legacy" + "destination": "https://assets.cometchat.io/legacy-docs/notifications/push-notifications-extension-legacy.html" }, { "source": "/notifications/mute-functionality", - "destination": "/notifications/push-notifications-extension-legacy" + "destination": "https://assets.cometchat.io/legacy-docs/notifications/push-notifications-extension-legacy.html" }, { "source": "/notifications/token-management", - "destination": "/notifications/push-notifications-extension-legacy" + "destination": "https://assets.cometchat.io/legacy-docs/notifications/push-notifications-extension-legacy.html" }, { "source": "/notifications/email-notification-extension", - "destination": "/notifications/email-notifications-extension-legacy" + "destination": "https://assets.cometchat.io/legacy-docs/notifications/email-notifications-extension-legacy.html" }, { "source": "/notifications/sms-notification-extension", - "destination": "/notifications/sms-notifications-extension-legacy" - }, - { - "source": "/notifications/react-native-push-notifications", - "destination": "/notifications/react-native-push-notifications-android" + "destination": "https://assets.cometchat.io/legacy-docs/notifications/sms-notifications-extension-legacy.html" }, { "source": "/sdk/ionic/overview", - "destination": "/sdk/ionic-legacy/overview" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/overview.html" }, { "source": "/sdk/ionic/key-concepts", - "destination": "/sdk/ionic-legacy/key-concepts" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/key-concepts.html" }, { "source": "/sdk/ionic/message-structure-and-hierarchy", - "destination": "/sdk/ionic-legacy/message-structure-and-hierarchy" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/message-structure-and-hierarchy.html" }, { "source": "/sdk/ionic/rate-limits", - "destination": "/sdk/ionic-legacy/rate-limits" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/rate-limits.html" }, { "source": "/sdk/ionic/setup", - "destination": "/sdk/ionic-legacy/setup" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/setup.html" }, { "source": "/sdk/ionic/authentication", - "destination": "/sdk/ionic-legacy/authentication" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/authentication.html" }, { "source": "/sdk/ionic/login-listeners", - "destination": "/sdk/ionic-legacy/login-listeners" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/login-listeners.html" }, { "source": "/sdk/ionic/messaging-overview", - "destination": "/sdk/ionic-legacy/messaging-overview" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/messaging-overview.html" }, { "source": "/sdk/ionic/send-message", - "destination": "/sdk/ionic-legacy/send-message" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/send-message.html" }, { "source": "/sdk/ionic/receive-messages", - "destination": "/sdk/ionic-legacy/receive-messages" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/receive-messages.html" }, { "source": "/sdk/ionic/additional-message-filtering", - "destination": "/sdk/ionic-legacy/additional-message-filtering" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/additional-message-filtering.html" }, { "source": "/sdk/ionic/retrieve-conversations", - "destination": "/sdk/ionic-legacy/retrieve-conversations" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/retrieve-conversations.html" }, { "source": "/sdk/ionic/threaded-messages", - "destination": "/sdk/ionic-legacy/threaded-messages" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/threaded-messages.html" }, { "source": "/sdk/ionic/edit-message", - "destination": "/sdk/ionic-legacy/edit-message" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/edit-message.html" }, { "source": "/sdk/ionic/delete-message", - "destination": "/sdk/ionic-legacy/delete-message" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/delete-message.html" }, { "source": "/sdk/ionic/delete-conversation", - "destination": "/sdk/ionic-legacy/delete-conversation" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/delete-conversation.html" }, { "source": "/sdk/ionic/typing-indicators", - "destination": "/sdk/ionic-legacy/typing-indicators" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/typing-indicators.html" }, { "source": "/sdk/ionic/interactive-messages", - "destination": "/sdk/ionic-legacy/interactive-messages" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/interactive-messages.html" }, { "source": "/sdk/ionic/transient-messages", - "destination": "/sdk/ionic-legacy/transient-messages" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/transient-messages.html" }, { "source": "/sdk/ionic/delivery-read-receipts", - "destination": "/sdk/ionic-legacy/delivery-read-receipts" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/delivery-read-receipts.html" }, { "source": "/sdk/ionic/mentions", - "destination": "/sdk/ionic-legacy/mentions" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/mentions.html" }, { "source": "/sdk/ionic/reactions", - "destination": "/sdk/ionic-legacy/reactions" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/reactions.html" }, { "source": "/sdk/ionic/calling-overview", - "destination": "/calls/v4/javascript/overview" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/calling-overview.html" }, { "source": "/sdk/ionic/calling-setup", - "destination": "/calls/v4/javascript/setup" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/calling-setup.html" }, { "source": "/sdk/ionic/default-call", - "destination": "/calls/v4/javascript/ringing" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/default-call.html" }, { "source": "/sdk/ionic/direct-call", - "destination": "/calls/v4/javascript/call-session" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/direct-call.html" }, { "source": "/sdk/ionic/video-view-customisation", - "destination": "/calls/v4/javascript/video-view-customisation" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/video-view-customisation.html" }, { "source": "/sdk/ionic/recording", - "destination": "/calls/v4/javascript/recording" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/recording.html" }, { "source": "/sdk/ionic/presenter-mode", - "destination": "/calls/v4/javascript/presenter-mode" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/presenter-mode.html" }, { "source": "/sdk/ionic/users-overview", - "destination": "/sdk/ionic-legacy/users-overview" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/users-overview.html" }, { "source": "/sdk/ionic/retrieve-users", - "destination": "/sdk/ionic-legacy/retrieve-users" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/retrieve-users.html" }, { "source": "/sdk/ionic/user-management", - "destination": "/sdk/ionic-legacy/user-management" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/user-management.html" }, { "source": "/sdk/ionic/block-users", - "destination": "/sdk/ionic-legacy/block-users" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/block-users.html" }, { "source": "/sdk/ionic/user-presence", - "destination": "/sdk/ionic-legacy/user-presence" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/user-presence.html" }, { "source": "/sdk/ionic/groups-overview", - "destination": "/sdk/ionic-legacy/groups-overview" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/groups-overview.html" }, { "source": "/sdk/ionic/retrieve-groups", - "destination": "/sdk/ionic-legacy/retrieve-groups" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/retrieve-groups.html" }, { "source": "/sdk/ionic/create-group", - "destination": "/sdk/ionic-legacy/create-group" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/create-group.html" }, { "source": "/sdk/ionic/update-group", - "destination": "/sdk/ionic-legacy/update-group" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/update-group.html" }, { "source": "/sdk/ionic/join-group", - "destination": "/sdk/ionic-legacy/join-group" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/join-group.html" }, { "source": "/sdk/ionic/leave-group", - "destination": "/sdk/ionic-legacy/leave-group" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/leave-group.html" }, { "source": "/sdk/ionic/delete-group", - "destination": "/sdk/ionic-legacy/delete-group" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/delete-group.html" }, { "source": "/sdk/ionic/retrieve-group-members", - "destination": "/sdk/ionic-legacy/retrieve-group-members" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/retrieve-group-members.html" }, { "source": "/sdk/ionic/group-add-members", - "destination": "/sdk/ionic-legacy/group-add-members" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/group-add-members.html" }, { "source": "/sdk/ionic/group-kick-member", - "destination": "/sdk/ionic-legacy/group-kick-member" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/group-kick-member.html" }, { "source": "/sdk/ionic/group-change-member-scope", - "destination": "/sdk/ionic-legacy/group-change-member-scope" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/group-change-member-scope.html" }, { "source": "/sdk/ionic/transfer-group-ownership", - "destination": "/sdk/ionic-legacy/transfer-group-ownership" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/transfer-group-ownership.html" }, { "source": "/sdk/ionic/resources-overview", - "destination": "/sdk/ionic-legacy/resources-overview" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/resources-overview.html" }, { "source": "/sdk/ionic/real-time-listeners", - "destination": "/sdk/ionic-legacy/real-time-listeners" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/real-time-listeners.html" }, { "source": "/sdk/ionic/upgrading-from-v3-guide", - "destination": "/sdk/ionic-legacy/upgrading-from-v3-guide" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/upgrading-from-v3-guide.html" }, { "source": "/sdk/ionic/advanced", - "destination": "/sdk/ionic-legacy/advanced" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/advanced.html" }, { "source": "/sdk/ionic/connection-behaviour", - "destination": "/sdk/ionic-legacy/connection-behaviour" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/connection-behaviour.html" }, { "source": "/sdk/ionic/connection-status", - "destination": "/sdk/ionic-legacy/connection-status" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/connection-status.html" }, { "source": "/sdk/ionic/managing-connections-manually", - "destination": "/sdk/ionic-legacy/managing-connections-manually" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/managing-connections-manually.html" }, { "source": "/sdk/ionic/extensions-overview", - "destination": "/sdk/ionic-legacy/extensions-overview" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/extensions-overview.html" }, { "source": "/sdk/ionic/webhooks-overview", - "destination": "/sdk/ionic-legacy/webhooks-overview" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/webhooks-overview.html" }, { "source": "/sdk/ionic/ai-chatbots-overview", - "destination": "/sdk/ionic-legacy/ai-chatbots-overview" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/ai-chatbots-overview.html" }, { "source": "/sdk/ionic/ai-user-copilot-overview", - "destination": "/sdk/ionic-legacy/ai-user-copilot-overview" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/ai-user-copilot-overview.html" }, { "source": "/sdk/ionic/changelog", - "destination": "/sdk/ionic-legacy/changelog" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/changelog.html" }, { "source": "/sdk/ionic/2.0/overview", - "destination": "/sdk/ionic-legacy/2.0/overview" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/overview.html" }, { "source": "/sdk/ionic/2.0/key-concepts", - "destination": "/sdk/ionic-legacy/2.0/key-concepts" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/key-concepts.html" }, { "source": "/sdk/ionic/2.0/message-structure-and-hierarchy", - "destination": "/sdk/ionic-legacy/2.0/message-structure-and-hierarchy" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/message-structure-and-hierarchy.html" }, { "source": "/sdk/ionic/2.0/rate-limits", - "destination": "/sdk/ionic-legacy/2.0/rate-limits" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/rate-limits.html" }, { "source": "/sdk/ionic/2.0/setup", - "destination": "/sdk/ionic-legacy/2.0/setup" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/setup.html" }, { "source": "/sdk/ionic/2.0/authentication", - "destination": "/sdk/ionic-legacy/2.0/authentication" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/authentication.html" }, { "source": "/sdk/ionic/2.0/authentication-login-listeners", - "destination": "/sdk/ionic-legacy/2.0/authentication-login-listeners" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/authentication-login-listeners.html" }, { "source": "/sdk/ionic/2.0/messaging", - "destination": "/sdk/ionic-legacy/2.0/messaging" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/messaging.html" }, { "source": "/sdk/ionic/2.0/messaging-send-message", - "destination": "/sdk/ionic-legacy/2.0/messaging-send-message" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/messaging-send-message.html" }, { "source": "/sdk/ionic/2.0/messaging-receive-messages", - "destination": "/sdk/ionic-legacy/2.0/messaging-receive-messages" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/messaging-receive-messages.html" }, { "source": "/sdk/ionic/2.0/messaging-additional-message-filtering", - "destination": "/sdk/ionic-legacy/2.0/messaging-additional-message-filtering" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/messaging-additional-message-filtering.html" }, { "source": "/sdk/ionic/2.0/messaging-retrieve-conversations", - "destination": "/sdk/ionic-legacy/2.0/messaging-retrieve-conversations" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/messaging-retrieve-conversations.html" }, { "source": "/sdk/ionic/2.0/threaded-messages", - "destination": "/sdk/ionic-legacy/2.0/threaded-messages" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/threaded-messages.html" }, { "source": "/sdk/ionic/2.0/messaging-edit-message", - "destination": "/sdk/ionic-legacy/2.0/messaging-edit-message" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/messaging-edit-message.html" }, { "source": "/sdk/ionic/2.0/messaging-delete-message", - "destination": "/sdk/ionic-legacy/2.0/messaging-delete-message" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/messaging-delete-message.html" }, { "source": "/sdk/ionic/2.0/messaging-delete-conversation", - "destination": "/sdk/ionic-legacy/2.0/messaging-delete-conversation" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/messaging-delete-conversation.html" }, { "source": "/sdk/ionic/2.0/messaging-typing-indicators", - "destination": "/sdk/ionic-legacy/2.0/messaging-typing-indicators" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/messaging-typing-indicators.html" }, { "source": "/sdk/ionic/2.0/messaging-receipts", - "destination": "/sdk/ionic-legacy/2.0/messaging-receipts" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/messaging-receipts.html" }, { "source": "/sdk/ionic/2.0/calling", - "destination": "/sdk/ionic-legacy/2.0/calling" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/calling.html" }, { "source": "/sdk/ionic/2.0/calling-default-calling", - "destination": "/sdk/ionic-legacy/2.0/calling-default-calling" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/calling-default-calling.html" }, { "source": "/sdk/ionic/2.0/calling-direct-calling", - "destination": "/sdk/ionic-legacy/2.0/calling-direct-calling" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/calling-direct-calling.html" }, { "source": "/sdk/ionic/2.0/users", - "destination": "/sdk/ionic-legacy/2.0/users" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/users.html" }, { "source": "/sdk/ionic/2.0/users-retrieve-users", - "destination": "/sdk/ionic-legacy/2.0/users-retrieve-users" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/users-retrieve-users.html" }, { "source": "/sdk/ionic/2.0/users-user-management", - "destination": "/sdk/ionic-legacy/2.0/users-user-management" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/users-user-management.html" }, { "source": "/sdk/ionic/2.0/users-block-users", - "destination": "/sdk/ionic-legacy/2.0/users-block-users" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/users-block-users.html" }, { "source": "/sdk/ionic/2.0/user-presence", - "destination": "/sdk/ionic-legacy/2.0/user-presence" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/user-presence.html" }, { "source": "/sdk/ionic/2.0/groups", - "destination": "/sdk/ionic-legacy/2.0/groups" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups.html" }, { "source": "/sdk/ionic/2.0/groups-retrieve-groups", - "destination": "/sdk/ionic-legacy/2.0/groups-retrieve-groups" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups-retrieve-groups.html" }, { "source": "/sdk/ionic/2.0/groups-create-group", - "destination": "/sdk/ionic-legacy/2.0/groups-create-group" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups-create-group.html" }, { "source": "/sdk/ionic/2.0/groups-update-group", - "destination": "/sdk/ionic-legacy/2.0/groups-update-group" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups-update-group.html" }, { "source": "/sdk/ionic/2.0/groups-join-group", - "destination": "/sdk/ionic-legacy/2.0/groups-join-group" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups-join-group.html" }, { "source": "/sdk/ionic/2.0/groups-leave-group", - "destination": "/sdk/ionic-legacy/2.0/groups-leave-group" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups-leave-group.html" }, { "source": "/sdk/ionic/2.0/groups-delete-group", - "destination": "/sdk/ionic-legacy/2.0/groups-delete-group" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups-delete-group.html" }, { "source": "/sdk/ionic/2.0/groups-retrieve-group-members", - "destination": "/sdk/ionic-legacy/2.0/groups-retrieve-group-members" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups-retrieve-group-members.html" }, { "source": "/sdk/ionic/2.0/groups-add-members-to-group", - "destination": "/sdk/ionic-legacy/2.0/groups-add-members-to-group" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups-add-members-to-group.html" }, { "source": "/sdk/ionic/2.0/groups-kick-ban-members", - "destination": "/sdk/ionic-legacy/2.0/groups-kick-ban-members" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups-kick-ban-members.html" }, { "source": "/sdk/ionic/2.0/groups-change-member-scope", - "destination": "/sdk/ionic-legacy/2.0/groups-change-member-scope" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups-change-member-scope.html" }, { "source": "/sdk/ionic/2.0/groups-transfer-group-ownership", - "destination": "/sdk/ionic-legacy/2.0/groups-transfer-group-ownership" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/groups-transfer-group-ownership.html" }, { "source": "/sdk/ionic/2.0/resources", - "destination": "/sdk/ionic-legacy/2.0/resources" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/resources.html" }, { "source": "/sdk/ionic/2.0/resources-all-real-time-listeners", - "destination": "/sdk/ionic-legacy/2.0/resources-all-real-time-listeners" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/resources-all-real-time-listeners.html" }, { "source": "/sdk/ionic/2.0/resources-upgrading-from-v1", - "destination": "/sdk/ionic-legacy/2.0/resources-upgrading-from-v1" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/resources-upgrading-from-v1.html" }, { "source": "/sdk/ionic/2.0/advanced", - "destination": "/sdk/ionic-legacy/2.0/advanced" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/advanced.html" }, { "source": "/sdk/ionic/2.0/advanced-connection-listener", - "destination": "/sdk/ionic-legacy/2.0/advanced-connection-listener" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/advanced-connection-listener.html" }, { "source": "/sdk/ionic/2.0/webhooks", - "destination": "/sdk/ionic-legacy/2.0/webhooks" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/webhooks.html" }, { "source": "/sdk/ionic/2.0/bots", - "destination": "/sdk/ionic-legacy/2.0/bots" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/bots.html" }, { "source": "/sdk/ionic/3.0/overview", - "destination": "/sdk/ionic-legacy/3.0/overview" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/overview.html" }, { "source": "/sdk/ionic/3.0/key-concepts", - "destination": "/sdk/ionic-legacy/3.0/key-concepts" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/key-concepts.html" }, { "source": "/sdk/ionic/3.0/message-structure-and-hierarchy", - "destination": "/sdk/ionic-legacy/3.0/message-structure-and-hierarchy" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/message-structure-and-hierarchy.html" }, { "source": "/sdk/ionic/3.0/rate-limits", - "destination": "/sdk/ionic-legacy/3.0/rate-limits" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/rate-limits.html" }, { "source": "/sdk/ionic/3.0/setup", - "destination": "/sdk/ionic-legacy/3.0/setup" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/setup.html" }, { "source": "/sdk/ionic/3.0/authentication", - "destination": "/sdk/ionic-legacy/3.0/authentication" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/authentication.html" }, { "source": "/sdk/ionic/3.0/authentication-login-listeners", - "destination": "/sdk/ionic-legacy/3.0/authentication-login-listeners" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/authentication-login-listeners.html" }, { "source": "/sdk/ionic/3.0/messaging", - "destination": "/sdk/ionic-legacy/3.0/messaging" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/messaging.html" }, { "source": "/sdk/ionic/3.0/messaging-send-message", - "destination": "/sdk/ionic-legacy/3.0/messaging-send-message" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/messaging-send-message.html" }, { "source": "/sdk/ionic/3.0/messaging-receive-messages", - "destination": "/sdk/ionic-legacy/3.0/messaging-receive-messages" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/messaging-receive-messages.html" }, { "source": "/sdk/ionic/3.0/messaging-additional-message-filtering", - "destination": "/sdk/ionic-legacy/3.0/messaging-additional-message-filtering" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/messaging-additional-message-filtering.html" }, { "source": "/sdk/ionic/3.0/messaging-retrieve-conversations", - "destination": "/sdk/ionic-legacy/3.0/messaging-retrieve-conversations" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/messaging-retrieve-conversations.html" }, { "source": "/sdk/ionic/3.0/threaded-messages", - "destination": "/sdk/ionic-legacy/3.0/threaded-messages" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/threaded-messages.html" }, { "source": "/sdk/ionic/3.0/transient-messages", - "destination": "/sdk/ionic-legacy/3.0/transient-messages" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/transient-messages.html" }, { "source": "/sdk/ionic/3.0/messaging-edit-message", - "destination": "/sdk/ionic-legacy/3.0/messaging-edit-message" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/messaging-edit-message.html" }, { "source": "/sdk/ionic/3.0/messaging-delete-message", - "destination": "/sdk/ionic-legacy/3.0/messaging-delete-message" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/messaging-delete-message.html" }, { "source": "/sdk/ionic/3.0/messaging-delete-conversation", - "destination": "/sdk/ionic-legacy/3.0/messaging-delete-conversation" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/messaging-delete-conversation.html" }, { "source": "/sdk/ionic/3.0/messaging-typing-indicators", - "destination": "/sdk/ionic-legacy/3.0/messaging-typing-indicators" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/messaging-typing-indicators.html" }, { "source": "/sdk/ionic/3.0/messaging-receipts", - "destination": "/sdk/ionic-legacy/3.0/messaging-receipts" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/messaging-receipts.html" }, { "source": "/sdk/ionic/3.0/calling", - "destination": "/sdk/ionic-legacy/3.0/calling" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/calling.html" }, { "source": "/sdk/ionic/3.0/calling-default-calling", - "destination": "/sdk/ionic-legacy/3.0/calling-default-calling" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/calling-default-calling.html" }, { "source": "/sdk/ionic/3.0/calling-direct-calling", - "destination": "/sdk/ionic-legacy/3.0/calling-direct-calling" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/calling-direct-calling.html" }, { "source": "/sdk/ionic/3.0/calling-recording", - "destination": "/sdk/ionic-legacy/3.0/calling-recording" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/calling-recording.html" }, { "source": "/sdk/ionic/3.0/calling-v3", - "destination": "/sdk/ionic-legacy/3.0/calling-v3" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/calling-v3.html" }, { "source": "/sdk/ionic/3.0/v3-setup", - "destination": "/sdk/ionic-legacy/3.0/v3-setup" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/v3-setup.html" }, { "source": "/sdk/ionic/3.0/v3-start-call-session", - "destination": "/sdk/ionic-legacy/3.0/v3-start-call-session" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/v3-start-call-session.html" }, { "source": "/sdk/ionic/3.0/v3-video-view-customisation", - "destination": "/sdk/ionic-legacy/3.0/v3-video-view-customisation" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/v3-video-view-customisation.html" }, { "source": "/sdk/ionic/3.0/v3-calling-recording", - "destination": "/sdk/ionic-legacy/3.0/v3-calling-recording" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/v3-calling-recording.html" }, { "source": "/sdk/ionic/3.0/video-view-customisation", - "destination": "/sdk/ionic-legacy/3.0/video-view-customisation" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/video-view-customisation.html" }, { "source": "/sdk/ionic/3.0/users", - "destination": "/sdk/ionic-legacy/3.0/users" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/users.html" }, { "source": "/sdk/ionic/3.0/users-retrieve-users", - "destination": "/sdk/ionic-legacy/3.0/users-retrieve-users" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/users-retrieve-users.html" }, { "source": "/sdk/ionic/3.0/users-user-management", - "destination": "/sdk/ionic-legacy/3.0/users-user-management" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/users-user-management.html" }, { "source": "/sdk/ionic/3.0/users-block-users", - "destination": "/sdk/ionic-legacy/3.0/users-block-users" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/users-block-users.html" }, { "source": "/sdk/ionic/3.0/user-presence", - "destination": "/sdk/ionic-legacy/3.0/user-presence" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/user-presence.html" }, { "source": "/sdk/ionic/3.0/groups", - "destination": "/sdk/ionic-legacy/3.0/groups" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups.html" }, { "source": "/sdk/ionic/3.0/groups-retrieve-groups", - "destination": "/sdk/ionic-legacy/3.0/groups-retrieve-groups" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups-retrieve-groups.html" }, { "source": "/sdk/ionic/3.0/groups-create-group", - "destination": "/sdk/ionic-legacy/3.0/groups-create-group" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups-create-group.html" }, { "source": "/sdk/ionic/3.0/groups-update-group", - "destination": "/sdk/ionic-legacy/3.0/groups-update-group" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups-update-group.html" }, { "source": "/sdk/ionic/3.0/groups-join-group", - "destination": "/sdk/ionic-legacy/3.0/groups-join-group" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups-join-group.html" }, { "source": "/sdk/ionic/3.0/groups-leave-group", - "destination": "/sdk/ionic-legacy/3.0/groups-leave-group" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups-leave-group.html" }, { "source": "/sdk/ionic/3.0/groups-delete-group", - "destination": "/sdk/ionic-legacy/3.0/groups-delete-group" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups-delete-group.html" }, { "source": "/sdk/ionic/3.0/groups-retrieve-group-members", - "destination": "/sdk/ionic-legacy/3.0/groups-retrieve-group-members" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups-retrieve-group-members.html" }, { "source": "/sdk/ionic/3.0/groups-add-members-to-group", - "destination": "/sdk/ionic-legacy/3.0/groups-add-members-to-group" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups-add-members-to-group.html" }, { "source": "/sdk/ionic/3.0/groups-kick-ban-members", - "destination": "/sdk/ionic-legacy/3.0/groups-kick-ban-members" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups-kick-ban-members.html" }, { "source": "/sdk/ionic/3.0/groups-change-member-scope", - "destination": "/sdk/ionic-legacy/3.0/groups-change-member-scope" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups-change-member-scope.html" }, { "source": "/sdk/ionic/3.0/groups-transfer-group-ownership", - "destination": "/sdk/ionic-legacy/3.0/groups-transfer-group-ownership" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/groups-transfer-group-ownership.html" }, { "source": "/sdk/ionic/3.0/resources", - "destination": "/sdk/ionic-legacy/3.0/resources" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/resources.html" }, { "source": "/sdk/ionic/3.0/resources-all-real-time-listeners", - "destination": "/sdk/ionic-legacy/3.0/resources-all-real-time-listeners" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/resources-all-real-time-listeners.html" }, { "source": "/sdk/ionic/3.0/resources-upgrading-from-v2", - "destination": "/sdk/ionic-legacy/3.0/resources-upgrading-from-v2" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/resources-upgrading-from-v2.html" }, { "source": "/sdk/ionic/3.0/advanced", - "destination": "/sdk/ionic-legacy/3.0/advanced" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/advanced.html" }, { "source": "/sdk/ionic/3.0/advanced-connection-listener", - "destination": "/sdk/ionic-legacy/3.0/advanced-connection-listener" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/advanced-connection-listener.html" }, { "source": "/sdk/ionic/3.0/advanced-managing-web-socket-connections-manually", - "destination": "/sdk/ionic-legacy/3.0/advanced-managing-web-socket-connections-manually" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/advanced-managing-web-socket-connections-manually.html" }, { "source": "/sdk/ionic/3.0/webhooks", - "destination": "/sdk/ionic-legacy/3.0/webhooks" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/webhooks.html" }, { "source": "/sdk/ionic/3.0/bots", - "destination": "/sdk/ionic-legacy/3.0/bots" - }, - { - "source": "/sdk/javascript/calling-setup", - "destination": "/calls/v4/javascript/setup" - }, - { - "source": "/sdk/javascript/default-call", - "destination": "/calls/v4/javascript/ringing" - }, - { - "source": "/sdk/javascript/direct-call", - "destination": "/calls/v4/javascript/call-session" - }, - { - "source": "/sdk/javascript/standalone-calling", - "destination": "/calls/v4/javascript/standalone-calling" - }, - { - "source": "/sdk/javascript/recording", - "destination": "/calls/v4/javascript/recording" - }, - { - "source": "/sdk/javascript/virtual-background", - "destination": "/calls/v4/javascript/virtual-background" - }, - { - "source": "/sdk/javascript/video-view-customisation", - "destination": "/calls/v4/javascript/video-view-customisation" - }, - { - "source": "/sdk/javascript/custom-css", - "destination": "/calls/v4/javascript/custom-css" - }, - { - "source": "/sdk/javascript/presenter-mode", - "destination": "/calls/v4/javascript/presenter-mode" - }, - { - "source": "/sdk/javascript/call-logs", - "destination": "/calls/v4/javascript/call-logs" - }, - { - "source": "/sdk/javascript/session-timeout", - "destination": "/calls/v4/javascript/session-timeout" - }, - { - "source": "/sdk/react-native/calling-setup", - "destination": "/calls/v4/react-native/setup" - }, - { - "source": "/sdk/react-native/default-call", - "destination": "/calls/v4/react-native/ringing" - }, - { - "source": "/sdk/react-native/direct-call", - "destination": "/calls/v4/react-native/call-session" - }, - { - "source": "/sdk/react-native/standalone-calling", - "destination": "/calls/v4/react-native/standalone-calling" - }, - { - "source": "/sdk/react-native/recording", - "destination": "/calls/v4/react-native/recording" - }, - { - "source": "/sdk/react-native/video-view-customisation", - "destination": "/calls/v4/react-native/video-view-customisation" - }, - { - "source": "/sdk/react-native/presenter-mode", - "destination": "/calls/v4/react-native/presenter-mode" - }, - { - "source": "/sdk/react-native/call-logs", - "destination": "/calls/v4/react-native/call-logs" - }, - { - "source": "/sdk/react-native/expo-integration-guide", - "destination": "/calls/v4/react-native/expo-integration-guide" - }, - { - "source": "/sdk/react-native/session-timeout", - "destination": "/calls/v4/react-native/session-timeout" - }, - { - "source": "/sdk/ios/calling-setup", - "destination": "/calls/v4/ios/setup" - }, - { - "source": "/sdk/ios/default-calling", - "destination": "/calls/v4/ios/ringing" - }, - { - "source": "/sdk/ios/direct-calling", - "destination": "/calls/v4/ios/call-session" - }, - { - "source": "/sdk/ios/standalone-calling", - "destination": "/calls/v4/ios/standalone-calling" - }, - { - "source": "/sdk/ios/recording", - "destination": "/calls/v4/ios/recording" - }, - { - "source": "/sdk/ios/video-view-customisation", - "destination": "/calls/v4/ios/video-view-customisation" - }, - { - "source": "/sdk/ios/presenter-mode", - "destination": "/calls/v4/ios/presenter-mode" - }, - { - "source": "/sdk/ios/call-logs", - "destination": "/calls/v4/ios/call-logs" - }, - { - "source": "/sdk/ios/session-timeout", - "destination": "/calls/v4/ios/session-timeout" - }, - { - "source": "/sdk/ios/launch-call-screen-on-tap-of-push-notification", - "destination": "/calls/v4/ios/launch-call-screen-on-tap-of-push-notification" - }, - { - "source": "/sdk/android/calling-setup", - "destination": "/calls/v4/android/setup" - }, - { - "source": "/sdk/android/default-calling", - "destination": "/calls/v4/android/ringing" - }, - { - "source": "/sdk/android/direct-calling", - "destination": "/calls/v4/android/call-session" - }, - { - "source": "/sdk/android/standalone-calling", - "destination": "/calls/v4/android/standalone-calling" - }, - { - "source": "/sdk/android/recording", - "destination": "/calls/v4/android/recording" - }, - { - "source": "/sdk/android/video-view-customisation", - "destination": "/calls/v4/android/video-view-customisation" - }, - { - "source": "/sdk/android/presenter-mode", - "destination": "/calls/v4/android/presenter-mode" - }, - { - "source": "/sdk/android/call-logs", - "destination": "/calls/v4/android/call-logs" - }, - { - "source": "/sdk/android/session-timeout", - "destination": "/calls/v4/android/session-timeout" - }, - { - "source": "/sdk/flutter/calling-setup", - "destination": "/calls/v4/flutter/setup" - }, - { - "source": "/sdk/flutter/default-call", - "destination": "/calls/v4/flutter/ringing" - }, - { - "source": "/sdk/flutter/direct-call", - "destination": "/calls/v4/flutter/call-session" - }, - { - "source": "/sdk/flutter/standalone-calling", - "destination": "/calls/v4/flutter/standalone-calling" - }, - { - "source": "/sdk/flutter/video-view-customisation", - "destination": "/calls/v4/flutter/video-view-customisation" - }, - { - "source": "/sdk/flutter/recording", - "destination": "/calls/v4/flutter/recording" - }, - { - "source": "/sdk/flutter/presenter-mode", - "destination": "/calls/v4/flutter/presenter-mode" - }, - { - "source": "/sdk/flutter/call-logs", - "destination": "/calls/v4/flutter/call-logs" - }, - { - "source": "/sdk/flutter/session-timeout", - "destination": "/calls/v4/flutter/session-timeout" - }, - { - "source": "/sdk/ionic-legacy/calling-overview", - "destination": "/calls/v4/javascript/overview" - }, - { - "source": "/sdk/ionic-legacy/calling-setup", - "destination": "/calls/v4/javascript/setup" - }, - { - "source": "/sdk/ionic-legacy/default-call", - "destination": "/calls/v4/javascript/ringing" - }, - { - "source": "/sdk/ionic-legacy/direct-call", - "destination": "/calls/v4/javascript/call-session" - }, - { - "source": "/sdk/ionic-legacy/presenter-mode", - "destination": "/calls/v4/javascript/presenter-mode" - }, - { - "source": "/sdk/ionic-legacy/recording", - "destination": "/calls/v4/javascript/recording" - }, - { - "source": "/sdk/ionic-legacy/video-view-customisation", - "destination": "/calls/v4/javascript/video-view-customisation" + "destination": "https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/bots.html" } ], "integrations": { @@ -8159,7 +8263,7 @@ "metatags": { "charset": "UTF-8", "viewport": "width=device-width, initial-scale=1.0", - "description": "Learn how to integrate, customize, and scale real-time chat using CometChat\u2019s UI Kits, SDKs, and widgets across popular frameworks. Get step-by-step guides, best practices, and implementation details to build production-ready chat experiences.", + "description": "Learn how to integrate, customize, and scale real-time chat using CometChat’s UI Kits, SDKs, and widgets across popular frameworks. Get step-by-step guides, best practices, and implementation details to build production-ready chat experiences.", "language": "en" } }, diff --git a/fundamentals/webhooks-legacy.mdx b/fundamentals/webhooks-legacy.mdx deleted file mode 100644 index 44a02d0fa..000000000 --- a/fundamentals/webhooks-legacy.mdx +++ /dev/null @@ -1,306 +0,0 @@ ---- -title: "Webhooks (Legacy)" -sidebarTitle: "Webhooks (Legacy)" ---- - - - -**Legacy Notice**: Legacy extensions are no longer actively maintained and will not receive feature updates or enhancements. - -For new projects, use **[Webhooks](/fundamentals/webhooks-overview)**. - - - -CometChat legacy webhooks enable real-time event-driven communication with your system. They allow you to receive HTTP POST requests whenever specific events occur—such as sending a message or a user coming online. These webhooks are ideal for integrating external services like SMS, email, analytics, or auditing systems. - -*** - -## Webhook Endpoint Requirements - -To ensure reliable delivery and security, your webhook endpoint must meet the following requirements: - -1. **HTTPS required**: Your endpoint must use `HTTPS` to ensure secure data transmission. -2. **Public accessibility**: It must be accessible from the public internet. -3. **Support for POST requests**: The endpoint must accept `HTTP POST` requests with a `Content-Type` of `application/json`. -4. **Immediate acknowledgment**: Your server must respond with an `HTTP 200 OK` status quickly to acknowledge receipt. - -*** - -## Security - -It is strongly recommended to use **Basic Authentication** to protect your webhook endpoints. - -### Header format - -When enabled, every webhook request from CometChat will include the following HTTP header: - -```html -Authorization: Basic -``` - -> Set your username and password while configuring the webhook on the CometChat dashboard. - -*** - -## Legacy webhook events - -Below are the legacy webhook events supported by CometChat: - -| Event | Description | -| --- | --- | -| [before_message](#before_message) | Triggered when a message is in-flight—just before it is processed by CometChat. | -| [after_message](#after_message) | Triggered after a message has been successfully sent. | -| [message_delivery_receipt](#message_delivery_receipt) | Triggered when a message is marked as delivered to a user. | -| [message_read_receipt](#message_read_receipt) | Triggered when a message is marked as read by the recipient. | -| [user_connection_status_change](#user_connection_status_change) | Triggered when a user connects or disconnects from the CometChat platform. | - -*** - -## Manage legacy webhooks - -You can manage and configure legacy webhooks in CometChat either from the **dashboard UI** or programmatically via **Management APIs**. - -### Option 1: Manage from the dashboard - - - - - -### Steps - -1. Log in to your [CometChat Dashboard](https://app.cometchat.com/login) and select your app. -2. Go to **Settings** > **Legacy Webhooks** from the left menu. -3. Click on **Add New Webhook**. -4. Fill in the configuration: - * **Webhook ID**: A unique identifier for your webhook. - * **URL**: Endpoint where event payloads will be delivered. - * **Triggers**: Select the events you want to receive. - * **Security**: (Recommended) Enable authentication. -5. Enable the webhook. -6. Save the configuration. - -### Option 2: Manage via Management APIs - -CometChat also provides Management APIs to automate webhook and trigger management. - -#### Webhook management endpoints - -| Operation | API Reference | -| --- | --- | -| Create a new webhook | [Create Webhook](https://api-explorer.cometchat.com/reference/create-webhook) | -| Update an existing webhook | [Update Webhook](https://api-explorer.cometchat.com/reference/update-webhook) | -| List all webhooks | [List Webhooks](https://api-explorer.cometchat.com/reference/list-webhooks) | -| Get a webhook by ID | [Get Webhook](https://api-explorer.cometchat.com/reference/get-webhook) | -| Delete a webhook | [Delete Webhook](https://api-explorer.cometchat.com/reference/delete-webhook) | - -#### Trigger management endpoints - -| Operation | API Reference | -| --- | --- | -| Add triggers to a webhook | [Add Triggers](https://api-explorer.cometchat.com/reference/add-triggers) | -| List all triggers of a webhook | [List Triggers](https://api-explorer.cometchat.com/reference/list-triggers) | -| Remove triggers from a webhook | [Remove Triggers](https://api-explorer.cometchat.com/reference/remove-triggers) | - -*** - -## Event payloads - -### Message events - -#### before_message - -The endpoint will be triggered when a message is in-flight. - -```json -{ - "trigger": "before_message", - "data": { - "conversationId": "cometchat-uid-4_user_cometchat-uid-5", - "sender": "cometchat-uid-5", - "receiverType": "user", - "receiver": "cometchat-uid-4", - "category": "message", - "type": "text", - "data": { - "text": "Hi Webhook Test", - "entities": { - "sender": { - "entity": { - "uid": "cometchat-uid-5", - "name": "John Paul", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-5.webp", - "status": "offline", - "role": "default" - }, - "entityType": "user" - }, - "receiver": { - "entity": { - "uid": "cometchat-uid-4", - "name": "Susan Marie", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-4.webp", - "status": "offline", - "role": "default" - }, - "entityType": "user" - } - } - }, - "sentAt": 1586435925, - "updatedAt": 1586435925, - }, - "appId": "167*****1529", - "webhook": "send-message" -} -``` - -#### after_message - -The endpoint will be triggered after a message is sent. - -```json -{ - "trigger": "after_message", - "data": { - "id": "1", - "conversationId": "cometchat-uid-4_user_cometchat-uid-5", - "sender": "cometchat-uid-5", - "receiverType": "user", - "receiver": "cometchat-uid-4", - "category": "message", - "type": "text", - "data": { - "text": "Hi Webhook Test", - "entities": { - "sender": { - "entity": { - "uid": "cometchat-uid-5", - "name": "John Paul", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-5.webp", - "status": "offline", - "role": "default" - }, - "entityType": "user" - }, - "receiver": { - "entity": { - "uid": "cometchat-uid-4", - "name": "Susan Marie", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-4.webp", - "status": "offline", - "role": "default" - }, - "entityType": "user" - } - } - }, - "sentAt": 1586435925, - "updatedAt": 1586435925, - }, - "appId": "167*****1529", - "webhook": "send-message" -} -``` - -#### message_delivery_receipt - -The endpoint will be triggered when a message is marked delivered. - -```json -{ - "trigger": "message_delivery_receipt", - "appId": "167*****1529", - "origin": { - "platform": "WEBSOCKET" - }, - "chatAPIVersion?": "3.0", - "region?": "us|eu|other", - "webhook": "webhook_name", - "data": { - "messageId": "MESSAGE_ID", - "receiptType": "delivered", - "deliveredAt": 1673017183, - "messageSender":"messageSenderUID", - "receiptSender":"receiptSenderUID", - "receiptReceiver":"uid|guid", - "receiverType": "user|group" - } -} -``` - -#### message_read_receipt - -The endpoint will be triggered when a message is marked read. - -```json -{ - "trigger": "message_read_receipt", - "appId": "167*****1529", - "origin": { - "platform": "WEBSOCKET" - }, - "chatAPIVersion?": "3.0", - "region?": "us|eu|other", - "webhook": "webhook_name", - "data": { - "messageId": "MESSAGE_ID", - "receiptType": "read", - "readAt": 1673017183, - "messageSender":"messageSenderUID", - "receiptSender":"receiptSenderUID", - "receiptReceiver":"uid|guid", - "receiverType": "user|group" - } -} -``` - -### User-related events - -#### user_connection_status_change - -The endpoint will be triggered when a users logs in or logs out of CometChat. - -```json -{ - "trigger": "after_connection_status_changed", - "appId": "167*****1529", - "origin": { - "platform": "API|MGNT-API|WEBSOCKET|WEBRTC" - }, - "chatAPIVersion?": "3.0", - "region?": "us|eu|other", - "webhook": "webhook_name", - "data": { - "user": { - "uid": "uid of the user", - "status": "online|offline", - "status_updated": true, - "status_updated_at": "unixtimestamp in millisec" - }, - "event": { - "type": "connected|disconnected", - "at": "unixtimestamp in millisec", - "event_for": { - "connected_at": "unixtimestamp in millisec", - "cometchat_device_id": "unique device id used by cometchat to identify the device(random string)", - "session_id": "unique id to indetify the unique session of users", - "platform": "android|ios|web" - } - }, - "connections": [ - { - "connected_at": "unixtimestamp in millisec", - "cometchat_device_id": "unique device id used by cometchat to identify the device(random string)", - "session_id": "unique id to indetify the unique session of users", - "platform": "android|ios|web" - }, - { - "connected_at": "unixtimestamp in millisec", - "cometchat_device_id": "unique device id used by cometchat to identify the device(random string)", - "session_id": "unique id to indetify the unique session of users", - "platform": "android|ios|web" - } - ] - } -} -``` diff --git a/images/01a6f1df-1633625271-66d7d5dd85f4470c655d902bf7fa85bd.png b/images/01a6f1df-1633625271-66d7d5dd85f4470c655d902bf7fa85bd.png deleted file mode 100644 index 3c8f20845..000000000 Binary files a/images/01a6f1df-1633625271-66d7d5dd85f4470c655d902bf7fa85bd.png and /dev/null differ diff --git a/images/0380f9ce-1640937733-db13c95c4dba1700cb3e9ad7016fb18c.png b/images/0380f9ce-1640937733-db13c95c4dba1700cb3e9ad7016fb18c.png deleted file mode 100644 index 280c98804..000000000 Binary files a/images/0380f9ce-1640937733-db13c95c4dba1700cb3e9ad7016fb18c.png and /dev/null differ diff --git a/images/058eddb7-1623199683-a8b0e22509052b609197e049e75433c9.png b/images/058eddb7-1623199683-a8b0e22509052b609197e049e75433c9.png deleted file mode 100644 index 8a1309730..000000000 Binary files a/images/058eddb7-1623199683-a8b0e22509052b609197e049e75433c9.png and /dev/null differ diff --git a/images/06ec41e4-1623199646-7ba0cb45f033b090fc49ddb715b0cb2b.png b/images/06ec41e4-1623199646-7ba0cb45f033b090fc49ddb715b0cb2b.png deleted file mode 100644 index 911a27152..000000000 Binary files a/images/06ec41e4-1623199646-7ba0cb45f033b090fc49ddb715b0cb2b.png and /dev/null differ diff --git a/images/0a8f7530-1640937388-8cffb5a81bcc1431e73ab3572da610b8.png b/images/0a8f7530-1640937388-8cffb5a81bcc1431e73ab3572da610b8.png deleted file mode 100644 index 855a4e0b3..000000000 Binary files a/images/0a8f7530-1640937388-8cffb5a81bcc1431e73ab3572da610b8.png and /dev/null differ diff --git a/images/0b8820c9-1640937745-015a5fd67f1185d1b2d0272be3252a06.png b/images/0b8820c9-1640937745-015a5fd67f1185d1b2d0272be3252a06.png deleted file mode 100644 index a1a9af482..000000000 Binary files a/images/0b8820c9-1640937745-015a5fd67f1185d1b2d0272be3252a06.png and /dev/null differ diff --git a/images/0ceb56ea-1623199669-c7940d862ba1d4156d25a13a5fb7be65.png b/images/0ceb56ea-1623199669-c7940d862ba1d4156d25a13a5fb7be65.png deleted file mode 100644 index af90fc173..000000000 Binary files a/images/0ceb56ea-1623199669-c7940d862ba1d4156d25a13a5fb7be65.png and /dev/null differ diff --git a/images/0d35bb99-1623199728-68f98b21a400a8e2f124b585329243d0.png b/images/0d35bb99-1623199728-68f98b21a400a8e2f124b585329243d0.png deleted file mode 100644 index 4c27d53bf..000000000 Binary files a/images/0d35bb99-1623199728-68f98b21a400a8e2f124b585329243d0.png and /dev/null differ diff --git a/images/0d943138-1623199638-069f938ce1a6ea29b93c1986bc423b5f.png b/images/0d943138-1623199638-069f938ce1a6ea29b93c1986bc423b5f.png deleted file mode 100644 index d071d5f78..000000000 Binary files a/images/0d943138-1623199638-069f938ce1a6ea29b93c1986bc423b5f.png and /dev/null differ diff --git a/images/0fff2c6d-cometchat-widget-install-6d0bf8af5fdc5e2771a0e51cda2088d8.png b/images/0fff2c6d-cometchat-widget-install-6d0bf8af5fdc5e2771a0e51cda2088d8.png deleted file mode 100644 index 8b259ca6e..000000000 Binary files a/images/0fff2c6d-cometchat-widget-install-6d0bf8af5fdc5e2771a0e51cda2088d8.png and /dev/null differ diff --git a/images/106be116-UAAAAYdEVYdGV4aWY6UGl4ZWxZRGltZW5zaW9uADIxN14Eu6AAAAAASUVORK5CYII.png b/images/106be116-UAAAAYdEVYdGV4aWY6UGl4ZWxZRGltZW5zaW9uADIxN14Eu6AAAAAASUVORK5CYII.png deleted file mode 100644 index ca5b9da67..000000000 Binary files a/images/106be116-UAAAAYdEVYdGV4aWY6UGl4ZWxZRGltZW5zaW9uADIxN14Eu6AAAAAASUVORK5CYII.png and /dev/null differ diff --git a/images/10dbaaf4-cometchat-push-notifications-extension-settings-payload-message-options-28494a3c1ed3d9e7a65dd171d17cb12d.png b/images/10dbaaf4-cometchat-push-notifications-extension-settings-payload-message-options-28494a3c1ed3d9e7a65dd171d17cb12d.png deleted file mode 100644 index 5796547d6..000000000 Binary files a/images/10dbaaf4-cometchat-push-notifications-extension-settings-payload-message-options-28494a3c1ed3d9e7a65dd171d17cb12d.png and /dev/null differ diff --git a/images/1113dedb-1625144671-6c9feb22a7b924a9860c3f0cff84410e.png b/images/1113dedb-1625144671-6c9feb22a7b924a9860c3f0cff84410e.png deleted file mode 100644 index 5bd36c21c..000000000 Binary files a/images/1113dedb-1625144671-6c9feb22a7b924a9860c3f0cff84410e.png and /dev/null differ diff --git a/images/172b8bc9-1640937429-b6b2a668b555f2111586c2baf8ac8316.png b/images/172b8bc9-1640937429-b6b2a668b555f2111586c2baf8ac8316.png deleted file mode 100644 index 1523787b7..000000000 Binary files a/images/172b8bc9-1640937429-b6b2a668b555f2111586c2baf8ac8316.png and /dev/null differ diff --git a/images/1838e7dc-1623199715-b21bded8a4ec5a159e9249376d0108a2.png b/images/1838e7dc-1623199715-b21bded8a4ec5a159e9249376d0108a2.png deleted file mode 100644 index 3602910d6..000000000 Binary files a/images/1838e7dc-1623199715-b21bded8a4ec5a159e9249376d0108a2.png and /dev/null differ diff --git a/images/1a70cb4c-1625144352-1c58c7254e4d9f911f2ae456c4f518cb.png b/images/1a70cb4c-1625144352-1c58c7254e4d9f911f2ae456c4f518cb.png deleted file mode 100644 index 1fba2e56d..000000000 Binary files a/images/1a70cb4c-1625144352-1c58c7254e4d9f911f2ae456c4f518cb.png and /dev/null differ diff --git a/images/1d356809-cometchat-widget-wordpress-dashboard-plugin-settings-407485c995256f92e063ea4996e2a3de.png b/images/1d356809-cometchat-widget-wordpress-dashboard-plugin-settings-407485c995256f92e063ea4996e2a3de.png deleted file mode 100644 index 60d73ac7f..000000000 Binary files a/images/1d356809-cometchat-widget-wordpress-dashboard-plugin-settings-407485c995256f92e063ea4996e2a3de.png and /dev/null differ diff --git a/images/22087faf-cometchat-dashboard-widget-landing-page-d80347fbe5aaaf9e51f67caace0e114c.png b/images/22087faf-cometchat-dashboard-widget-landing-page-d80347fbe5aaaf9e51f67caace0e114c.png deleted file mode 100644 index 2021f7c73..000000000 Binary files a/images/22087faf-cometchat-dashboard-widget-landing-page-d80347fbe5aaaf9e51f67caace0e114c.png and /dev/null differ diff --git a/images/23b8b8d4-cometchat-widget-wordpress-dashboard-plugin-activate-plugin-e56f4c6475294768f1d3ebdccfcb6c09.png b/images/23b8b8d4-cometchat-widget-wordpress-dashboard-plugin-activate-plugin-e56f4c6475294768f1d3ebdccfcb6c09.png deleted file mode 100644 index 1d000c9ae..000000000 Binary files a/images/23b8b8d4-cometchat-widget-wordpress-dashboard-plugin-activate-plugin-e56f4c6475294768f1d3ebdccfcb6c09.png and /dev/null differ diff --git a/images/2465097e-1640937784-595c3a354a910eaf3e93a4c732160e96.png b/images/2465097e-1640937784-595c3a354a910eaf3e93a4c732160e96.png deleted file mode 100644 index 81be72534..000000000 Binary files a/images/2465097e-1640937784-595c3a354a910eaf3e93a4c732160e96.png and /dev/null differ diff --git a/images/2836ba6c-cometchat-firebase-get-service-account-3ed293fb42bfd421d5127639f2857277.png b/images/2836ba6c-cometchat-firebase-get-service-account-3ed293fb42bfd421d5127639f2857277.png deleted file mode 100644 index 83df9da27..000000000 Binary files a/images/2836ba6c-cometchat-firebase-get-service-account-3ed293fb42bfd421d5127639f2857277.png and /dev/null differ diff --git a/images/292ffc0c-1623199626-8fcde69272b0f25055ce10fa4e65f790.png b/images/292ffc0c-1623199626-8fcde69272b0f25055ce10fa4e65f790.png deleted file mode 100644 index aae209d14..000000000 Binary files a/images/292ffc0c-1623199626-8fcde69272b0f25055ce10fa4e65f790.png and /dev/null differ diff --git a/images/2b2f10a0-1623199729-ff39ea8363485acfdf5c2625e9676556.png b/images/2b2f10a0-1623199729-ff39ea8363485acfdf5c2625e9676556.png deleted file mode 100644 index ec08e0dce..000000000 Binary files a/images/2b2f10a0-1623199729-ff39ea8363485acfdf5c2625e9676556.png and /dev/null differ diff --git a/images/2e1fde5b-1623199699-d8679c0055666a6a84430c01acf1f91c.png b/images/2e1fde5b-1623199699-d8679c0055666a6a84430c01acf1f91c.png deleted file mode 100644 index 28bd798c4..000000000 Binary files a/images/2e1fde5b-1623199699-d8679c0055666a6a84430c01acf1f91c.png and /dev/null differ diff --git a/images/3207f2a4-6k068nprjmachrszi9ckyzgqxbf1rmc98asy5d09yhktx37v0pyxf6wxmufg2jci-4ab4b9056ff91b946fb2fc048bc764fa.png b/images/3207f2a4-6k068nprjmachrszi9ckyzgqxbf1rmc98asy5d09yhktx37v0pyxf6wxmufg2jci-4ab4b9056ff91b946fb2fc048bc764fa.png deleted file mode 100644 index 93f3f8382..000000000 Binary files a/images/3207f2a4-6k068nprjmachrszi9ckyzgqxbf1rmc98asy5d09yhktx37v0pyxf6wxmufg2jci-4ab4b9056ff91b946fb2fc048bc764fa.png and /dev/null differ diff --git a/images/3d57f724-1623199661-12cb6d7fab6a98b2e70e66862265ab13.png b/images/3d57f724-1623199661-12cb6d7fab6a98b2e70e66862265ab13.png deleted file mode 100644 index 2a6013cf7..000000000 Binary files a/images/3d57f724-1623199661-12cb6d7fab6a98b2e70e66862265ab13.png and /dev/null differ diff --git a/images/42540588-t1mk6nfkkpy7fipuzeupl1oognnhmjuw3vdivlhg0t8turw7okuiwenncydrc83q-4ab4b9056ff91b946fb2fc048bc764fa.png b/images/42540588-t1mk6nfkkpy7fipuzeupl1oognnhmjuw3vdivlhg0t8turw7okuiwenncydrc83q-4ab4b9056ff91b946fb2fc048bc764fa.png deleted file mode 100644 index 93f3f8382..000000000 Binary files a/images/42540588-t1mk6nfkkpy7fipuzeupl1oognnhmjuw3vdivlhg0t8turw7okuiwenncydrc83q-4ab4b9056ff91b946fb2fc048bc764fa.png and /dev/null differ diff --git a/images/45f6cf14-1625144330-b7b2778ff7475a87d1b743ca68138d4c.png b/images/45f6cf14-1625144330-b7b2778ff7475a87d1b743ca68138d4c.png deleted file mode 100644 index df2a36dda..000000000 Binary files a/images/45f6cf14-1625144330-b7b2778ff7475a87d1b743ca68138d4c.png and /dev/null differ diff --git a/images/48d85cdb-1625152077-179f408f37e02830e46d38430db718e3.jpg b/images/48d85cdb-1625152077-179f408f37e02830e46d38430db718e3.jpg deleted file mode 100644 index 40bed4fd2..000000000 Binary files a/images/48d85cdb-1625152077-179f408f37e02830e46d38430db718e3.jpg and /dev/null differ diff --git a/images/4b6077a3-1625151886-ff472a11d6251be772c7022e0d56cb54.png b/images/4b6077a3-1625151886-ff472a11d6251be772c7022e0d56cb54.png deleted file mode 100644 index 0c62e9224..000000000 Binary files a/images/4b6077a3-1625151886-ff472a11d6251be772c7022e0d56cb54.png and /dev/null differ diff --git a/images/4f5d0cb1-1623199675-ff83aea7ea249ea9d1311bd38ab01354.png b/images/4f5d0cb1-1623199675-ff83aea7ea249ea9d1311bd38ab01354.png deleted file mode 100644 index 6e632611a..000000000 Binary files a/images/4f5d0cb1-1623199675-ff83aea7ea249ea9d1311bd38ab01354.png and /dev/null differ diff --git a/images/4f9a1fe2-1625143551-b6c300d2dcad41e7aab06f566c831aaa.png b/images/4f9a1fe2-1625143551-b6c300d2dcad41e7aab06f566c831aaa.png deleted file mode 100644 index bbb0b3fbb..000000000 Binary files a/images/4f9a1fe2-1625143551-b6c300d2dcad41e7aab06f566c831aaa.png and /dev/null differ diff --git a/images/50ec55fb-1623199650-f637f75678b8c499486603de2346f1d3.png b/images/50ec55fb-1623199650-f637f75678b8c499486603de2346f1d3.png deleted file mode 100644 index 3932b02f9..000000000 Binary files a/images/50ec55fb-1623199650-f637f75678b8c499486603de2346f1d3.png and /dev/null differ diff --git a/images/52e6548c-1623199732-71d1533ce5f42500dbf817df27946be2.png b/images/52e6548c-1623199732-71d1533ce5f42500dbf817df27946be2.png deleted file mode 100644 index eaef42184..000000000 Binary files a/images/52e6548c-1623199732-71d1533ce5f42500dbf817df27946be2.png and /dev/null differ diff --git a/images/5c3dbf05-1623199698-11f789692d0519f2f0877d81ba759f49.png b/images/5c3dbf05-1623199698-11f789692d0519f2f0877d81ba759f49.png deleted file mode 100644 index de71c85bb..000000000 Binary files a/images/5c3dbf05-1623199698-11f789692d0519f2f0877d81ba759f49.png and /dev/null differ diff --git a/images/5cc4b60f-1625143780-e2e6335de1dfd15f3b4ca2c90d75b8ac.png b/images/5cc4b60f-1625143780-e2e6335de1dfd15f3b4ca2c90d75b8ac.png deleted file mode 100644 index 9b6a911e2..000000000 Binary files a/images/5cc4b60f-1625143780-e2e6335de1dfd15f3b4ca2c90d75b8ac.png and /dev/null differ diff --git a/images/6d8b61db-1623199712-167188509f2dcd817d2eb1714d3d1a01.png b/images/6d8b61db-1623199712-167188509f2dcd817d2eb1714d3d1a01.png deleted file mode 100644 index afc1c70d9..000000000 Binary files a/images/6d8b61db-1623199712-167188509f2dcd817d2eb1714d3d1a01.png and /dev/null differ diff --git a/images/7125f94d-1623199719-a45e72df6870ea219ff5cc39700b69b1.png b/images/7125f94d-1623199719-a45e72df6870ea219ff5cc39700b69b1.png deleted file mode 100644 index 656328478..000000000 Binary files a/images/7125f94d-1623199719-a45e72df6870ea219ff5cc39700b69b1.png and /dev/null differ diff --git a/images/73e8b456-1623199691-5b31d94dd3773f131401d7fad7ddde09.png b/images/73e8b456-1623199691-5b31d94dd3773f131401d7fad7ddde09.png deleted file mode 100644 index 911b81e9e..000000000 Binary files a/images/73e8b456-1623199691-5b31d94dd3773f131401d7fad7ddde09.png and /dev/null differ diff --git a/images/790e609a-cometchat-extensions-push-notifications-2d0156e297965960863d547589c46044.png b/images/790e609a-cometchat-extensions-push-notifications-2d0156e297965960863d547589c46044.png deleted file mode 100644 index c9d003910..000000000 Binary files a/images/790e609a-cometchat-extensions-push-notifications-2d0156e297965960863d547589c46044.png and /dev/null differ diff --git a/images/7932e1e6-1623199630-7362107fb9b9119bc2f9fb111d4e450a.png b/images/7932e1e6-1623199630-7362107fb9b9119bc2f9fb111d4e450a.png deleted file mode 100644 index 3f9b512b9..000000000 Binary files a/images/7932e1e6-1623199630-7362107fb9b9119bc2f9fb111d4e450a.png and /dev/null differ diff --git a/images/7948cc4b-clzvkok6p26ma893mmb8ltpcax8iq59mtvdtp4456h33czl3f5jpwnpv2qbuumjr-21d00d8f9be6ef3fb206d438a1d64f0f.png b/images/7948cc4b-clzvkok6p26ma893mmb8ltpcax8iq59mtvdtp4456h33czl3f5jpwnpv2qbuumjr-21d00d8f9be6ef3fb206d438a1d64f0f.png deleted file mode 100644 index 9cc734f11..000000000 Binary files a/images/7948cc4b-clzvkok6p26ma893mmb8ltpcax8iq59mtvdtp4456h33czl3f5jpwnpv2qbuumjr-21d00d8f9be6ef3fb206d438a1d64f0f.png and /dev/null differ diff --git a/images/838abe77-1626087095-14695a63bb71bc1530081de1fb107b5c.png b/images/838abe77-1626087095-14695a63bb71bc1530081de1fb107b5c.png deleted file mode 100644 index a32cf9464..000000000 Binary files a/images/838abe77-1626087095-14695a63bb71bc1530081de1fb107b5c.png and /dev/null differ diff --git a/images/94bd7567-1640937759-985854eaa68734ab4ea0d63ac667fb1f.png b/images/94bd7567-1640937759-985854eaa68734ab4ea0d63ac667fb1f.png deleted file mode 100644 index a4411978f..000000000 Binary files a/images/94bd7567-1640937759-985854eaa68734ab4ea0d63ac667fb1f.png and /dev/null differ diff --git a/images/94f00a17-1623199636-52b9af9dd42b77102f3073c7d93760a7.png b/images/94f00a17-1623199636-52b9af9dd42b77102f3073c7d93760a7.png deleted file mode 100644 index ea90a2af1..000000000 Binary files a/images/94f00a17-1623199636-52b9af9dd42b77102f3073c7d93760a7.png and /dev/null differ diff --git a/images/97122883-1640937720-fcd19d0ec4b22be8309cbad8172e611e.png b/images/97122883-1640937720-fcd19d0ec4b22be8309cbad8172e611e.png deleted file mode 100644 index b8d799e42..000000000 Binary files a/images/97122883-1640937720-fcd19d0ec4b22be8309cbad8172e611e.png and /dev/null differ diff --git a/images/9b3d3095-1623199651-d9506794806367499d7e2ce6fbf7ecbf.png b/images/9b3d3095-1623199651-d9506794806367499d7e2ce6fbf7ecbf.png deleted file mode 100644 index 7f1b955a7..000000000 Binary files a/images/9b3d3095-1623199651-d9506794806367499d7e2ce6fbf7ecbf.png and /dev/null differ diff --git a/images/9cd7b785-cometchat-widget-docked-e2906f61f4478dbda64e0d6b78b0afeb.png b/images/9cd7b785-cometchat-widget-docked-e2906f61f4478dbda64e0d6b78b0afeb.png deleted file mode 100644 index 4f75ee87a..000000000 Binary files a/images/9cd7b785-cometchat-widget-docked-e2906f61f4478dbda64e0d6b78b0afeb.png and /dev/null differ diff --git a/images/9efba7cd-reu41ertm4ukyva9zcpiwioffws49ni9xe2q6olmbozpd4h1gxudydj41dc25dj3-4eb5d3cce059b21d7a1add99427296dd.png b/images/9efba7cd-reu41ertm4ukyva9zcpiwioffws49ni9xe2q6olmbozpd4h1gxudydj41dc25dj3-4eb5d3cce059b21d7a1add99427296dd.png deleted file mode 100644 index 8a82f2002..000000000 Binary files a/images/9efba7cd-reu41ertm4ukyva9zcpiwioffws49ni9xe2q6olmbozpd4h1gxudydj41dc25dj3-4eb5d3cce059b21d7a1add99427296dd.png and /dev/null differ diff --git a/images/9f1013b4-1623199739-ec5872d1da0be4a1cd4276b0f06a37c3.png b/images/9f1013b4-1623199739-ec5872d1da0be4a1cd4276b0f06a37c3.png deleted file mode 100644 index 89424b7b1..000000000 Binary files a/images/9f1013b4-1623199739-ec5872d1da0be4a1cd4276b0f06a37c3.png and /dev/null differ diff --git a/images/a4236fb1-cometchat-widget-wordpress-dashboard-upload-plugin-0e76a48f40712efb4fe59b44b1041590.png b/images/a4236fb1-cometchat-widget-wordpress-dashboard-upload-plugin-0e76a48f40712efb4fe59b44b1041590.png deleted file mode 100644 index 9e1bf96d1..000000000 Binary files a/images/a4236fb1-cometchat-widget-wordpress-dashboard-upload-plugin-0e76a48f40712efb4fe59b44b1041590.png and /dev/null differ diff --git a/images/a8d49795-PgAAAABJRU5ErkJggg.png b/images/a8d49795-PgAAAABJRU5ErkJggg.png deleted file mode 100644 index d8e009551..000000000 Binary files a/images/a8d49795-PgAAAABJRU5ErkJggg.png and /dev/null differ diff --git a/images/a97e4e80-1623199648-2ae35edb70153eb724714719fc64c65d.png b/images/a97e4e80-1623199648-2ae35edb70153eb724714719fc64c65d.png deleted file mode 100644 index adcf7f1cc..000000000 Binary files a/images/a97e4e80-1623199648-2ae35edb70153eb724714719fc64c65d.png and /dev/null differ diff --git a/images/ae62411b-cometchat-widget-embedded-eb1ab072b5ef5332c75498c4f89d0b4f.png b/images/ae62411b-cometchat-widget-embedded-eb1ab072b5ef5332c75498c4f89d0b4f.png deleted file mode 100644 index 87da8e587..000000000 Binary files a/images/ae62411b-cometchat-widget-embedded-eb1ab072b5ef5332c75498c4f89d0b4f.png and /dev/null differ diff --git a/images/ae703330-1638962591-abdb36bd2f7ce4e684d7aaa8ffa6a172.png b/images/ae703330-1638962591-abdb36bd2f7ce4e684d7aaa8ffa6a172.png deleted file mode 100644 index 1936dd5a1..000000000 Binary files a/images/ae703330-1638962591-abdb36bd2f7ce4e684d7aaa8ffa6a172.png and /dev/null differ diff --git a/images/af2efd86-1623199724-37f2d4286b1fcdf9acf4fafe5729d54c.png b/images/af2efd86-1623199724-37f2d4286b1fcdf9acf4fafe5729d54c.png deleted file mode 100644 index 89d8c338a..000000000 Binary files a/images/af2efd86-1623199724-37f2d4286b1fcdf9acf4fafe5729d54c.png and /dev/null differ diff --git a/images/b2742c90-1623199695-afe4a16ea5565a1fd775cf0714d51171.png b/images/b2742c90-1623199695-afe4a16ea5565a1fd775cf0714d51171.png deleted file mode 100644 index 178a6bda7..000000000 Binary files a/images/b2742c90-1623199695-afe4a16ea5565a1fd775cf0714d51171.png and /dev/null differ diff --git a/images/bed4abfc-1623199687-98cfb1a9f5996edae53f2b323725e778.png b/images/bed4abfc-1623199687-98cfb1a9f5996edae53f2b323725e778.png deleted file mode 100644 index 33d8321ec..000000000 Binary files a/images/bed4abfc-1623199687-98cfb1a9f5996edae53f2b323725e778.png and /dev/null differ diff --git a/images/bfd561a7-1623199682-9c9a23dd46dde042e79e9d325e2ba10c.png b/images/bfd561a7-1623199682-9c9a23dd46dde042e79e9d325e2ba10c.png deleted file mode 100644 index d4e0d68ae..000000000 Binary files a/images/bfd561a7-1623199682-9c9a23dd46dde042e79e9d325e2ba10c.png and /dev/null differ diff --git a/images/c18b3746-cometchat-widget-wordpress-dashboard-plugins-7be528827a974b8e233087321a4ce994.png b/images/c18b3746-cometchat-widget-wordpress-dashboard-plugins-7be528827a974b8e233087321a4ce994.png deleted file mode 100644 index b40e7eba7..000000000 Binary files a/images/c18b3746-cometchat-widget-wordpress-dashboard-plugins-7be528827a974b8e233087321a4ce994.png and /dev/null differ diff --git a/images/c36b29a8-bbso1h0thwtp4yp0z8yvomzie7oluzx2vetlll5rabm7z24tgp9d94ndu2r6nygk-aad037f6953c6ba50729c8e00da500ef.png b/images/c36b29a8-bbso1h0thwtp4yp0z8yvomzie7oluzx2vetlll5rabm7z24tgp9d94ndu2r6nygk-aad037f6953c6ba50729c8e00da500ef.png deleted file mode 100644 index 54a5437b8..000000000 Binary files a/images/c36b29a8-bbso1h0thwtp4yp0z8yvomzie7oluzx2vetlll5rabm7z24tgp9d94ndu2r6nygk-aad037f6953c6ba50729c8e00da500ef.png and /dev/null differ diff --git a/images/c47d740f-1623199592-18f6edace1510a65705e96ee2e85f7f7.png b/images/c47d740f-1623199592-18f6edace1510a65705e96ee2e85f7f7.png deleted file mode 100644 index b4a0c88e3..000000000 Binary files a/images/c47d740f-1623199592-18f6edace1510a65705e96ee2e85f7f7.png and /dev/null differ diff --git a/images/c4abbbfb-iqfukf6oqo4xhfq9cc5n6oi2b34hkd8ybr6vijelf4nosa43ctmef9peiphswzma-84aaadb82c1a1591641305185fd89dcd.jpg b/images/c4abbbfb-iqfukf6oqo4xhfq9cc5n6oi2b34hkd8ybr6vijelf4nosa43ctmef9peiphswzma-84aaadb82c1a1591641305185fd89dcd.jpg deleted file mode 100644 index 257e69468..000000000 Binary files a/images/c4abbbfb-iqfukf6oqo4xhfq9cc5n6oi2b34hkd8ybr6vijelf4nosa43ctmef9peiphswzma-84aaadb82c1a1591641305185fd89dcd.jpg and /dev/null differ diff --git a/images/c62ef130-29ee87jv3f0rs52quaq3h04c424aoc5q18qrt6m1fsmygqq5bry0b0f2lsj8skx5-4ca2b3ab04a8d9f529de9082cd7c6fe6.png b/images/c62ef130-29ee87jv3f0rs52quaq3h04c424aoc5q18qrt6m1fsmygqq5bry0b0f2lsj8skx5-4ca2b3ab04a8d9f529de9082cd7c6fe6.png deleted file mode 100644 index daeabb000..000000000 Binary files a/images/c62ef130-29ee87jv3f0rs52quaq3h04c424aoc5q18qrt6m1fsmygqq5bry0b0f2lsj8skx5-4ca2b3ab04a8d9f529de9082cd7c6fe6.png and /dev/null differ diff --git a/images/c6a19e8e-1638962603-d09dd80ed899c30a5300ae676fe6ad7d.png b/images/c6a19e8e-1638962603-d09dd80ed899c30a5300ae676fe6ad7d.png deleted file mode 100644 index e84b4ea72..000000000 Binary files a/images/c6a19e8e-1638962603-d09dd80ed899c30a5300ae676fe6ad7d.png and /dev/null differ diff --git a/images/c8c546a3-x8a7yv541r6b9g8t73h9j3afh1p4cgsopv6yj238ebz8565rscv568a40zf34f5h-c617ae8f9a6f09edf27d37dd01ce1bf3.png b/images/c8c546a3-x8a7yv541r6b9g8t73h9j3afh1p4cgsopv6yj238ebz8565rscv568a40zf34f5h-c617ae8f9a6f09edf27d37dd01ce1bf3.png deleted file mode 100644 index 1146598e4..000000000 Binary files a/images/c8c546a3-x8a7yv541r6b9g8t73h9j3afh1p4cgsopv6yj238ebz8565rscv568a40zf34f5h-c617ae8f9a6f09edf27d37dd01ce1bf3.png and /dev/null differ diff --git a/images/ca58350b-1623199634-10bf35b6e22454ec9b40ca48e033bdc5.png b/images/ca58350b-1623199634-10bf35b6e22454ec9b40ca48e033bdc5.png deleted file mode 100644 index 7b2ce4502..000000000 Binary files a/images/ca58350b-1623199634-10bf35b6e22454ec9b40ca48e033bdc5.png and /dev/null differ diff --git a/images/cbd9f03f-7074vppi29h4jsxht5yv37bqx44d29hd6mdtxoxbxtfeucz7rs3kebgmn5xg7nh7-3873961b1475ec06f951cae9d679b0f3.png b/images/cbd9f03f-7074vppi29h4jsxht5yv37bqx44d29hd6mdtxoxbxtfeucz7rs3kebgmn5xg7nh7-3873961b1475ec06f951cae9d679b0f3.png deleted file mode 100644 index 0849459e5..000000000 Binary files a/images/cbd9f03f-7074vppi29h4jsxht5yv37bqx44d29hd6mdtxoxbxtfeucz7rs3kebgmn5xg7nh7-3873961b1475ec06f951cae9d679b0f3.png and /dev/null differ diff --git a/images/cd58ed9d-1623199632-f012809746ebe3267fa897703f7fb835.png b/images/cd58ed9d-1623199632-f012809746ebe3267fa897703f7fb835.png deleted file mode 100644 index 80d6288a2..000000000 Binary files a/images/cd58ed9d-1623199632-f012809746ebe3267fa897703f7fb835.png and /dev/null differ diff --git a/images/cdf4d5a8-1623199677-bf5a548e69dc6ee9dc3c372def0bdc98.png b/images/cdf4d5a8-1623199677-bf5a548e69dc6ee9dc3c372def0bdc98.png deleted file mode 100644 index 1668bded5..000000000 Binary files a/images/cdf4d5a8-1623199677-bf5a548e69dc6ee9dc3c372def0bdc98.png and /dev/null differ diff --git a/images/ce087489-1640937807-2c55cbabbfcbae49896063810822240d.png b/images/ce087489-1640937807-2c55cbabbfcbae49896063810822240d.png deleted file mode 100644 index 8e84fd643..000000000 Binary files a/images/ce087489-1640937807-2c55cbabbfcbae49896063810822240d.png and /dev/null differ diff --git a/images/cef182e1-1640937699-59eddd83a6c0783b06ccf5eebe3b7d94.png b/images/cef182e1-1640937699-59eddd83a6c0783b06ccf5eebe3b7d94.png deleted file mode 100644 index dd008c822..000000000 Binary files a/images/cef182e1-1640937699-59eddd83a6c0783b06ccf5eebe3b7d94.png and /dev/null differ diff --git a/images/cometchat-ai-add-bot.png b/images/cometchat-ai-add-bot.png deleted file mode 100644 index 491b89e6c..000000000 Binary files a/images/cometchat-ai-add-bot.png and /dev/null differ diff --git a/images/cometchat-ai-instructions-list.png b/images/cometchat-ai-instructions-list.png deleted file mode 100644 index b85612c74..000000000 Binary files a/images/cometchat-ai-instructions-list.png and /dev/null differ diff --git a/images/cometchat-ai-instructions.png b/images/cometchat-ai-instructions.png deleted file mode 100644 index 2ecb6bae7..000000000 Binary files a/images/cometchat-ai-instructions.png and /dev/null differ diff --git a/images/cometchat-dashboard-ai-overview-custom-bots.png b/images/cometchat-dashboard-ai-overview-custom-bots.png deleted file mode 100644 index 29fc235f0..000000000 Binary files a/images/cometchat-dashboard-ai-overview-custom-bots.png and /dev/null differ diff --git a/images/d34e07a0-1640937502-629d7eca609e260bbcfe86ad993f776d.png b/images/d34e07a0-1640937502-629d7eca609e260bbcfe86ad993f776d.png deleted file mode 100644 index 9c6b7a008..000000000 Binary files a/images/d34e07a0-1640937502-629d7eca609e260bbcfe86ad993f776d.png and /dev/null differ diff --git a/images/d3ee52ca-1625151921-61502ae80f3126a81a02f828efbf40e3.png b/images/d3ee52ca-1625151921-61502ae80f3126a81a02f828efbf40e3.png deleted file mode 100644 index 65ba41cdf..000000000 Binary files a/images/d3ee52ca-1625151921-61502ae80f3126a81a02f828efbf40e3.png and /dev/null differ diff --git a/images/d51e00ee-1623199859-fdcff7272ecf6e64ef4adc50739e2f3a.png b/images/d51e00ee-1623199859-fdcff7272ecf6e64ef4adc50739e2f3a.png deleted file mode 100644 index c78c4ac65..000000000 Binary files a/images/d51e00ee-1623199859-fdcff7272ecf6e64ef4adc50739e2f3a.png and /dev/null differ diff --git a/images/d7a68604-1623199654-49dc03a0cc06cbdcab0573b82485c58c.png b/images/d7a68604-1623199654-49dc03a0cc06cbdcab0573b82485c58c.png deleted file mode 100644 index a92952b82..000000000 Binary files a/images/d7a68604-1623199654-49dc03a0cc06cbdcab0573b82485c58c.png and /dev/null differ diff --git a/images/d7c36803-1625145323-000bb46e1861f67d64529ed0e747a609.png b/images/d7c36803-1625145323-000bb46e1861f67d64529ed0e747a609.png deleted file mode 100644 index a5e4c365c..000000000 Binary files a/images/d7c36803-1625145323-000bb46e1861f67d64529ed0e747a609.png and /dev/null differ diff --git a/images/d7e76894-1623199635-2f13604be3a2a55f280420ffe06e424d.png b/images/d7e76894-1623199635-2f13604be3a2a55f280420ffe06e424d.png deleted file mode 100644 index 31fba5f07..000000000 Binary files a/images/d7e76894-1623199635-2f13604be3a2a55f280420ffe06e424d.png and /dev/null differ diff --git a/images/d81bd875-c3wpqodw2nki1niq5vn27gpizsd94zkqortvptz9gr8vrcg1y7zo7nx64k0o9hcx-79fd9382c5291976f18e6211f6d50417.png b/images/d81bd875-c3wpqodw2nki1niq5vn27gpizsd94zkqortvptz9gr8vrcg1y7zo7nx64k0o9hcx-79fd9382c5291976f18e6211f6d50417.png deleted file mode 100644 index 4537910e5..000000000 Binary files a/images/d81bd875-c3wpqodw2nki1niq5vn27gpizsd94zkqortvptz9gr8vrcg1y7zo7nx64k0o9hcx-79fd9382c5291976f18e6211f6d50417.png and /dev/null differ diff --git a/images/d88ee39d-1637282570-f33f06ff5a99a2d63f062582949f6845.png b/images/d88ee39d-1637282570-f33f06ff5a99a2d63f062582949f6845.png deleted file mode 100644 index 502ddbbff..000000000 Binary files a/images/d88ee39d-1637282570-f33f06ff5a99a2d63f062582949f6845.png and /dev/null differ diff --git a/images/df3e92ae-1623199680-fd6880bdea4d34d0d9f941b15f0940ef.png b/images/df3e92ae-1623199680-fd6880bdea4d34d0d9f941b15f0940ef.png deleted file mode 100644 index d3c5fc006..000000000 Binary files a/images/df3e92ae-1623199680-fd6880bdea4d34d0d9f941b15f0940ef.png and /dev/null differ diff --git a/images/e376fc1b-1623199721-427d9042c79bfe2af928d0bbe44c8fb1.png b/images/e376fc1b-1623199721-427d9042c79bfe2af928d0bbe44c8fb1.png deleted file mode 100644 index 73419c4df..000000000 Binary files a/images/e376fc1b-1623199721-427d9042c79bfe2af928d0bbe44c8fb1.png and /dev/null differ diff --git a/images/e53ecc4b-cometchat-extensions-push-notification-triggers-f847cdea801fcb44572e67c83d3faf66.png b/images/e53ecc4b-cometchat-extensions-push-notification-triggers-f847cdea801fcb44572e67c83d3faf66.png deleted file mode 100644 index e0f34d953..000000000 Binary files a/images/e53ecc4b-cometchat-extensions-push-notification-triggers-f847cdea801fcb44572e67c83d3faf66.png and /dev/null differ diff --git a/images/e597c8dd-1623199652-e34b0f505c4af36ecd03d49dc0e4f564.png b/images/e597c8dd-1623199652-e34b0f505c4af36ecd03d49dc0e4f564.png deleted file mode 100644 index c757ae79e..000000000 Binary files a/images/e597c8dd-1623199652-e34b0f505c4af36ecd03d49dc0e4f564.png and /dev/null differ diff --git a/images/edca1285-1623199676-d13ad22df1c7d1620ce53296728f9b8b.png b/images/edca1285-1623199676-d13ad22df1c7d1620ce53296728f9b8b.png deleted file mode 100644 index 2a885f3bb..000000000 Binary files a/images/edca1285-1623199676-d13ad22df1c7d1620ce53296728f9b8b.png and /dev/null differ diff --git a/images/f1dde893-1623199726-bf570172529d9b112076840694000c4d.png b/images/f1dde893-1623199726-bf570172529d9b112076840694000c4d.png deleted file mode 100644 index a4bde88db..000000000 Binary files a/images/f1dde893-1623199726-bf570172529d9b112076840694000c4d.png and /dev/null differ diff --git a/images/f95175df-1s26s11czkienxtcr5jp0e6cxp4bwbogqlcnd0d75bcg6cd2koxbw5ceisj0ygep-5b58e8c9377ee9bac1626a390525d975.png b/images/f95175df-1s26s11czkienxtcr5jp0e6cxp4bwbogqlcnd0d75bcg6cd2koxbw5ceisj0ygep-5b58e8c9377ee9bac1626a390525d975.png deleted file mode 100644 index 49b0028cb..000000000 Binary files a/images/f95175df-1s26s11czkienxtcr5jp0e6cxp4bwbogqlcnd0d75bcg6cd2koxbw5ceisj0ygep-5b58e8c9377ee9bac1626a390525d975.png and /dev/null differ diff --git a/images/fc715a61-legacy-webhooks-add-new-1492f0a84c8eee116aef5f4bcca26365.png b/images/fc715a61-legacy-webhooks-add-new-1492f0a84c8eee116aef5f4bcca26365.png deleted file mode 100644 index 2a6b4bf9d..000000000 Binary files a/images/fc715a61-legacy-webhooks-add-new-1492f0a84c8eee116aef5f4bcca26365.png and /dev/null differ diff --git a/images/fd1ca787-1623199672-9c1dad1c04bc280ac51548f8ce1e43f4.png b/images/fd1ca787-1623199672-9c1dad1c04bc280ac51548f8ce1e43f4.png deleted file mode 100644 index ad6a31932..000000000 Binary files a/images/fd1ca787-1623199672-9c1dad1c04bc280ac51548f8ce1e43f4.png and /dev/null differ diff --git a/moderation/legacy-extensions.mdx b/moderation/legacy-extensions.mdx deleted file mode 100644 index 258bb16a5..000000000 --- a/moderation/legacy-extensions.mdx +++ /dev/null @@ -1,348 +0,0 @@ ---- -title: "Legacy Moderation Extensions" -sidebarTitle: "Moderation (Legacy)" ---- - - -These extensions are considered legacy and are scheduled for deprecation. They are no longer recommended for new integrations and will not receive feature updates or enhancements. - -For new projects, use [AI Moderation](/moderation/overview). - - -## Slow Mode - -Slow down messages in groups to make them legible during high-traffic events. - -When enabled in a group, participants can only send messages after configured intervals. Admins and moderators are not restricted. - -**Enable Slow Mode** - -```js -CometChat.callExtension('slow-mode', 'POST', 'v1/configure', { - "guid": "cometchat-guid-1", - "slowDownTimeInMS": 660000 -}).then(response => { - // Success -}).catch(error => { - // Error -}); -``` - -**Disable Slow Mode** - -```js -CometChat.callExtension('slow-mode', 'DELETE', 'v1/configure', { - "guid": "cometchat-guid-1" -}).then(response => { - // Success -}).catch(error => { - // Error -}); -``` - -**Fetch Slow Mode Details** - -```js -const guid = "cometchat-guid-1"; -CometChat.callExtension('slow-mode', 'GET', `v1/fetch-configuration?guid=${guid}`, null) - .then(response => { - // { isSlowed, slowDownTimeInMS, lastMessageSentAtTimestamp } - }); -``` - ---- - -## Report User - -Enables users to report other users for offensive or suspicious behavior. - -**Settings** - -1. Go to **Extensions** → Enable **Report User** -2. Configure moderation criteria (max reports before notification) -3. Set up webhook URL for reports - -**Report a User** - -```js -CometChat.callExtension('report-user', 'POST', 'v1/report', { - "uid": "cometchat-uid-3", - "reason": "Misbehaving", - "guid": "cometchat-guid-1" // Optional: only for group reports -}).then(response => { - // { success: true } -}); -``` - -**View Reports** - -Open the Extension's settings page and click "View Reports" to take action (Kick, Ban, Block, or Ignore). - ---- - -## Report Message - -Enable users to report messages in conversations. - -**Report a Message** - -```js -CometChat.callExtension('report-message', 'POST', 'v1/report', { - "msgId": 123, - "reason": "Contains profanity" -}).then(response => { - // { success: true } -}); -``` - -**View Reports** - -Open the Extension's settings page and click "View Reports" to Delete or Ignore reported messages. - ---- - -## Data Masking Filter - -Hide phone numbers, email addresses, and other sensitive information in messages. - -**Settings** - -1. Enable the extension -2. Configure default masks (Emails, SSN, US phone numbers) -3. Add custom regex patterns for additional masking - -**Response Format** - -```json -{ - "@injected": { - "extensions": { - "data-masking": { - "data": { - "sensitive_data": "yes", - "message_masked": "My number is ***** & my email id is ****" - } - } - } - } -} -``` - -**Implementation** - -```js -var metadata = message.getMetadata(); -if (metadata != null) { - var injectedObject = metadata["@injected"]; - if (injectedObject?.extensions?.["data-masking"]) { - var dataMaskingObject = injectedObject.extensions["data-masking"]["data"]; - var message_masked = dataMaskingObject["message_masked"]; - } -} -``` - ---- - -## Profanity Filter - -Mask or hide profanity in messages using a customizable blacklist. - -**Settings** - -1. Enable the extension -2. Optionally enable "Drop messages with Profanity" -3. Add comma-separated list of words to filter (supports emojis) - -**Response Format** - -```json -{ - "@injected": { - "extensions": { - "profanity-filter": { - "profanity": "yes", - "message_clean": "This is ****" - } - } - } -} -``` - -**Implementation** - -```js -var metadata = message.getMetadata(); -if (metadata != null) { - var injectedObject = metadata["@injected"]; - if (injectedObject?.extensions?.["profanity-filter"]) { - var profanityFilterObject = injectedObject.extensions["profanity-filter"]; - var cleanMessage = profanityFilterObject["message_clean"]; - } -} -``` - ---- - -## Image Moderation - -AI-powered image moderation to detect unsafe content. - -Images are classified into: -- Explicit Nudity -- Suggestive Nudity -- Violence -- Visually Disturbing - -**Response Format** - -```json -{ - "@injected": { - "extensions": { - "image-moderation": { - "unsafe": "yes", - "confidence": "99", - "category": "explicit_nudity" - } - } - } -} -``` - -A confidence value less than 50 is likely a false-positive. - -**Implementation** - -```js -const metadata = message.getMetadata(); -if (metadata != null) { - const injectedObject = metadata["@injected"]; - if (injectedObject?.extensions?.["image-moderation"]) { - const { attachments } = injectedObject.extensions["image-moderation"]; - for (const attachment of attachments) { - if (!attachment.error) { - const { unsafe } = attachment.data.verdict; - } - } - } -} -``` - ---- - -## Sentiment Analysis - -Understand the tone or sentiment of messages. - -Messages are classified as: Positive, Neutral, Negative, or Mixed. - -Supported languages: German, English, Spanish, Italian, Portuguese, French, Japanese, Korean, Hindi, Arabic, Chinese (simplified & traditional) - -**Response Format** - -```json -{ - "@injected": { - "extensions": { - "sentiment-analysis": { - "sentiment": "positive", - "sentiment_score": { - "positive": 95, - "neutral": 4, - "negative": 0, - "mixed": 0 - } - } - } - } -} -``` - ---- - -## In-Flight Message Moderation - -Manually moderate messages before delivery. - -**Settings** - -Configure moderation criteria: -- Moderate all messages, one-on-one only, or group only -- Moderate messages from specific users (UIDs) -- Moderate messages to specific users or groups - -**Actions** - -From the Dashboard, you can: -- **Approve**: Send the message to the receiver -- **Reject**: Delete the message -- **Kick**: Remove user from group (can rejoin) -- **Ban**: Ban user from group (cannot rejoin) - ---- - -## Virus & Malware Scanner - -Scan uploaded files for malicious content using [Scanii](https://scanii.com). - -**Prerequisites** - -Create a Scanii account and get your API Key and Secret. - -**Response Format** - -```json -{ - "@injected": { - "extensions": { - "virus-malware-scanner": { - "attachments": [{ - "data": { - "url": "https://media.com/file.mp3", - "verdict": { - "scan_results": [] - } - }, - "error": null - }] - } - } - } -} -``` - -An empty `scan_results` array means the file is safe. - ---- - -## XSS Filter - -Sanitize messages to prevent cross-site scripting attacks. Applicable only for Web SDK. - -**Response Format** - -```json -{ - "@injected": { - "extensions": { - "xss-filter": { - "hasXSS": "yes", - "sanitized_message": "" - } - } - } -} -``` - -**Implementation** - -```js -var metadata = message.getMetadata(); -if (metadata != null) { - var injectedObject = metadata["@injected"]; - if (injectedObject?.extensions?.["xss-filter"]) { - var xssFilterObject = injectedObject.extensions["xss-filter"]; - var sanitized_message = xssFilterObject["sanitized_message"]; - } -} -``` diff --git a/notifications/email-notifications-extension-legacy.mdx b/notifications/email-notifications-extension-legacy.mdx deleted file mode 100644 index d4212ff83..000000000 --- a/notifications/email-notifications-extension-legacy.mdx +++ /dev/null @@ -1,415 +0,0 @@ ---- -title: "Email Notifications (Legacy)" ---- - - - -**Legacy Notice**: This extension is already included as part of the core messaging experience and is scheduled for deprecation in the near future. - -Please note: Legacy extensions are no longer actively maintained and will not receive feature updates or enhancements. - - - -## About the extension - -The Email Notification extension helps you to notify offline users about unread messages via emails. - -After you've configured the extension, your users will receive email notifications for unread messages in one-on-one conversations. - -The Email notifications extension allows you to have the following two integrations: - -1. Integration using [Webhook](/notifications/email-notifications#integration-using-webhook) -2. Integration using [SendGrid](/notifications/email-integration#sendgrid) - -## Before you begin - -These steps are required irrespective of the integration. - -### 1. Storing user emails - -You can use our [Update user](https://api-explorer.cometchat.com/reference/update-user) API to set private metadata for a user. We recommend adding this code where you call our [Create user](https://api-explorer.cometchat.com/reference/creates-user) API. - -Alternatively, just for the sake of testing purposes, you can add this from the CometChat Dashboard as well. - -1. Login to [CometChat](https://app.cometchat.com/login). -2. Select your app and go to the "Users" section. -3. Click on the Edit option available under the three dots for the user under consideration. -4. Click on the Edit button on the Details section. -5. Paste the below JSON in the Metadata input box and hit Save. - -The Metadata is a JSON that should have the `@private` key present and should have the value `email` specified for the user. The format for the private metadata must be as follows: - - - -```json -{ - "@private": - { - "email":"abc@xyz.com" - } -} -``` - - - - - -### 2. Read Receipts - -Be sure to implement read receipts so that your users receive email notifications for unread messages only. - -## Integration using Webhook - -This method of integration allows you to choose your Email API vendor and send Email notifications as per your needs. - -### 1. Create your webhook - -Build your backend that integrates with the Email API vendor of your choice. Expose a URL that accepts an HTTP POST request.This URL will be the "Webhook URL" to which the extension will send the following details: - -| Key | Value | Description | -| ---- | -------------- | ------------------------------------------------------------- | -| to | String (email) | The Email ID of the user to send the notification. | -| body | array | An array of message objects that were missed by the receiver. | - - - -```json -{ - "to": "user@email.com", - "body": [ - { - "id": "121", - "conversationId": "cometchat-uid-1_user_cometchat-uid-3", - "sender": "cometchat-uid-3", - "receiverType": "user", - "receiver": "cometchat-uid-1", - "category": "message", - "type": "text", - "data": { - "text": "1", - "entities": { - "sender": { - "entity": { - "uid": "cometchat-uid-3", - "name": "Nancy Grace", - "role": "default", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp", - "status": "available", - "lastActiveAt": 1639650770 - }, - "entityType": "user" - }, - "receiver": { - "entity": { - "uid": "cometchat-uid-1", - "name": "Andrew Joseph", - "role": "default", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp", - "status": "offline", - "lastActiveAt": 1639587777, - "conversationId": "cometchat-uid-1_user_cometchat-uid-3" - }, - "entityType": "user" - } - }, - "resource": "WEB-3_0_0-b5dee412-339c-48c6-b03a-1639650765951" - }, - "sentAt": 1639650887, - "updatedAt": 1639650887 - }, - {...}, {...} - ] -} -``` - - - - - -The subject of the email can be as per your requirement. Moreover, the messages array can be formatted to create the email body using a template of your choice. - -### 2. Extension settings - -1. Login to [CometChat](https://app.cometchat.com/login) and select your app. -2. Go to the Extensions section and enable the Email Notification extension. -3. Open the Settings for this extension where you can fill in the below details. -4. Save your settings. - - - - - - -Email replies - -If you wish to use the Email replies extension, you need use Integration using SendGrid. - - - -## Integration using SendGrid - -We have partnered with SendGrid for sending Email Notifications and hence you need to set up an account on [SendGrid](https://www.sendgrid.com/) before you start using the extension. - -### 1. Get your SendGrid API Key - -1. Log in to your SendGrid account. -2. In the left navigation pane, go to Settings -> API Keys. -3. If you don't have an API Key yet, click on Create API Key. Give a name to your API Key and select Full Access to get started. - -### 2. Add Email template - -1. In the left navigation pane, go to Email API -> Dynamic Templates. -2. Click on "Create a Dynamic Template" and give a name to your template. -3. In the Template listing, expand your template and click on "Add Version". -4. Under the "Your Email Designs" tab, select Blank Template. -5. As we have the following HTML template ready for you, select the "Code Editor" option. -6. Paste the code for the email template. You should be able to see the Preview in the Right pane. -7. Click on Settings on the Left to expand the Settings drawer. -8. Enter the Version name and Subject for your email and hit "Save". -9. You have now successfully created a Template with a version. From the Dynamic Templates listing page, expand your Template and make note of your Template ID. -10. The data sent from the extension to SendGrid for using in the template are as follows: - -| Key | Value | Description | -| ----------- | ------------------------ | --------------------------------------------------- | -| messages | Array of message objects | The list of unread messages by the receiver. | -| receiver | String | The name of the receiver of the Email notification. | -| unreadCount | Int | Number of messages that are unread. | - - - -1. Replace "[https://www.YOURSITE.com](https://www.YOURSITE.com%22)" with your website's URL in the below template. -2. The template filters and displays the TEXT messages in the email. Feel free to modify the template to include MEDIA messages as well. - - - - - -```html - - - - - - Simple Transactional Email - - - - - - - - - -
-
- - - - - - - - - - - -
- - - - -
-

While you were away...

- -

Hello, {{receiver}}! You have {{unreadCount}} unread messages.

- - - - -{{#each messages}} -{{#if this.data.text}} - - - - - {{/if}} -{{/each}} - - - -
- -

-
{{this.data.entities.sender.entity.name}}
{{this.data.text}}
- - - - - - - - -
- - - - - - -
Visit
-
-

To unsubscribe to these notifications, click here.

-
-
- - - - - - -
-
- - -``` - -
- -
- -### 3. Add Unsubscribe Group - -An unsubscribe group will allow your users to unsubscribe to only chat email notifications and will allow you to continue to send other emails to that user via SendGrid. - -1. In the left pane, go to Suppressions -> Unsubscribe Groups -2. Click on "Create New Group" and give it a name and proper description. -3. Save your new group and note down the Group ID. - -### 4. Extension settings - -1. Login to [CometChat](https://app.cometchat.com/login) and select your app. -2. Go to the Extensions section and enable the Email Notification extension. -3. Open the Settings for this extension where you can fill in the below details. -4. Save your settings. - - -Domain Authentication - -The domain used in Sender's Email needs to be Authenticated. Refer to SendGrid's documentation on [Domain Authentication](https://docs.sendgrid.com/ui/account-and-settings/how-to-set-up-domain-authentication) for more details. - - - - - - - -## Receive Email Notifications - -Send a message to an offline user and watch them receive an email automagically! - - - - diff --git a/notifications/legacy-push-notifications.mdx b/notifications/legacy-push-notifications.mdx deleted file mode 100644 index e6b6c4e0b..000000000 --- a/notifications/legacy-push-notifications.mdx +++ /dev/null @@ -1,1886 +0,0 @@ ---- -title: "Integration Guide for Legacy Push Notifications" ---- - - -Migrate to Token-based Push Notifications - -You can check out our new Token-based implementation [here](/notifications/push-notification-extension-overview). - - - -The Push Notification extension allows you to send push notifications to mobile apps and desktop browsers. - -Push notifications will work in all desktop browsers which support [Push API](https://caniuse.com/#feat=push-api). These include: - -1. Chrome 50+ -2. Firefox 44+ -3. Edge 17+ -4. Opera 42+ - -## Step 1: Add Firebase to your app - -To configure Firebase Push Notifications for your apps create a `Firebase` project at [Firebase Console](https://console.firebase.google.com/). - -If you have previously not created a Firebase project for your app Click Add project. If you already have created a project for your app in which you wish to integrate CometChat, select the same project and download the config file. - - - - - -## Step 2 : Obtain Firebase configuration for your platform - -### For Web - -1. Sign into Firebase and open your project. -2. On the Overview page, click Add app. -3. Select Add Firebase to your web app. -4. Copy the snippet and add it to your HTML application. - - - - - -### For Android - -1. Sign into Firebase and open your project. -2. On the Overview page, click Add app. -3. Select Add Firebase to your Android app. -4. Follow the on-screen instructions and finally download the google-services.json file. - - - - - - - - - -### For iOS - -1. Sign into Firebase and open your project. -2. On the Overview page, click Add app. -3. Select Add Firebase to your iOS app. -4. Enter the relevant details like your bundle ID and download the GoogleService-Info.plist file. -5. Move this plist file to the root of your XCode project. If prompted, select to add the config file to all targets as follows: - - - - - -### For React Native - -1. For React Native to Android, you need to download the `google-services.json` file. -2. For React native to iOS, you need to download the `GoogleServices-Info.plist` file. - -### For Capacitor, Cordova & Ionic (Deprecated) - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility. - - -1. For React Native to Android, you need to download the `google-services.json` file. -2. For React native to iOS, you need to download the `GoogleServices-Info.plist` file. -3. For web, you will need the Firebase Config object. - -## Step 3: Extension setup - -1. You need the Firebase Service key which you can get from Firebase console. - - 1. Open your Firebase app - 2. Click on the Settings Cog in the left navigation menu - 3. Select Project Settings and go to the Cloud Messaging tab - 4. Add a Server Key and copy it for further use. - -2. Login to the [CometChat Dashboard](https://app.cometchat.io/login) and select your app. - -3. On the Extensions page, enable the Push Notifications extension. - -4. Open the Settings for this extension. - -5. Enter FCM Server key. - -6. Select the platforms of choice. - -7. Enter the title for notifications. - -8. You can also toggle the triggers for sending Push Notifications. The triggers can be classified into 3 main categories: - - 1. Message Notifications - 2. Call Notifications - 3. Group Notifications - - - - - -## Step 4: Application Setup - -In order to use the topic-based Push Notifications, you need to subscribe to topics. In case of CometChat, you need to subscribe to 2 different types of topics: - -1. Topic to receive Push Notifications for one-on-one messages and calls. -2. Topic to receive Push Notifications for group messages and calls. - -Also, you can: - -1. Subscribe to one topic -2. Subscribe to all the topics - -Below steps guide you with this process of subscription to topics and specific setup for the platform of your choice. - -### For Web - -#### **1. Installing Firebase SDK** - - - -```sh -npm install firebase -``` - - - - -```sh -yarn add firebase -``` - - - - -```js - - -``` - - - - - -#### **2. Initialize Firebase app** - -1. Create a index.html file and initialize the Firebase app. This has to be done only once. -2. Here, you will need the Firebase Configuration object that you copied from the Firebase Console. -3. Also, register the service worker. - - - -```js -const config = { - apiKey: "AIzaSyBkasdasdasdybyI-ZkFCxNpJLAtYyqeERw5I60yTNs", - authDomain: "testAPP.firebaseapp.com", - databaseURL: "https://testAPP.firebaseio.com", - projectId: "testAPP-229414", - storageBucket: "testAPP.appspot.com", - messagingSenderId: "app_sender_id", -}; - -firebase.initializeApp(config); -``` - - - - - - - -```js -if ("serviceWorker" in navigator) { - window.addEventListener("load", () => { - navigator.serviceWorker.register("/firebase-messaging-sw.js"); - }); -} -``` - - - - - -#### **3. Request permission for Web Push** - -1. Create PushNotification.js file. -2. Insert the following code so that the browser asks for permission to show Push Notifications. -3. If the permission is granted, you will receive a FCM registration token. - - - -```js -const requestPermission = async () => { - const messaging = firebase.messaging(); - const FCM_TOKEN = await messaging - .requestPermission() - .then(() => messaging.getToken()); - .catch(error => console.log(error)); - return FCM_TOKEN; -} -``` - - - - - -#### **4. Subscribe to topic(s)** - -1. In the success callback of CometChat.login(), you can start the subscription process. -2. As mentioned earlier, you can either subscribe to one topic or subscribe to all. -3. The format for the name of user topic is `AppID_user_UID` -4. The format for the name of a group topic is `AppID_group_GUID` - - - -```js -var appID = "APP_ID"; -var token = "GENERATED_FCM_TOKEN"; -var userUID = "UID_OF_LOGGED_IN_USER"; -var appToken; -CometChat.getJoinedGroups().then((groups) => { - CometChat.getAppSettings().then((settings) => { - settings.extensions.forEach((ext) => { - if (ext.id == "push-notification") { - appToken = ext.appToken; - } - }); - var url = - "https://push-notification-us.cometchat.io/v1/subscribetomany?appToken=" + - appToken; - fetch(url, { - method: "POST", - headers: new Headers({ - "Content-Type": "application/json", - }), - body: JSON.stringify({ - appId: appID, - fcmToken: token, - uid: userUID, - groups: groups, - platform: "javascript", - }), - }) - .then((response) => { - if (response.status < 200 || response.status >= 400) { - console.log( - "Error subscribing to topics: " + - response.status + - " - " + - response.text() - ); - } else { - console.log("Subscribed to all topics"); - } - }) - .catch((error) => { - console.error(error); - }); - }); -}); -``` - - - - -```js -var token = "generated_FCM_token"; -CometChat.getAppSettings().then((settings) => { - var appToken; - settings.extensions.forEach((ext) => { - if (ext.id == "push-notification") { - appToken = ext.appToken; - } - }); - var userType = "user"; - var UID = "UID"; - var appId = "APP_ID"; - var region = "REGION_OF_APP"; - var topic = appId + "_" + userType + "_" + UID; - var url = - "https://push-notification-" + - region + - ".cometchat.io/v1/subscribe?appToken=" + - appToken + - ""; - fetch(url, { - method: "POST", - headers: new Headers({ - "Content-Type": "application/json", - }), - body: JSON.stringify({ appId: appId, fcmToken: token, topic: topic }), - }) - .then((response) => { - if (response.status < 200 || response.status >= 400) { - console.log( - "Error subscribing to topic: " + - response.status + - " - " + - response.text() - ); - } - console.log('Subscribed to "' + topic + '"'); - }) - .catch((error) => { - console.error(error); - }); -}); -``` - - - - -```js -var token = "generated_FCM_token"; -CometChat.getAppSettings().then(settings => { - var appToken; - settings.extensions.forEach(ext => { - if (ext.id == "push-notification){ - appToken = ext.appToken; - } - }); - var userType = "group"; - var GUID = "GUID"; - var appId = "APP_ID"; - var region = "REGION_OF_APP"; - var topic = appId + "_" + userType + "_" + GUID; - var url = - "https://push-notification-"+ region +".cometchat.io/v1/subscribe?appToken=" + - appToken + - ""; - fetch(url, { - method: "POST", - headers: new Headers({ - "Content-Type": "application/json" - }), - body: JSON.stringify({ appId: appId, fcmToken: token, topic: topic }) - }) - .then(response => { - if (response.status < 200 || response.status >= 400) { - console.log( - "Error subscribing to topic: " + - response.status + - " - " + - response.text() - ); - } - - console.log('Subscribed to "' + topic + '"'); - }) - .catch(error => { - console.error(error); - }); -}); -``` - - - - - -#### **5. Receive Messages** - -Create a firebase-messaging-sw\.js file which will handle showing notifications - - - -```js -importScripts("https://www.gstatic.com/firebasejs/8.3.2/firebase-app.js"); -importScripts("https://www.gstatic.com/firebasejs/8.3.2/firebase-messaging.js"); - -const FIREBASE_CONFIG_SW = { - // From Firebase - apiKey: "AIzaSyBkasdasdasdybyI-ZkFCxNpJLAtYyqeERw5I60yTNs", - authDomain: "testAPP.firebaseapp.com", - databaseURL: "https://testAPP.firebaseio.com", - projectId: "testAPP-229414", - storageBucket: "testAPP.appspot.com", - messagingSenderId: "app_sender_id", -}; - -firebase.initializeApp(FIREBASE_CONFIG_SW); - -const firebaseMessaging = firebase.messaging(); - -//background -firebaseMessaging.setBackgroundMessageHandler(function (payload) { - console.log(" Received background message ", payload); - - // Customize notification here - var notificationTitle = "notificationTitle"; - var notificationOptions = { - body: payload.data.alert, - icon: "", - }; - - return self.registration.showNotification( - notificationTitle, - notificationOptions - ); -}); - -// [END background_handler] -self.addEventListener("notificationclick", function (event) { - event.notification.close(); - //handle click event onClick on Web Push Notification -}); -``` - - - - - -#### **6. Unsubscribe from topics** - -Before you logout the user using CometChat.logout() method, you can unsubscribe from topics to stop receiving Push notifications for a logged out user. - - - -```js -var appID = "APP_ID"; -var token = "GENERATED_FCM_TOKEN"; -var appToken; -CometChat.getAppSettings().then((settings) => { - settings.extensions.forEach((ext) => { - if (ext.id == "push-notification") { - appToken = ext.appToken; - } - }); - var url = - "https://push-notification-us.cometchat.io/v1/unsubscribealltopic?appToken=" + - appToken; - fetch(url, { - method: "DELETE", - headers: new Headers({ - "Content-Type": "application_json", - }), - body: JSON.stringify({ appId: appID, fcmToken: token }), - }) - .then((response) => { - if (response.status < 200 || response.status >= 400) { - console.log( - "Error unsubscribing from topics: " + - response.status + - " - " + - response.text() - ); - } else { - console.log("Unsubscribed from all topics"); - } - }) - .catch((error) => { - console.error(error); - }); -}); -``` - - - - -```js -var token = "generated_FCM_token"; -CometChat.getAppSettings().then((settings) => { - var appToken; - settings.extensions.forEach((ext) => { - if (ext.id == "push-notification") { - appToken = ext.appToken; - } - }); - var userType = "user"; - var UID = "UID"; - var appId = "APP_ID"; - var region = "REGION_OF_APP"; - var topic = appId + "_" + userType + "_" + UID; - var url = - "https://push-notification-" + - region + - ".cometchat.io/v1/unsubscribe?appToken=" + - appToken; - fetch(url, { - method: "DELETE", - headers: new Headers({ - "Content-Type": "application/json", - }), - body: JSON.stringify({ appId: appId, fcmToken: token, topic: topic }), - }) - .then((response) => { - if (response.status < 200 || response.status >= 400) { - console.log( - "Error subscribing to topic: " + - response.status + - " - " + - response.text() - ); - } else { - console.log('Unsubscribed from "' + topic + '"'); - } - }) - .catch((error) => { - console.error(error); - }); -}); -``` - - - - -```js -var token = "generated_FCM_token"; -CometChat.getAppSettings().then((settings) => { - var appToken; - settings.extensions.forEach((ext) => { - if (ext.id == "push-notification") { - appToken = ext.appToken; - } - }); - var userType = "group"; - var GUID = "GUID"; - var appId = "APP_ID"; - var region = "REGION_OF_APP"; - var topic = appId + "_" + userType + "_" + GUID; - var url = - "https://push-notification-" + - region + - ".cometchat.io/v1/unsubscribe?appToken=" + - appToken; - fetch(url, { - method: "DELETE", - headers: new Headers({ - "Content-Type": "application/json", - }), - body: JSON.stringify({ appId: appId, fcmToken: token, topic: topic }), - }) - .then((response) => { - if (response.status < 200 || response.status >= 400) { - console.log( - "Error subscribing to topic: " + - response.status + - " - " + - response.text() - ); - } else { - console.log('Unsubscribed from "' + topic + '"'); - } - }) - .catch((error) => { - console.error(error); - }); -}); -``` - - - - - -#### **7. Handle Custom messages** - -To receive notification of `CustomMessage`, you need to set metadata while sending the `CustomMessage`. - - - -```js -var receiverID = "UID"; -var customData = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002", -}; - -var customType = "location"; -var receiverType = CometChat.RECEIVER_TYPE.USER; -var metadata = { - pushNotification: "Your Notification Message", -}; - -var customMessage = new CometChat.CustomMessage( - receiverID, - receiverType, - customType, - customData -); - -customMessage.setMetadata(metadata); - -CometChat.sendCustomMessage(customMessage).then( - (message) => { - // Message sent successfully. - console.log("custom message sent successfully", message); - }, - (error) => { - console.log("custom message sending failed with error", error); - // Handle exception. - } -); -``` - - - - - -### For Android - -#### **1. Setup client app** - -To enable Firebase products in your app, add the `google-services plugin` to your Gradle files. - -In your root-level (project-level) Gradle file (build.gradle), Check that you have Google's Maven repository. - -In your module (app-level) Gradle file (usually app/build.gradle), apply the Google Services Gradle plugin and add the dependencies for the Firebase Cloud Messaging. - - - -```gradle -buildscript { - - repositories { - // Check that you have the following line (if not, add it): - google() // Google's Maven repository - } - - dependencies { - // ... - - // Add the following line: - classpath 'com.google.gms:google-services:4.3.3' // Google Services plugin - } -} - -allprojects { - // ... - - repositories { - // Check that you have the following line (if not, add it): - google() // Google's Maven repository - // ... - } -} -``` - - - - -```gradle -apply plugin: 'com.android.application' -apply plugin: 'com.google.gms.google-services' - -android { - //... -} - -dependencies { - //.. - implementation 'com.google.firebase:firebase-messaging:20.2.4' - //.. - implementation 'com.cometchat:pro-android-chat-sdk:2.1.0' -} -``` - - - - - -#### **2. Using FirebaseMessaging Service & Broadcast Receiver** - -FirebaseMessagingService provides a method which helps to register token for client app by overriding onNewToken. - - - -```java -public class MyFirebaseMessagingService extends FirebaseMessagingService { - - private static final String TAG = "MyFirebaseService"; - public static String token; - - //.. - @Override - public void onNewToken(String s) { - token = s; - Log.d(TAG, "onNewToken: "+s); - } -} -``` - - - - - -#### **3. Subscribe and unsubscribe to topic(s)** - -1. After successful login using CometChat.login(), you can start the subscription process. -2. As mentioned earlier, you can either subscribe to one topic or subscribe to all. -3. The format for the name of user topic is `AppID_user_UID` -4. The format for the name of a group topic is `AppID_group_GUID` -5. You can unsubscribe when the user logs out (i.e. before calling the CometChat.logout() method) - - - -```java -public static void subscribeUserNotification(String UID) { - FirebaseMessaging.getInstance().subscribeToTopic(AppConfig.AppDetails.APP_ID + "_"+ CometChatConstants.RECEIVER_TYPE_USER +"_" + - UID); - } - - public static void unsubscribeUserNotification(String UID) { - FirebaseMessaging.getInstance().unsubscribeFromTopic(AppConfig.AppDetails.APP_ID + "_"+ CometChatConstants.RECEIVER_TYPE_USER +"_" + - UID); - } - - public static void subscribeGroupNotification(String GUID) { - FirebaseMessaging.getInstance().subscribeToTopic(AppConfig.AppDetails.APP_ID + "_"+ CometChatConstants.RECEIVER_TYPE_GROUP +"_" + - GUID); - } - - public static void unsubscribeGroupNotification(String GUID) { - FirebaseMessaging.getInstance().unsubscribeFromTopic(AppConfig.AppDetails.APP_ID + "_"+ CometChatConstants.RECEIVER_TYPE_GROUP +"_" + - GUID); - } -``` - - - - - -#### **4. Receive Messages** - -To receive messages, you need to override the `onMessageReceived (RemoteMessage remoteMessage)`. - - - -```java -package com.cometchat.pro.android.pushnotification.utils; - -import android.app.Notification; -import android.app.PendingIntent; -import android.content.Intent; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.media.RingtoneManager; -import android.util.Log; - -import androidx.core.app.NotificationCompat; -import androidx.core.app.NotificationManagerCompat; - -import com.cometchat.pro.android.pushnotification.R; -import com.cometchat.pro.android.pushnotification.constants.AppConfig; -import com.cometchat.pro.constants.CometChatConstants; -import com.cometchat.pro.core.Call; -import com.cometchat.pro.helpers.CometChatHelper; -import com.cometchat.pro.models.BaseMessage; -import com.google.android.gms.tasks.OnSuccessListener; -import com.google.firebase.messaging.FirebaseMessaging; -import com.google.firebase.messaging.FirebaseMessagingService; -import com.google.firebase.messaging.RemoteMessage; - -import org.json.JSONException; -import org.json.JSONObject; - -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.Date; - -import constant.StringContract; - -public class MyFirebaseMessagingService extends FirebaseMessagingService { - - private static final String TAG = "MyFirebaseService"; - private JSONObject json; - private Intent intent; - private int count=0; - private Call call; - public static String token; - private static final int REQUEST_CODE = 12; - - private boolean isCall; - - public static void subscribeUserNotification(String UID) { - FirebaseMessaging.getInstance().subscribeToTopic(AppConfig.AppDetails.APP_ID + "_"+ CometChatConstants.RECEIVER_TYPE_USER +"_" + - UID).addOnSuccessListener(new OnSuccessListener() { - @Override - public void onSuccess(Void aVoid) { - Log.e(TAG, UID+ " Subscribed Success"); - } - }); - } - - public static void unsubscribeUserNotification(String UID) { - FirebaseMessaging.getInstance().unsubscribeFromTopic(AppConfig.AppDetails.APP_ID + "_"+ CometChatConstants.RECEIVER_TYPE_USER +"_" + - UID).addOnSuccessListener(new OnSuccessListener() { - @Override - public void onSuccess(Void aVoid) { - Log.e(TAG, UID+ " Unsubscribed Success"); - } - }); - } - - public static void subscribeGroupNotification(String GUID) { - FirebaseMessaging.getInstance().subscribeToTopic(AppConfig.AppDetails.APP_ID + "_"+ CometChatConstants.RECEIVER_TYPE_GROUP +"_" + - GUID).addOnSuccessListener(new OnSuccessListener() { - @Override - public void onSuccess(Void aVoid) { - Log.e(TAG, GUID+ " Subscribed Success"); - } - }); - } - - public static void unsubscribeGroupNotification(String GUID) { - FirebaseMessaging.getInstance().unsubscribeFromTopic(AppConfig.AppDetails.APP_ID + "_"+ CometChatConstants.RECEIVER_TYPE_GROUP +"_" + - GUID); - } - - @Override - public void onNewToken(String s) { - token = s; - Log.d(TAG, "onNewToken: "+s); - } - - @Override - public void onMessageReceived(RemoteMessage remoteMessage) { - try { - count++; - json = new JSONObject(remoteMessage.getData()); - Log.d(TAG, "JSONObject: "+json.toString()); - JSONObject messageData = new JSONObject(json.getString("message")); - BaseMessage baseMessage = CometChatHelper.processMessage(new JSONObject(remoteMessage.getData().get("message"))); - if (baseMessage instanceof Call){ - call = (Call)baseMessage; - isCall=true; - } - showNotifcation(baseMessage); - } catch (JSONException e) { - e.printStackTrace(); - } - } - - public Bitmap getBitmapFromURL(String strURL) { - if (strURL!=null) { - try { - URL url = new URL(strURL); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setDoInput(true); - connection.connect(); - InputStream input = connection.getInputStream(); - Bitmap myBitmap = BitmapFactory.decodeStream(input); - return myBitmap; - } catch (IOException e) { - e.printStackTrace(); - return null; - } - } else { - return null; - } - } - - private void showNotifcation(BaseMessage baseMessage) { - - try { - int m = (int) ((new Date().getTime())); - String GROUP_ID = "group_id"; - - NotificationCompat.Builder builder = new NotificationCompat.Builder(this,"2") - .setSmallIcon(R.drawable.cc) - .setContentTitle(json.getString("title")) - .setContentText(json.getString("alert")) - .setPriority(NotificationCompat.PRIORITY_HIGH) - .setColor(getResources().getColor(R.color.colorPrimary)) - .setLargeIcon(getBitmapFromURL(baseMessage.getSender().getAvatar())) - .setGroup(GROUP_ID) - .setCategory(NotificationCompat.CATEGORY_MESSAGE) - .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) - .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); - - NotificationCompat.Builder summaryBuilder = new NotificationCompat.Builder(this,"2") - .setContentTitle("CometChat") - .setContentText(count+" messages") - .setSmallIcon(R.drawable.cc) - .setGroup(GROUP_ID) - .setGroupSummary(true); - NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); - - if (isCall){ - builder.setGroup(GROUP_ID+"Call"); - if (json.getString("alert").equals("Incoming audio call") || json.getString("alert").equals("Incoming video call")) { - builder.setOngoing(true); - builder.setPriority(NotificationCompat.PRIORITY_HIGH); - builder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE)); - builder.addAction(0, "Answers", PendingIntent.getBroadcast(getApplicationContext(), REQUEST_CODE, getCallIntent("Answers"), PendingIntent.FLAG_UPDATE_CURRENT)); - builder.addAction(0, "Decline", PendingIntent.getBroadcast(getApplicationContext(), 1, getCallIntent("Decline"), PendingIntent.FLAG_UPDATE_CURRENT)); - } - notificationManager.notify(05,builder.build()); - } - else { - notificationManager.notify(baseMessage.getId(), builder.build()); - notificationManager.notify(0, summaryBuilder.build()); - } - - } catch (Exception e) { - e.printStackTrace(); - } - - } - - private Intent getCallIntent(String title){ - Intent callIntent = new Intent(getApplicationContext(), CallNotificationAction.class); - callIntent.putExtra(StringContract.IntentStrings.SESSION_ID,call.getSessionId()); - callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - callIntent.setAction(title); - return callIntent; - } -} -``` - - - - - -`CallNotificationAction.java` is a Broadcast Receiver which is used to handle call events when app is in the background. - -Since Android O, there have been certain restrictions added for background tasks and users cannot launch intent directly from the service. More details can be found [here](https://developer.android.com/guide/components/activities/background-starts). - - - -```java -package com.cometchat.pro.android.pushnotification.utils; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.util.Log; -import android.widget.Toast; - -import androidx.core.app.NotificationManagerCompat; - -import com.cometchat.pro.constants.CometChatConstants; -import com.cometchat.pro.core.Call; -import com.cometchat.pro.core.CometChat; -import com.cometchat.pro.exceptions.CometChatException; -import com.cometchat.pro.models.Group; -import com.cometchat.pro.models.User; - -import constant.StringContract; -import screen.CallActivity; - -public class CallNotificationAction extends BroadcastReceiver { - - String TAG = "CallNotificationAction"; - @Override - public void onReceive(Context context, Intent intent) { - String sessionID = intent.getStringExtra(StringContract.IntentStrings.SESSION_ID); - Log.e(TAG, "onReceive: " + intent.getStringExtra(StringContract.IntentStrings.SESSION_ID)); - if (intent.getAction().equals("Answers")) { - CometChat.acceptCall(sessionID, new CometChat.CallbackListener() { - @Override - public void onSuccess(Call call) { - Intent acceptIntent = new Intent(context, CometChatCallActivity.class); - acceptIntent.putExtra(StringContract.IntentStrings.SESSION_ID,call.getSessionId()); - acceptIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - context.startActivity(acceptIntent); - } - - @Override - public void onError(CometChatException e) { - Toast.makeText(context,"Error "+e.getMessage(),Toast.LENGTH_LONG).show(); - } - }); - NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); - notificationManager.cancel(05); - } - else { - CometChat.rejectCall(sessionID, CometChatConstants.CALL_STATUS_REJECTED, new CometChat.CallbackListener() { - @Override - public void onSuccess(Call call) { - NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); - notificationManager.cancel(05); - } - - @Override - public void onError(CometChatException e) { - - } - }); - } - } -} -``` - - - - - -You also need to add both of the above mentioned file in your `AndroidManifest.xml` to make Push notification work in Background as well. - - - -```xml - - - - - - -``` - - - - - -**6. Notification Channel** - -From Android O and above you need to use NotificationChannel to show notifications. You can add the below method in your Application class and call it in *OnCreate().* This method will manage the notification channel for your app. - - - -```java -private void createNotificationChannel() { - // Create the NotificationChannel, but only on API 26+ because - // the NotificationChannel class is new and not in the support library - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - CharSequence name = getString(R.string.app_name); - String description = getString(R.string.channel_description); - int importance = NotificationManager.IMPORTANCE_HIGH; - NotificationChannel channel = new NotificationChannel("2", name, importance); - channel.setDescription(description); - channel.enableVibration(true); - channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); - - // Register the channel with the system; you can't change the importance - // or other notification behaviors after this - NotificationManager notificationManager = getSystemService(NotificationManager.class); - notificationManager.createNotificationChannel(channel); - } -} -``` - - - - - -### For iOS - -#### Apple Developer Portal - -The following steps in this section are written on the assumption that you already have an app ID assigned to your client app - -**1. Create a Certificate Signing Request** - -To obtain a signing certificate required to sign apps for installation on iOS devices, you should first create a certificate signing request (CSR) file through Keychain Access on your Mac. - -1. Open the Keychain Access from the utility folder, go to Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority, and then click -2. The Certificate Information dialog box appears. Enter the email address that you use in your Apple Developer account, and enter a common name for your private key. Don't enter CA email address, choose Saved to disk, and then click the Continue button. -3. Specify the name of your CSR to save and choose the location to save the file on your local disk. Then your CSR file is created, which contains a public/private key pair. - -**2. Create an SSL Certificate** - -1. Sign in to your account at the [Apple Developer Member Center](https://developer.apple.com/membercenter). -2. Go to Certificates, Identifiers & Profiles. In the Identifiers > App IDs and select the Push Notifications service under Application Services -3. Click the Edit button. -4. Under the Push Notifications service, choose which SSL certificate to create either Development or Production. -5. In the Generate your certificate pane that appears after the selection, under Upload CSR file., upload the CSR file you created through the Choose File... button. To complete the process, choose Continue. When the certificate is ready, choose Download to save it to your Mac. -6. In order to install the downloaded certificate to the KeyChain Access on your Mac, double-click it. You can find the certificate in the KeyChain Access > login > Certificates. - -**3. Export and update .p12 file to Firebase** - -1. Type a name for the .p12 file and save it to your Mac. -2. Browse to the location where you saved your key, select it, and click Open. Add the key ID for the key (available in Certificates, Identifiers & Profiles in the Apple Developer Member Center) and export it. - -**4. Upload your APNs Certificates** - -1. Go to Firebase console and open your project. -2. Inside your iOS project in the Firebase console, select settings and then select the `Cloud Messaging` tab. -3. Scroll down to iOS app configuration, click the Upload button for APNS certificate. -4. Browse to the location where you saved your APNs Certificates, select it, and click Open. - -#### iOS App Setup - -**1. FCM Client on iOS** - -Add the Firebase SDK, Add the firebase pods that you want to install. You can include a Pod in your Podfile like this: - - - -```ruby -pod 'Firebase/Core' -pod 'Firebase/Messaging' -``` - - - - - -Import the Firebase module in your `AppDelegate`: - - - -```swift -import Firebase -``` - - - - -```objc -@import Firebase; -``` - - - - - -Configure a FirebaseApp shared instance, typically in your application's `application:didFinishLaunchingWithOptions` - - - -```swift -FirebaseApp.configure() -``` - - - - -```objc -[FIRApp configure]; -``` - - - - - -Register for remote notification, typically in your application's \`application:didFinishLaunchingWithOptions\`\`\` - - - -```swift -Messaging.messaging().delegate = self - -if #available(iOS 10.0, *) { - UNUserNotificationCenter.current().delegate = self - - let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound] - UNUserNotificationCenter.current().requestAuthorization( - options: authOptions, - completionHandler: { - _, - _ in - }) -} else { - let settings: UIUserNotificationSettings = - UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil) - application.registerUserNotificationSettings(settings) -} - -application.registerForRemoteNotifications() -``` - - - - -```objc -[FIRMessaging messaging].delegate = self; - -if ([UNUserNotificationCenter class] != nil) { - - [UNUserNotificationCenter currentNotificationCenter].delegate = self; - - UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge; - - [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions: authOptions completionHandler: ^ (BOOL granted, NSError * _Nullable error) { - // ... - } - ]; - -} else { - UIUserNotificationType allNotificationTypes = (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge); - - UIUserNotificationSettings * settings = [UIUserNotificationSettings settingsForTypes: allNotificationTypes categories: nil]; - - [application registerUserNotificationSettings: settings]; - -} -[application registerForRemoteNotifications]; -``` - - - - - -The FCM Registration token - - - -```swift -func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { - print("Unable to register for remote notifications: \\(error.localizedDescription)") -} - -func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { - print("APNs token retrieved: \\(deviceToken)") - - Messaging.messaging().apnsToken = deviceToken -} -``` - - - - -```objc --(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error -{ - NSLog(@"Unable to register for remote notifications: %@", error); -} - --(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken -{ - NSLog(@"APNs device token retrieved: %@", deviceToken); - [FIRMessaging messaging].APNSToken = deviceToken; -} -``` - - - - - -**2. Subscribe and Unsubscribe to topic(s)** - -1. The format for the name of user topic is `AppID_user_UID_ios` -2. The format for the name of a group topic is `AppID_group_GUID_ios` - - - -```swift -let userTopic: String = appID + "_user_" + logged_in_user_UID + "_ios" - -Messaging.messaging().subscribe(toTopic: userTopic) { error in - print("Subscribed to \\(userTopic) topic") -} -``` - - - - -```objc -NSString *userTopic = [NSString allow] init]; -userTopic = appID + "_user_" + logged_in_user_UID + "_ios"; - -[[FIRMessaging messaging] subscribeToTopic:@userTopic - completion:^(NSError * _Nullable error) { - NSLog(@"Subscribed to userTopic topic %@",userTopic); -}]; -``` - - - - -```swift -let groupTopic: String = appID + "_group_" + group_guid + "_ios" - -Messaging.messaging().subscribe(toTopic: groupTopic) { error in - print("Subscribed to \\(groupTopic) topic") -} -``` - - - - -```objc -NSString *groupTopic = [NSString allow] init]; -groupTopic = appID + "_group_" + group_guid + "_ios"; - -[[FIRMessaging messaging] subscribeToTopic:@groupTopic - completion:^(NSError * _Nullable error) { - NSLog(@"Subscribed to userTopic topic %@",groupTopic); -}]; -``` - - - - - - - -```swift -/** -* log out from `CometChat` and unsubscribe from `FCM` push notifications -*/ -CometChat.logout(onSuccess: { (success) in - Messaging.messaging().unsubscribe(fromTopic: userTopic) - Messaging.messaging().unsubscribe(fromTopic: groupTopic) -}) {(error) in - -} -``` - - - - -```objc -/** - * log out from `CometChat` and unsubscribe from `FCM` push notifications - */ -[CometChat logoutOnSuccess:^(NSString * _Nonnull logoutSuccess) { - - [[FIRMessaging messaging] unsubscribeFromTopic:userTopic]; - [[FIRMessaging messaging] unsubscribeFromTopic:groupTopic]; -} onError:^(CometChatException * _Nonnull error) { - NSLog(@"error in login %@",[error errorDescription]); -}]; -``` - - - - - -**3. Receive Remote notifications** - -This typically happens in your application's AppDelegate - - - -```swift -func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) { - - // Print full message. - print(userInfo) -} - -func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping(UIBackgroundFetchResult) -> Void) { - - // Print full message. - print(userInfo) - - completionHandler(UIBackgroundFetchResult.newData) -} -``` - - - - -```objc -- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { - - // Print full message. - NSLog(@"%@", userInfo); -} - -- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo - fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { - - // Print full message. - NSLog(@"%@", userInfo); - - completionHandler(UIBackgroundFetchResultNewData); -} -``` - - - - - -Receive and display notifications for `CustomMessage`, you need to set the `metadata` while sending the `CustomMessage`: - - - -```swift -var receiverID = "cometchat-uid-1"; -var message = [ - "someRandomKey": "someRandomData" -]; - -var customMessage = CustomMessage(receiverUid: receiverID, receiverType: ReceiverTypeUser, customData: message); - -// to display custom notification banner add this , "pushNotification" key is not to modify, although you can modify banner text as shown beow // -var customNotificationDisplayText = [ - "pushNotification": "notification_banner_text_here"; -]; - -// set it as metadata of `Custom message` -customMessage.metaData = customNotificationDisplayText; - -CometChat.sendCustomMessage(withMessage: customMessage, onSuccess: { sentMessage in - - print("sentMessage \\(sentMessage.stringValue)"); - -}, onError: { error in - - if let error = error?.errorDescription() { - print("error sending custom message \\(error)"); - } -}); -``` - - - - -```objc -NSString * receiverID = @ "cometchat-uid-1"; -NSDictionary * message = [NSDictionary dictionaryWithObjectsAndKeys: @ "someRandomData", @ "someRandomKey", nil]; - -CustomMessage * customMessage = [ - [CustomMessage alloc] initWithReceiverUid: receiverID receiverType: ReceiverTypeUser customData: message -]; - -// to display custom notification banner add this // -NSDictionary * customNotificationDisplayText = [NSDictionary dictionaryWithObjectsAndKeys: @ "notification_banner_text_here", @ "pushNotification", nil]; - -[customMessage setMetaData: customNotificationDisplayText]; - - -[CometChat sendCustomMessageWithMessage: customMessage onSuccess: ^ (CustomMessage * _Nonnull sentMessage) { - - NSLog(@ "sentMessage %@", [sentMessage stringValue]); - - } - onError: ^ (CometChatException * _Nullable error) { - - NSLog(@ "error sending custom message %@", [error errorDescription]); - } -]; -``` - - - - - -### For React Native - -#### **1. Installing Firebase SDK** - -Install the react-native-firebase package in your project. - - - -```sh -npm install @react-native-firebase/app @react-native-firebase/messaging -``` - - - - -```sh -yarn add @react-native-firebase/app @react-native-firebase/messaging -``` - - - - - -**2. Android Setup** - -To allow the Android app to securely connect to your Firebase project, a configuration file must be downloaded and added to your project. - -Download the `google-services.json` file and place it inside of your project at the following location: /android/app/google-services.json. - -**Configure Firebase in Android:** - -To allow Firebase on Android to use the credentials, the google-services plugin must be enabled on the project. This requires modification to two files in the Android directory. - -Add the google-services plugin as a dependency inside of your `/android/build.gradle`. - -Execute the plugin by adding the following to your `/android/app/build.gradle` file. - - - -```gradle -buildscript { - dependencies { - // ... other dependencies - classpath 'com.google.gms:google-services:4.3.3' - // Add me --- _\\ - } -} -``` - - - - -```gradle -apply plugin: 'com.android.application' -apply plugin: 'com.google.gms.google-services' // <- Add this line -``` - - - - - -#### **3. iOS Setup** - -To allow the iOS app to securely connect to your Firebase project, a configuration file must be downloaded and added to your project. - -On the Firebase console, add a new iOS application and enter your project details. The "iOS bundle ID" must match your local project bundle ID. The bundle ID can be found within the "General" tab when opening the project with Xcode. - -Download the GoogleService-Info.plist file. - -Using Xcode, open the projects /ios/\{projectName}.xcodeproj file (or /ios/\{projectName}.xcworkspace if using Pods). - -Right-click on the project name and "Add files" to the project, as demonstrated below: - - - - - -Select the downloaded `GoogleService-Info.plist` file from your computer, and ensure the "Copy items if needed" checkbox is enabled. - - - - - -**Configure Firebase in iOS:** - -To allow Firebase on iOS to use the credentials, the Firebase iOS SDK must be configured during the bootstrap phase of your application. - -To do this, open your /ios/\{projectName}/AppDelegate.m file, and add the following: - -At the top of the file, import the Firebase SDK: - - - -```swift -#import -``` - - - - - -Within your existing `didFinishLaunchingWithOptions` method, add the following to the top of the method: - - - -```objc -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - // Add me --- \\_ - if ([FIRApp defaultApp] == nil) { - [FIRApp configure]; - } - // Add me --- _\\ - // ... -} -``` - - - - - -In the Firebase console, you have to include either APNs Authentication Key or APNs Certificate in Project Settings > Cloud Messaging in order to receive push notifications. - -Turn on the following two capabilities in Xcode: a. Push Notifications & b. Background Modes - Check only Remote Notifications. - - - - - -Lastly, Open your projects /ios/Podfile and add any of the globals shown below to the top of the file: - - - -```ruby -# Override Firebase SDK Version -$FirebaseSDKVersion = '6.29.0' -``` - - - - - -**4. Handling Push Notifications** - -You can refer to the below code for handling Push Notifications in React Native. - - - -```js -import React from "react"; -import { - SafeAreaView, - StyleSheet, - View, - Text, - StatusBar, - TouchableOpacity, - Alert, - Platform, -} from "react-native"; -import messaging from "@react-native-firebase/messaging"; -import { CometChat } from "@cometchat/chat-sdk-react-native"; -import { decode, encode } from "base-64"; - -if (!global.btoa) { - global.btoa = encode; -} - -if (!global.atob) { - global.atob = decode; -} - -var topics = []; -this.DOMParser = require("xmldom").DOMParser; -class App extends React.Component { - async componentDidMount() { - this.checkPermission(); - this.createNotificationListeners(); - } - - async checkPermission() { - const authStatus = await messaging.requestPermission(); - const enabled = - authStatus === messaging.AuthorizationStatus.AUTHORIZED || - authStatus === messaging.AuthorizationStatus.PROVISIONAL; - if (enabled) { - await messaging.getToken(); - } - } - - createNotificationListeners() { - this.messageListener = messaging.onMessage(async (remoteMessage) => { - Alert.alert("A new FCM message arrived!", JSON.stringify(remoteMessage)); - }); - } - - subscribeForPushNotification() { - var appSettings = new CometChat.AppSettingsBuilder() - .subscribePresenceForAllUsers() - .setRegion(region) - .build(); - CometChat.init("APP_ID", appSettings).then( - () => { - CometChat.login("UID", "API_KEY").then((user) => { - CometChat.getJoinedGroups().then((groups) => { - let isiOS = Platform.OS === "ios"; - var userTopic = appId + "_user_" + user.getUid(); - if (isiOS) { - var userTopicIos = userTopic + "_ios"; - topics.push(userTopicIos); - } else { - var userTopicIos = userTopic + "_notification"; - topics.push(userTopic); - } - groups.forEach((group) => { - var groupTopic = appId + "_group_" + group; - if (isiOS) { - var groupTopicIos = groupTopic + "_ios"; - topics.push(groupTopicIos); - } else { - var groupTopicIos = groupTopic + "_notification"; - topics.push(groupTopic); - } - }); - topics.forEach(async (topic) => { - console.log("subscribing to topic => ", topic); - await messaging.subscribeToTopic(topic); - }); - }); - }); - }, - (error) => { - console.log("Initialization failed with error:", error); - } - ); - } - - unsubscribeFromPushNotification() { - topics.forEach(async (topic) => { - await messaging.unsubscribeFromTopic(topic); - }); - } - - render() { - return ( - <> - - - - - CometChat Push Notification - - - - - { - this.subscribeForPushNotification(); - }} - style={styles.linkContainer} - > - Subscribe for push notification - - - - - { - this.unsubscribeFromPushNotification(); - }} - style={styles.linkContainer} - > - Unsubscribe from push notification - - - - - - ); - } -} -const styles = StyleSheet.create({ - body: { - backgroundColor: "#fff", - justifyContent: "space-around", - alignItems: "center", - flex: 1, - height: "100%", - }, - linkContainer: { - justifyContent: "center", - alignItems: "center", - paddingVertical: 8, - backgroundColor: "#ddd", - borderRadius: 40, - height: 40, - width: "80%", - }, - separator: { - backgroundColor: "#ddd", - height: 1, - width: "100%", - }, -}); - -export default App; -``` - - - - - -#### **5. Subscribe to and u nsubscribe from topics** - -Refer to the JavaScript section above for subscription and unsubscription code. - -### For Capacitor, Cordova & Ionic (Deprecated) - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility. - - -**1. Firebase Plugins** - -For Cordova & Ionic, there are numerous plugins available via NPM which can be used to set up push notifications for your apps like [FCM Plugin](https://ionicframework.com/docs/v3/native/fcm/) and [Push Plugin](https://ionicframework.com/docs/native/push). - -To setup Push Notification, you need to follow the steps mentioned in the Plugin's Documentation. You need to make different apps on the firebase console for each platform respectively (Android, iOS). - -**2. Subscribe and unsubscribe process** - -Refer to the JavaScript section above for subscription and unsubscription code. - -**3. Receiving Push notifications** - -Here you can use the callback provided by the plugin. For eg: If you are using the [FCM Plugin](https://ionicframework.com/docs/v3/native/fcm/) you can receive the messages as follows: - - - -```js -this.fcm.onNotification().subscribe((data) => { - console.log("here you receive the message", data); -}); -``` - - - - - -This should ideally be added in the app.component.ts file and should be called in the success of the platform.ready(). - -For other plugins, you can refer to the documentation provided by the plugin to check how messages can be received using that plugin. Once you have started receiving messages, you can act on the received messages accordingly as per your requirements. - -### Converting Push payload to message object - -CometChat SDK provides a method `CometChat.CometChatHelper.processMessage()` to convert the message JSON to the corresponding object of `TextMessage`, `MediaMessage`, `CustomMessage`, `Action` or `Call`. - -This code needs to be added to the `onMessageReceived()` method of the `FirebaseMessagingService` class. - - - -```js -let processedMessage = CometChat.CometChatHelper.processMessage(JSON_MESSAGE); -``` - - - - -```java -CometChatHelper.processMessage(new JSONObject(remoteMessage.getData().get("message")); -``` - - - - -```swift -func userNotificationCenter(_ center: UNUserNotificationCenter, - willPresent notification: UNNotification, - withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { - - if let userInfo = (notification.request.content.userInfo as? [String : Any]){ - let messageObject = userInfo["message"] - - if let someString = messageObject as? String { - - if let dict = someString.stringTodictionary(){ - - print("BaseMessage Object: \\(CometChat.processMessage(dict))") - } - } - } -} - -extension String { - - - func stringTodictionary() -> [String:Any]? { - - var dictonary:[String:Any]? - - if let data = self.data(using: .utf8) { - - do { - dictonary = try JSONSerialization.jsonObject(with: data, options: []) as? [String : Any] - - if let myDictionary = dictonary - { - return myDictionary; - } - } catch let error as NSError { - print(error) - } - - } - return dictonary; - } -} -``` - - - - -```js -let processedMessage = CometChat.CometChatHelper.processMessage(JSON_MESSAGE); -``` - - - - -```js -// Ionic Cordova is deprecated - use JavaScript SDK -let processedMessage = CometChat.CometChatHelper.processMessage(JSON_MESSAGE); -``` - - - - - - -Attachments can be of the following types: - -`CometChatConstants.MESSAGE_TYPE_IMAGE`\ -`CometChatConstants.MESSAGE_TYPE_VIDEO`\ -`CometChatConstants.MESSAGE_TYPE_AUDIO`\ -`CometChatConstants.MESSAGE_TYPE_FILE` - - diff --git a/notifications/push-notifications-extension-legacy.mdx b/notifications/push-notifications-extension-legacy.mdx deleted file mode 100644 index 219096f91..000000000 --- a/notifications/push-notifications-extension-legacy.mdx +++ /dev/null @@ -1,5154 +0,0 @@ ---- -title: "Push Notifications (Legacy)" -description: "Push notification setup guides." ---- - - - -**Legacy Notice**: This extension is already included as part of the core messaging experience and is scheduled for deprecation in the near future. - -Please note: Legacy extensions are no longer actively maintained and will not receive feature updates or enhancements. - - - -Learn how to send push notifications to mobile apps and desktop browsers. - -Push notifications will work in iOS and Android apps as well as desktop browsers that support [Push API](https://caniuse.com/#feat=push-api). These browsers include: - -1. Chrome 50+ -2. Firefox 44+ -3. Edge 17+ -4. Opera 42+ - -## Implementation - -1. If you are new and want to implement Token-based Push Notifications in your app, follow our platform-specific guides: - - 1. [JavaScript](#web) (Web) - 2. [Android](#android) - 3. [iOS](#ios-fcm) - 4. [Flutter](#flutter) - 5. [React Native](#react-native) - 6. [Capacitor, Cordova & Ionic](#capacitor%2C-cordova-%26-ionic) - -2. For Android and iOS we also have setup that allows the usage of Native calling screens: - - 1. [Android - Connection Service](#android-connection-service) - 2. [iOS - APNs](#ios-apns) - -3. [Token management](#token-management) to manage FCM and APNs tokens for the logged-in user. - -4. [Mute functionality](#mute-functionality) to mute certain conversations or implement DND. - -## Web - -The Push Notification extension allows you to send push notifications to mobile apps and desktop browsers. - -Push notifications will work in all desktop browsers which support [Push API](https://caniuse.com/#feat=push-api). These include: - -1. Chrome 50+ -2. Firefox 44+ -3. Edge 17+ -4. Opera 42+ - - - Push notifications sample app for Web (React) - - View on Github - - -## Firebase Project Setup - -Visit [Firebase Console](https://console.firebase.google.com) and login/signup using your Gmail ID. - -### Step 1: Create a new Firebase Project - - - - - -This is a simple 3 step process where: - -1. You give a name to your project -2. Add Google Analytics to your project (Optional) -3. Configure Google Analytics account (Optional) - -Click on Create and you are ready to go. - -### Step 2: Add Firebase to your Web App - -1. Click on the Web icon on the below screen and Register your app with a nickname. -2. Once done, click on Continue to Console. - - - - - -### Step 3: Download the service account file - - - - - -## Extension settings - -### Step 1: Enable the extension - -1. Login to [CometChat](https://app.cometchat.com/login) and select your app. -2. Go to the Extensions section and Enable the Push Notifications. -3. Open the settings for the extension and add all the mentioned settings and hit save. - - - - - -### Step 2: Save your settings - -On the Settings page you need to enter the following: - -1. **Set extension version** - -* If you are setting it for the first time, Select `V2` to start using the token-based version of the Push Notification extension. -* If you already have an app using `V1` and want to migrate your app to use `V2`, then Select `V1 & V2` option. This ensures that the users viewing the older version of your app also receive Push Notifications. -* Eventually, when all your users are on the latest version of your app, you can change this option to `V2`, thus turning off `V1` (Topic-based) Push Notifications completely. - -2. **Select the platforms that you want to support** - -* Select from Web, Android, Ionic (Deprecated), React Native, Flutter & iOS. - -3. **Notification payload settings** - -* You can control if the notification key should be in the Payload or not. Learn more about the FCM Messages [here](https://firebase.google.com/docs/cloud-messaging/). - -4. **Push payload message options** - - - - - -* The maximum payload size supported by FCM and APNs for push notifications is approximately 4 KB. Due to the inclusion of CometChat's message object, the payload size may exceed this limit, potentially leading to non-delivery of push notifications for certain messages. The options provided allow you to remove the sender's metadata, receiver's metadata, message metadata and trim the content of the text field. - -* The message metadata includes the outputs of the Thumbnail Generation, Image Moderation, and Smart Replies extensions. You may want to retain this metadata if you need to customize the notification displayed to the end user based on these outputs. - -5. **Notification Triggers** - - - - - -* Select the triggers for sending Push Notifications. These triggers can be classified into 3 main categories: - - 1. Message Notifications - 2. Call Notifications - 3. Group Notifications - -* These are pretty self-explanatory and you can toggle them as per your requirement. - -## Web App Setup - -### Step 1: Folder and files setup - -Create a folder with the following three files: - -| Files | Description | -| ------------------------- | ------------------------------------------------------------------------------------------- | -| index.html | Displays a simple User Login Form. | -| PushNotification.js | File with the logic to initialize CometChat and Firebase. | -| firebase-messaging-sw\.js | Service worker shows Push Notifications when the tab is either in the background or closed. | - -### Step 2: Add the Firebase Config to the HTML File - -1. Go to the Firebase Console and click on the Web app and open up the Settings page. -2. Go to the "General" tab on the Settings page. -3. Scroll down and copy the Firebase SDK snippet and paste in the \ tag of your index.html file. - - - - - -### Step 3: Setup index.html file - -1. Include the latest CometChat library using CDN. - -2. Register the service worker file. - -3. Also, include the `PushNotification.js`. - -4. The \ has a simple form: - - 1. Text input for UID. - 2. Login button. - 3. Logout button. - -Once done, your `index.html` file should look like this: - - - -```html - - - - - - - Push Notification Sample - - - - - - - - - - - - - - - - - - - - Push Notifications (Legacy)
-
- - - - - -``` - -
- -
- -### Step 4: Setup the service worker file - -1. Use `importScripts` to include the `firebase-app.js` and `firebase-messaging.js` files in the service worker. -2. Also paste in the `FIREBASE_CONFIG` object again in this file. -3. Initialize the Firebase object using the config. -4. Call the messaging() on the Firebase object. - -Once done, your `firebase-messaging-sw.js` file should look like this: - - - -```js -importScripts('https://www.gstatic.com/firebasejs/7.21.0/firebase-app.js'); -importScripts( - 'https://www.gstatic.com/firebasejs/7.21.0/firebase-messaging.js' -); - -const FIREBASE_CONFIG = { - // Your Config -}; - -// Initialize firebase in the service worker. -firebase.initializeApp(FIREBASE_CONFIG); - -// Start Receiving Push Notifications when -// the browser tab is in the background or closed. -firebase.messaging(); -``` - - - - - -### Step 5: Setup the PushNotification.js file - -Now our simple web app has the following: - -1. Setup required to start using Firebase SDK. -2. Service worker registration when the index.html loads for the first time. - -Next, we can focus on the flow to setup CometChat login process along with the steps required to setup Push Notifications using Firebase Cloud Messaging (or FCM). - -During login: - -1. Initialize CometChat. -2. Login using CometChat user. -3. Ask for the User's permission to show Push Notifications. -4. If permission is granted, obtain the `FCM_TOKEN`. -5. Register the obtained `FCM_TOKEN` with the extension. - -During logout: - -1. First delete the token using the firebase object. -2. Logout CometChat user. - -The above steps have been implemented in the `login` and `logout` functions in the `PushNotifications.js` file. You can copy paste the below code. Do not forget to replace the `APP_ID`, `REGION`, `AUTH_KEY` of your app in the code below. - - - -```js -const APP_ID = 'APP_ID'; -const REGION = 'REGION'; -const AUTH_KEY = 'AUTH_KEY'; - -const APP_SETTING = new CometChat.AppSettingsBuilder() - .subscribePresenceForAllUsers() - .setRegion(REGION) - .build(); -let FCM_TOKEN = ''; - -let loginButton; -let logoutButton; - -const login = async () => { - const UID = document.getElementById('uid').value; - if (!UID) { - document.getElementById('uid').focus(); - return; - } - loginButton.disabled = true; - console.log('Initiating login... '); - try { - // CC init - await CometChat.init(APP_ID, APP_SETTING); - - // User login - const loginResponse = await CometChat.login(UID, AUTH_KEY); - console.log('1. User login complete', loginResponse); - - CometChat.getLoggedinUser().then((user) => console.log(user.name)); - // Change the page title - document.title = UID + ' logged in'; - - // Fetch the FCM Token - const messaging = firebase.messaging(); - FCM_TOKEN = await messaging.getToken(); - console.log('2. Received FCM Token', FCM_TOKEN); - - // Register the FCM Token - await CometChat.registerTokenForPushNotification(FCM_TOKEN); - console.log('3. Registered FCM Token'); - - logoutButton.disabled = false; - } catch (error) { - console.error(error); - } -}; - -const logout = async () => { - console.log('Initiating logout...'); - loginButton.disabled = true; - logoutButton.disabled = true; - try { - // Delete the token - const messaging = firebase.messaging(); - await messaging.deleteToken(); - - // Logout the user - await CometChat.logout(); - console.log('5. Logged out'); - - // Refresh the page. - init(); - window.location.reload(); - } catch (error) { - console.error(error); - } -}; - -const init = () => { - // Basic initialization - loginButton = document.getElementById('loginButton'); - logoutButton = document.getElementById('logoutButton'); - - loginButton.addEventListener('click', login); - logoutButton.addEventListener('click', logout); - - logoutButton.disabled = true; -}; - -window.onload = () => { - // Call the initialization function on load. - setTimeout(init, 300); -}; -``` - - - - - -## Start receiving Push Notifications - -1. You can now host the project folder using Nginx, Apache web server, or even VSCode Live server extension. -2. Launch the web app in a browser and open the browser console to see the logs. -3. Enter the UID of the user and click on login. -4. When asked for permission to show notifications, click on Allow. -5. Once you see logs saying that the FCM Token has been registered, either send the browser tab to the background or close it completely. -6. Send a message to this logged-in user from another device (using our Sample Apps) and you should be able to see the Push Notifications. - -## Stop receiving Push Notifications - -1. Reopen the previous closed browser tab and click on logout. -2. The `FCM_TOKEN` will be deleted on the extension's end on the `CometChat.logout()` call. -3. As a good practice, the `FCM_TOKEN` should also be deleted using the `firebase.messaging().deleteToken()`. - -## Custom body for notifications - -To send custom body for notifications or to receive notification of `CustomMessage`, you need to set metadata while sending the `CustomMessage`. - - - -```js -var receiverID = 'UID'; -var customData = { - latitude: '50.6192171633316', - longitude: '-72.68182268750002', -}; - -var customType = 'location'; -var receiverType = CometChat.RECEIVER_TYPE.USER; -var metadata = { - pushNotification: 'Your Notification Message', -}; - -var customMessage = new CometChat.CustomMessage( - receiverID, - receiverType, - customType, - customData -); - -customMessage.setMetadata(metadata); - -CometChat.sendCustomMessage(customMessage).then( - (message) => { - // Message sent successfully. - console.log('custom message sent successfully', message); - }, - (error) => { - console.log('custom message sending failed with error', error); - // Handle exception. - } -); -``` - - - - - -## Android - -The Push Notification extension allows you to send push notifications to mobile apps and desktop browsers. In this section, we will see how to send Push Notifications to your Android app using Firebase Cloud Messaging or FCM. - - -Use Connection Service - -If you want to use the System's native call service to handle calls, please refer to our guide on [Android - Connection Service](#android-connection-service) - - - - - Android Push notifications sample app - - View on Github - - -## Firebase Project Setup - -Visit [Firebase Console](https://console.firebase.google.com) and login/signup using your Gmail ID. - -### Step 1: Create a new Firebase Project - -On your Firebase Console, create a new project. - - - - - -This is a simple 3 step process where: - -1. You give a name to your project -2. Add Google Analytics to your project (Optional) -3. Configure Google Analytics account (Optional) - -Click on Create and you are ready to go. - -### Step 2: Add Firebase to your Android App - -1. Click on the Android icon as shown on the screen below. - - - - - -2. Register your Android app by providing the following details: - - 1. Android Package name - 2. App nickname (optional) - 3. Debug signing certificate SHA-1 (optional) - - - - - -3. Download the `google-services.json` file and place it in the required location in your project. - - - - - -4. Add Firebase SDK by copying and pasting the snippets in the Project-level `build.gradle` file. - - - - - -5. Add Firebase SDK by copying and pasting the snippets in the App-level `build.gradle` file. - - - - - -6. Click on 'Continue to Console' to finish the setup. - -### Step 3: Download the service account file - - - - - -## Extension settings - -### Step 1: Enable the extension - -1. Login to [CometChat](https://app.cometchat.com/login) and select your app. -2. Go to the Extensions section and Enable the Push Notifications extension. -3. Open the settings for this extension and save the following. - - - - - -### Step 2: Save your settings - -On the Settings page you need to enter the following: - -1. **Set extension version** - -* If you are setting it for the first time, Select `V2` to start using the token-based version of the Push Notification extension. -* If you already have an app using `V1` and want to migrate your app to use `V2`, then Select `V1 & V2` option. This ensures that the users viewing the older version of your app also receive Push Notifications. -* Eventually, when all your users are on the latest version of your app, you can change this option to `V2`, thus turning off `V1` (Topic-based) Push Notifications completely. - -2. **Select the platforms that you want to support** - -* Select from Web, Android, Ionic (Deprecated), React Native, Flutter & iOS. - -3. **Notification payload settings** - -* You can control if the notification key should be in the Payload or not. Learn more about the FCM Messages [here](https://firebase.google.com/docs/cloud-messaging). - -4. **Push payload message options** - - - - - -The maximum payload size supported by FCM and APNs for push notifications is approximately 4 KB. Due to the inclusion of CometChat's message object, the payload size may exceed this limit, potentially leading to non-delivery of push notifications for certain messages. The options provided allow you to remove the sender's metadata, receiver's metadata, message metadata and trim the content of the text field. - -* The message metadata includes the outputs of the Thumbnail Generation, Image Moderation, and Smart Replies extensions. You may want to retain this metadata if you need to customize the notification displayed to the end user based on these outputs. - -5. **Notification Triggers** - - - - - -* Select the triggers for sending Push Notifications. These triggers can be classified into 3 main categories: - - 1. Message Notifications - 2. Call Notifications - 3. Group Notifications - -* These are pretty self-explanatory and you can toggle them as per your requirement. - -## Android App Setup - -In the Firebase Project setup, we did the following things: - -1. Added google-services.json file to the project. -2. Added the required Firebase SDK snippets to the Project-level build.grade file. -3. Added the required Firebase SDK snippets to the App-level build.gradle file. - -If you want more details, check the [Firebase Documentation](https://firebase.google.com/docs/cloud-messaging/android/client). - -### Step 1: Register the FCM Token on user login - -1. Initialize CometChat and then login your user. -2. On successful login, you can register the obtained FCM Token using `CometChat.registerTokenForPushNotification()` function call. (You can see the process of getting the FCM Token in the next step) - - - -```java -CometChat.registerTokenForPushNotification(MyFirebaseMessagingService.token, new CometChat.CallbackListener() { - @Override - public void onSuccess(String s) { - Log.e( "onSuccessPN: ",s ); - } - @Override - public void onError(CometChatException e) { - Log.e("onErrorPN: ",e.getMessage() ); - } -}); -``` - - - - -```kotlin -CometChat.registerTokenForPushNotification(MyFirebaseMessagingService.token, object : CallbackListener() { - override fun onSuccess(s: String?) { - Log.e("onSuccessPN: ", s) - } - - override fun onError(e: CometChatException) { - Log.e("onErrorPN: ", e.message) - } - }) -``` - - - - - -To fetch the registered token you can use below Firebase method. - - - -```java -FirebaseInstanceId.getInstance().getInstanceId().addOnCompleteListener( - new OnCompleteListener() { - @Override - public void onComplete(@NonNull Task task) { - if (!task.isSuccessful()) { - return; - } - token = task.getResult().getToken(); - //CometChat.registerTokenForPushNotification(token, CometChat.CallbackListener()); - } -}); -``` - - - - -```kotlin -FirebaseInstanceId.getInstance().getInstanceId() - .addOnCompleteListener(object : OnCompleteListener() { - fun onComplete(task: com.google.android.gms.tasks.Task) { - if (!task.isSuccessful()) { - return - } - token = task.getResult().getToken() - //CometChat.registerTokenForPushNotification(token,CometChat.CallbackListener()) - } - }) -``` - - - - - -### Step 2: Receive notifications - -1. The FCM Token can be received by overriding the `onNewToken()` method. This token is stored as a String variable. You can choose to store it in SharedPreferences as well. -2. To receive messages, you need to override the onMessageReceived(RemoteMessage remoteMessage). -3. [PushNotificationService.java](https://github.com/cometchat/cometchat-push-notification-app-android/blob/v4-push-notifications-extension/app/src/main/java/com/cometchat/pushnotificationsample/PushNotificationService.java) has the code that provides a way you can handle messages received from CometChat users and groups. -4. CallNotificationAction.class is a BroadcastReceiver which is used to handle call events when your app is in the background state. -5. Since Android O, there have been certain restrictions added for background tasks and users cannot launch intent directly from the service. More details [here](https://developer.android.com/guide/components/activities/background-starts). -6. We suggest you to create notification channel inside your application class. After Android O, it is necessary to register notification channel to allow notifications of your apps. - - - -```java -private void createNotificationChannel() { - // Create the NotificationChannel, but only on API 26+ because - // the NotificationChannel class is new and not in the support library - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - CharSequence name = getString(R.string.app_name); - String description = getString(R.string.channel_description); - int importance = NotificationManager.IMPORTANCE_HIGH; - NotificationChannel channel = new NotificationChannel("2", name, importance); - channel.setDescription(description); - channel.enableVibration(true); - channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); - // Register the channel with the system; you can't change the importance - // or other notification behaviors after this - NotificationManager notificationManager = getSystemService(NotificationManager.class); - notificationManager.createNotificationChannel(channel); - } - } -``` - - - - - -* You also need to add both of the above-mentioned files in your AndroidManifest.xml to make Push notification work in the background as well. - - - -```xml - - - - - - -``` - - - - - -## Advanced - -### Converting Push Notification Payloads to Message Objects - -CometChat provides a method `CometChatHelper.processMessage()` to convert the message JSON to the corresponding object of `TextMessage`, `MediaMessage`, `CustomMessage`, `Action` or `Call`. - -This code needs to be added to the `onMessageReceived()` method of the `FirebaseMessagingService` class. - - - -```java -CometChatHelper.processMessage(new JSONObject(remoteMessage.getData().get("message")); -``` - - - - - - - -Type of Attachment can be of the following the type\ -`CometChatConstants.MESSAGE_TYPE_IMAGE`\ -`CometChatConstants.MESSAGE_TYPE_VIDEO`\ -`CometChatConstants.MESSAGE_TYPE_AUDIO`\ -`CometChatConstants.MESSAGE_TYPE_FILE` - - - -Push Notification Payload sample for text and media messages- - - - -```json -{ - "alert": "Nancy Grace: Text Message", - "sound": "default", - "title": "CometChat", - "message": { - "receiver": "cometchat-uid-4", - "data": { - "entities": { - "receiver": { - "entityType": "user", - "entity": { - "uid": "cometchat-uid-4", - "role": "default", - "name": "Susan Marie", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-4.webp", - "status": "offline" - } - }, - "sender": { - "entityType": "user", - "entity": { - "uid": "cometchat-uid-3", - "role": "default", - "name": "Nancy Grace", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp", - "status": "offline" - } - } - }, - "text": "Text Message" - }, - "sender": "cometchat-uid-3", - "receiverType": "user", - "id": "142", - "sentAt": 1555668711, - "category": "message", - "type": "text" - } -} -``` - - - - -```json -{ - "alert": "Nancy Grace: has sent an image", - "sound": "default", - "title": "CometChat", - "message": { - "receiver": "cometchat-uid-4", - "data": { - "attachments": [ - { - "extension": "png", - "size": 14327, - "name": "extension_leftpanel.png", - "mimeType": "image_png", - "url": "https://s3-eu-west-1.amazonaws.com/data.cometchat.com/1255466c41bd7f/media/1555671238_956450103_extension_leftpanel.png" - } - ], - "entities": { - "receiver": { - "entityType": "user", - "entity": { - "uid": "cometchat-uid-4", - "role": "default", - "name": "Susan Marie", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-4.webp", - "status": "offline" - } - }, - "sender": { - "entityType": "user", - "entity": { - "uid": "cometchat-uid-3", - "role": "default", - "name": "Nancy Grace", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp", - "status": "offline" - } - } - }, - "url": "https://s3-eu-west-1.amazonaws.com/data.cometchat.com/1255466c41bd7f/media/1555671238_956450103_extension_leftpanel.png" - }, - "sender": "cometchat-uid-3", - "receiverType": "user", - "id": "145", - "sentAt": 1555671238, - "category": "message", - "type": "image" - } -} -``` - - - - - -### Handle Push Notification Actions. - - - - - -**Step 1. Process push notification payload and grab BaseMessage object** - -To open a chat view, firstly you will need a BaseMessage object. You can grab this from the push notification payload received in `onMessageReceived(RemoteMessage message)`. You need to call `CometChat.processMessage()` method to process push notification payload. - - - -```java -@Override -public void onMessageReceived(RemoteMessage remoteMessage) { - try { - JSONObject messageData = new JSONObject(remoteMessage.getData().get("message")); - BaseMessage baseMessage = CometChatHelper.processMessage(messageData); - - //Process BaseMessage and show Notification - } catch (JSONException e) { - e.printStackTrace(); - } -} -``` - - - - - -**Step 2 . Handle Notification Actions** - -You can launch the chat view after you tap on the Message Notification by creating PendingIntent and set it with NotificationBuilder object. - - - -CometChatMessageListActivity is part of UI Kit Library. You can replace CometChatMessageListActivity with your required class. - - - -## Android Connection Service - -Learn how to send Push Notifications to your Android app using Firebase Cloud Messaging or FCM. - - - Android Push notifications sample app - - View on Github - - -## Firebase Project Setup - -Visit [Firebase Console](https://console.firebase.google.com/) and login/signup using your Gmail ID. - -### Step 1: Create a new Firebase Project - -On your Firebase Console, create a new project. - - - - - -This is a simple 3 step process where: - -1. You give a name to your project -2. Add Google Analytics to your project (Optional) -3. Configure Google Analytics account (Optional) - -Click on Create and you are ready to go. - -### Step 2: Add Firebase to your Android App - -1. Click on the Android icon as shown on the screen below. - - - - - -2. Register your Android app by providing the following details: - - 1. Android Package name - 2. App nickname (optional) - 3. Debug signing certificate SHA-1 (optional) - - - - - - - -3. Download the google-services.json file and place it in the required location in your project. - - - - - -4. Add Firebase SDK by copying and pasting the snippets in the Project-level build.gradle file. - - - - - -5. Add Firebase SDK by copying and pasting the snippets in the App-level build.gradle file. - - - - - -6. Click on 'Continue to Console' to finish the setup. - -### Step 3: Download the service account file - - - - - -## Extension settings - -### Step 1: Enable the extension - -1. Login to [CometChat](https://app.cometchat.com/login) and select your app. -2. Go to the Extensions section and Enable the Push Notifications extension. -3. Open the settings for this extension and save the following. - - - - - -### Step 2: Save your settings - -On the Settings page you need to enter the following: - -1. **Set extension version** - -* If you are setting it for the first time, Select `V2` to start using the token-based version of the Push Notification extension. -* If you already have an app using `V1` and want to migrate your app to use `V2`, then Select `V1 & V2` option. This ensures that the users viewing the older version of your app also receive Push Notifications. -* Eventually, when all your users are on the latest version of your app, you can change this option to `V2`, thus turning off `V1` (Topic-based) Push Notifications completely. - -2. **Select the platforms that you want to support** - -* Select from Web, Android, Ionic (Deprecated), React Native, Flutter & iOS. - -3. **Notification payload settings** - -* You can control if the notification key should be in the Payload or not. Learn more about the FCM Messages [here](https://firebase.google.com/docs/cloud-messaging). - -4. **Push payload message options** - - - - - -The maximum payload size supported by FCM and APNs for push notifications is approximately 4 KB. Due to the inclusion of CometChat's message object, the payload size may exceed this limit, potentially leading to non-delivery of push notifications for certain messages. The options provided allow you to remove the sender's metadata, receiver's metadata, message metadata and trim the content of the text field. - -* The message metadata includes the outputs of the Thumbnail Generation, Image Moderation, and Smart Replies extensions. You may want to retain this metadata if you need to customize the notification displayed to the end user based on these outputs. - -5. **Notification Triggers** - - - - - -* Select the triggers for sending Push Notifications. These triggers can be classified into 3 main categories: - - 1. Message Notifications - 2. Call Notifications - 3. Group Notifications - -* These are pretty self-explanatory and you can toggle them as per your requirement. - -## Android App Setup - -In the Firebase Project setup, we did the following things: - -1. Added google-services.json file to the project. -2. Added the required Firebase SDK snippets to the Project-level build.grade file. -3. Added the required Firebase SDK snippets to the App-level build.gradle file. - -If you want more details, check the [Firebase Documentation](https://firebase.google.com/docs/cloud-messaging/android/client). - -### Step 1: Register the FCM Token on user login - -1. Initialize CometChat and then login your user. -2. On successful login, you can register the obtained FCM Token using `CometChat.registerTokenForPushNotification()` function call. (You can see the process of getting the FCM Token in the next step) - - - -```java -CometChat.registerTokenForPushNotification(MyFirebaseMessagingService.token, new CometChat.CallbackListener() { - @Override - public void onSuccess(String s) { - Log.e( "onSuccessPN: ",s ); - } - @Override - public void onError(CometChatException e) { - Log.e("onErrorPN: ",e.getMessage() ); - } -}); -``` - - - - -```kotlin -CometChat.registerTokenForPushNotification(MyFirebaseMessagingService.token, object : CallbackListener() { - override fun onSuccess(s: String?) { - Log.e("onSuccessPN: ", s) - } - - override fun onError(e: CometChatException) { - Log.e("onErrorPN: ", e.message) - } - }) -``` - - - - - -To fetch the registered token you can use below Firebase method. - - - -```java -FirebaseInstanceId.getInstance().getInstanceId().addOnCompleteListener( - new OnCompleteListener() { - @Override - public void onComplete(@NonNull Task task) { - if (!task.isSuccessful()) { - return; - } - token = task.getResult().getToken(); - //CometChat.registerTokenForPushNotification(token, CometChat.CallbackListener()); - } -}); -``` - - - - -```kotlin -FirebaseInstanceId.getInstance().getInstanceId() - .addOnCompleteListener(object : OnCompleteListener() { - fun onComplete(task: com.google.android.gms.tasks.Task) { - if (!task.isSuccessful()) { - return - } - token = task.getResult().getToken() - //CometChat.registerTokenForPushNotification(token,CometChat.CallbackListener()) - } - }) -``` - - - - - -### Step 2: Setup ConnectionService. - - - - - -**ConnectionService** is an abstract service used to handle VoIP & other calls. It is part of android.telecom package which helps to handle telecom services. ConnectionService can be used either as System-Managed Service where System defined UI is shown to handle the calls. It can also be used as Self-Managed Service where users can show their own calling UI to handle the calls. - -*Note - Currently the sample app uses system-managed connection service, So the System UI will be displayed to handle incoming calls.* - -Learn more about [ConnectionService](https://developer.android.com/reference/android/telecom/ConnectionService). - -| Files | Description | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| [CallConnectionService.java](https://github.com/cometchat/cometchat-push-notification-app-android/blob/v4-push-notifications-extension/app/src/main/java/com/cometchat/pushnotificationsample/CallConnectionService.java) | Custom ConnectionService file which is used to handle incoming & outgoing calls. It is used to manages the ConnectionService with your app. It also handles PhoneAccounts and bind it's services to Telecom. | -| [CallConnection.java](https://github.com/cometchat/cometchat-push-notification-app-android/blob/v4-push-notifications-extension/app/src/main/java/com/cometchat/pushnotificationsample/CallConnection.java) | Custom Connection class which is used to handle the callbacks of ConnectionService. Call backs such as onAnswer(), onReject(), onHold(), etc. | -| [CallManager.java](https://github.com/cometchat/cometchat-push-notification-app-android/blob/v4-push-notifications-extension/app/src/main/java/com/cometchat/pushnotificationsample/CallConnectionService.java) | It is used to manages the ConnectionService with your app. It also handles PhoneAccounts and bind it's services to Telecom. | - -### Step 3: Receive notifications - -1. The FCM Token can be received by overriding the `onNewToken()` method. This token is stored as a String variable. You can choose to store it in SharedPreferences as well. -2. To receive messages, you need to override the onMessageReceived(RemoteMessage remoteMessage). -3. [PushNotificationService.java](https://github.com/cometchat/cometchat-push-notification-app-android/blob/v4-push-notifications-extension/app/src/main/java/com/cometchat/pushnotificationsample/PushNotificationService.java) has the code that provides a way you can handle messages received from CometChat users and groups. -4. Since Android O, there have been certain restrictions added for background tasks and users cannot launch intent directly from the service. More details [here](https://developer.android.com/guide/components/activities/background-starts). -5. You also need to add the above-mentioned MyFirebasMessagingService.java fil in your AndroidManifest.xml to make Push notification work in the background as well. - - - -```xml - - - - - -``` - - - - - -### Converting Push Notification Payloads to Message Objects - -CometChat provides a method `CometChatHelper.processMessage()` to convert the message JSON to the corresponding object of `TextMessage`, `MediaMessage`, `CustomMessage`, `Action` or `Call`. - -This code needs to be added to the `onMessageReceived()` method of the `FirebaseMessagingService` class. - - - -```java -CometChatHelper.processMessage(new JSONObject(remoteMessage.getData().get("message")); -``` - - - - - - - -Type of Attachment can be of the following the type\ -`CometChatConstants.MESSAGE_TYPE_IMAGE`\ -`CometChatConstants.MESSAGE_TYPE_VIDEO`\ -`CometChatConstants.MESSAGE_TYPE_AUDIO`\ -`CometChatConstants.MESSAGE_TYPE_FILE` - - - -Push Notification Payload sample for text and media messages- - - - -```json -{ - "alert": "Nancy Grace: Text Message", - "sound": "default", - "title": "CometChat", - "message": { - "receiver": "cometchat-uid-4", - "data": { - "entities": { - "receiver": { - "entityType": "user", - "entity": { - "uid": "cometchat-uid-4", - "role": "default", - "name": "Susan Marie", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-4.webp", - "status": "offline" - } - }, - "sender": { - "entityType": "user", - "entity": { - "uid": "cometchat-uid-3", - "role": "default", - "name": "Nancy Grace", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp", - "status": "offline" - } - } - }, - "text": "Text Message" - }, - "sender": "cometchat-uid-3", - "receiverType": "user", - "id": "142", - "sentAt": 1555668711, - "category": "message", - "type": "text" - } -} -``` - - - - -```json -{ - "alert": "Nancy Grace: has sent an image", - "sound": "default", - "title": "CometChat", - "message": { - "receiver": "cometchat-uid-4", - "data": { - "attachments": [ - { - "extension": "png", - "size": 14327, - "name": "extension_leftpanel.png", - "mimeType": "image/png", - "url": "https://s3-eu-west-1.amazonaws.com/data.cometchat.com/1255466c41bd7f/media/1555671238_956450103_extension_leftpanel.png" - } - ], - "entities": { - "receiver": { - "entityType": "user", - "entity": { - "uid": "cometchat-uid-4", - "role": "default", - "name": "Susan Marie", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-4.webp", - "status": "offline" - } - }, - "sender": { - "entityType": "user", - "entity": { - "uid": "cometchat-uid-3", - "role": "default", - "name": "Nancy Grace", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp", - "status": "offline" - } - } - }, - "url": "https://s3-eu-west-1.amazonaws.com/data.cometchat.com/1255466c41bd7f/media/1555671238_956450103_extension_leftpanel.png" - }, - "sender": "cometchat-uid-3", - "receiverType": "user", - "id": "145", - "sentAt": 1555671238, - "category": "message", - "type": "image" - } -} -``` - - - - - -## iOS FCM - -Learn how to send out Push Notifications to your iOS using Firebase Cloud Messaging or FCM. - - -Don't want to use FCM? - -You can refer to [our setup](#ios-apns) using the Apple Push Notifications service (APNs). - - - - - iOS Push notifications sample app - - View on Github - - -## Firebase Project Setup - -Visit [Firebase Console](https://console.firebase.google.com/) and login/signup using your Gmail ID. - -### Step 1: Create a new Firebase Project - -On your Firebase Console, create a new project. - - - - - -This is a simple 3 step process where: - -1. You give a name to your project -2. Add Google Analytics to your project (Optional) -3. Configure Google Analytics account (Optional) - -Click on Create and you are ready to go. - -### Step 2: Add Firebase to your iOS App - -1. Click on the iOS icon as shown on the screen below. - - - - - -2. Register your Android app by providing the following details: a. iOS bundle name b. App nickname (optional) c. App Store ID (optional) - - - - - -3. Download the GoogleService-Info.plist file and place it in the mentioned location of your project. Move your config file into the root of your Xcode project. If prompted, select to add the config file to all targets as follows. - - - - - - - - - -4. We will Add Firebase SDK and Initialisation code later. So, click on 'Next', 'Next', and 'Continue to the Console'. - -### Step 3: Download the service account file - - - - - -## Extension settings - -### Step 1: Enable the extension - -1. Login to [CometChat](https://app.cometchat.com/login) and select your app. -2. Go to the Extensions section and Enable the Push Notifications extension. -3. Open the settings for this extension and save the following settings. - - - - - -### Step 2: Save your settings - -On the Settings page you need to enter the following: - -1. **Set extension version** - -* If you are setting it for the first time, Select `V2` to start using the token-based version of the Push Notification extension. -* If you already have an app using `V1` and want to migrate your app to use `V2`, then Select `V1 & V2` option. This ensures that the users viewing the older version of your app also receive Push Notifications. -* Eventually, when all your users are on the latest version of your app, you can change this option to `V2`, thus turning off `V1` (Topic-based) Push Notifications completely. - -2. **Select the platforms that you want to support** - -* Select from Web, Android, Ionic (Deprecated), React Native, Flutter & iOS. - -3. **Notification payload settings** - -* You can control if the notification key should be in the Payload or not. Learn more about the FCM Messages [here](https://firebase.google.com/docs/cloud-messaging). - -4. **Push payload message options** - - - - - -The maximum payload size supported by FCM and APNs for push notifications is approximately 4 KB. Due to the inclusion of CometChat's message object, the payload size may exceed this limit, potentially leading to non-delivery of push notifications for certain messages. The options provided allow you to remove the sender's metadata, receiver's metadata, message metadata and trim the content of the text field. - -* The message metadata includes the outputs of the Thumbnail Generation, Image Moderation, and Smart Replies extensions. You may want to retain this metadata if you need to customize the notification displayed to the end user based on these outputs. - -5. **Notification Triggers** - - - - - -* Select the triggers for sending Push Notifications. These triggers can be classified into 3 main categories: - - 1. Message Notifications - 2. Call Notifications - 3. Group Notifications - -* These are pretty self-explanatory and you can toggle them as per your requirement. - -## Get APNS Credentials - -The following steps in this section are written on the assumption that you already have an app ID assigned to your client app. - -### Step 1: Create a Certificate Signing Request - -To obtain a signing certificate required to sign apps for installation on iOS devices, you should first create a certificate signing request (CSR) file through Keychain Access on your Mac. - -1. Open the Keychain Access from the utility folder, go to Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority, and then click. - - - - - -2. The Certificate Information dialog box appears. Enter the email address that you use in your Apple Developer account, and enter a common name for your private key. Don't enter CA email address, choose Saved to disk, and then click the Continue button. - - - - - -3. Specify the name of your CSR to save and choose the location to save the file on your local disk. Then your CSR file is created, which contains a public/private key pair. - -### Step 2: Create an SSL certificate - -1. Sign in to your account at the [Apple Developer Member Center](https://developer.apple.com/membercenter). -2. Go to Certificates, Identifiers & Profiles. In the Identifiers > App IDs and select the Push Notifications service under Application Services -3. Click the Edit button. - - - - - -4. Under the Push Notifications service, choose which SSL certificate to create either Development or Production. - - - - - -5. In the Generate your certificate pane that appears after the selection, under Upload CSR file., upload the CSR file you created through the Choose File... button. To complete the process, choose Continue. When the certificate is ready, choose Download to save it to your Mac. - - - - - -6. In order to install the downloaded certificate to the KeyChain Access on your Mac, double-click it. You can find the certificate in the KeyChain Access > login > Certificates. - -### Step 3: Export and update .p12 file to Firebase - -1. Type a name for the .p12 file and save it to your Mac. -2. Browse to the location where you saved your key, select it, and click Open. Add the key ID for the key (available in Certificates, Identifiers & Profiles in the Apple Developer Member Center) and export it. - - - - - -### Step 4: Upload your APNs Certificates - -1. Go to Firebase console and open your project. -2. Inside your iOS project in the Firebase console, select settings and then select the `Cloud Messaging` tab. -3. Scroll down to iOS app configuration, click the Upload button for APNS certificate. -4. Browse to the location where you saved your APNs Certificates, select it, and click Open. - - - - - -## iOS App Setup - -### Step 1: Initial Firebase Cloud Messaging client setup - -1. Add the Firebase SDK, Add the firebase pods that you want to install. You can include a Pod in your Podfile like this: - - - -```swift -pod 'Firebase_Core' -pod 'Firebase_Messaging' -``` - - - - - -2. Import the Firebase module in your `ApplicationDelegate:` - - - -```swift -import Firebase -``` - - - - -```objc -@import Firebase; -``` - - - - - -3. Configure a FirebaseApp shared instance, typically in your application's `application:didFinishLaunchingWithOptions: method:` - - - -```swift -FirebaseApp.configure() -``` - - - - -```objc -[FIRApp configure]; -``` - - - - - -### Step 2: Register the FCM Token - -1. Get the FCM Token for remote notifications, typically in your application's `application:didFinishLaunchingWithOptions: method:` - - - -```swift -Messaging.messaging().delegate = self - -if #available(iOS 10.0, *) { - UNUserNotificationCenter.current().delegate = self - - let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound] - UNUserNotificationCenter.current().requestAuthorization( - options: authOptions, - completionHandler: { - _, - _ in - }) -} else { - let settings: UIUserNotificationSettings = - UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil) - application.registerUserNotificationSettings(settings) -} - -application.registerForRemoteNotifications() -``` - - - - -```objc -[FIRMessaging messaging].delegate = self; - -if ([UNUserNotificationCenter class] != nil) { - - [UNUserNotificationCenter currentNotificationCenter].delegate = self; - - UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert | UNAuthorizationOptionSound | UNAuthorizationOptionBadge; - - [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions: authOptions completionHandler: ^ (BOOL granted, NSError * _Nullable error) { - // ... - } - ]; - -} else { - UIUserNotificationType allNotificationTypes = (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge); - - UIUserNotificationSettings * settings = [UIUserNotificationSettings settingsForTypes: allNotificationTypes categories: nil]; - - [application registerUserNotificationSettings: settings]; - -} -[application registerForRemoteNotifications]; -``` - - - - - - - -```swift -func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { - print("Unable to register for remote notifications: \\(error.localizedDescription)") -} - -func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { - print("APNs token retrieved: \\(deviceToken)") - - Messaging.messaging().apnsToken = deviceToken -} -``` - - - - -```objc --(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error -{ - NSLog(@"Unable to register for remote notifications: %@", error); -} - --(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken -{ - NSLog(@"APNs device token retrieved: %@", deviceToken); - [FIRMessaging messaging].APNSToken = deviceToken; -} -``` - - - - - -2. Register the FCM token with our Push Notifications extension on success of CometChat.login - - - -```swift -let authKey = "XXXX XXXX XXXXX" - -CometChat.login(UID: UID, authKey: authKey, onSuccess: { (user) in - DispatchQueue.main.async { - if let token = UserDefaults.standard.value(forKey: "fcmToken") as? String { - CometChat.registerTokenForPushNotification(token: token, onSuccess: { (success) in - print("onSuccess to registerTokenForPushNotification: \\(success)") - }) { (error) in - print("error to registerTokenForPushNotification") - } -} -``` - - - - - -3. This also needs to be done when you refresh your FCM Token - - - -```swift -extension AppDelegate : MessagingDelegate { - // [START refresh_token] - func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) { - print("Firebase registration token: \\(fcmToken)") - - UserDefaults.standard.set(fcmToken, forKey: "fcmToken") - CometChat.registerTokenForPushNotification(token: fcmToken, onSuccess: { (sucess) in - print("token registered \\(sucess)") - }) { (error) in - print("token registered error \\(String(describing: error?.errorDescription))") - } - - - let dataDict:[String: String] = ["token": fcmToken] - NotificationCenter.default.post(name: Notification.Name("FCMToken"), object: nil, userInfo: dataDict) - } -} -``` - - - - - -### Step 3: Start receiving Push Notifications - -1. Receive remote notification, typically in your application's `App Delegate:` - - - -```swift -func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) { - - // Print full message. - print(userInfo) -} - -func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping(UIBackgroundFetchResult) -> Void) { - - // Print full message. - print(userInfo) - - completionHandler(UIBackgroundFetchResult.newData) -} -``` - - - - -```objc -- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { - - // Print full message. - NSLog(@"%@", userInfo); -} - -- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo - fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { - - // Print full message. - NSLog(@"%@", userInfo); - - completionHandler(UIBackgroundFetchResultNewData); -} -``` - - - - - -2. Receive Notification for `CustomMessage`: - -To receive and display push notifications for a CustomMessage, the developer must set metadata.pushNotification while sending the message. The value of this field is used as the notification text displayed to the recipient. If metadata.pushNotification is not set (or is null), the push notification will not be triggered for that message. - - - -```swift -var receiverID = "cometchat-uid-1"; -var message = [ - "someRandomKey": "someRandomData" -]; - -var customMessage = CustomMessage(receiverUid: receiverID, receiverType: ReceiverTypeUser, customData: message); - -// to display custom notification banner add this , "pushNotification" key is not to modify, although you can modify banner text as shown beow // -var customNotificationDisplayText = [ - "pushNotification": "notification_banner_text_here"; -]; - -// set it as metadata of `Custom message` -customMessage.metaData = customNotificationDisplayText; - -CometChat.sendCustomMessage(withMessage: customMessage, onSuccess: { sentMessage in - - print("sentMessage \\(sentMessage.stringValue)"); - -}, onError: { error in - - if let error = error?.errorDescription() { - print("error sending custom message \\(error)"); - } -}); -``` - - - - -```objc -NSString * receiverID = @ "cometchat-uid-1"; -NSDictionary * message = [NSDictionary dictionaryWithObjectsAndKeys: @ "someRandomData", @ "someRandomKey", nil]; - -CustomMessage * customMessage = [ - [CustomMessage alloc] initWithReceiverUid: receiverID receiverType: ReceiverTypeUser customData: message -]; - -// to display custom notification banner add this // -NSDictionary * customNotificationDisplayText = [NSDictionary dictionaryWithObjectsAndKeys: @ "notification_banner_text_here", @ "pushNotification", nil]; - -[customMessage setMetaData: customNotificationDisplayText]; - - -[CometChat sendCustomMessageWithMessage: customMessage onSuccess: ^ (CustomMessage * _Nonnull sentMessage) { - - NSLog(@ "sentMessage %@", [sentMessage stringValue]); - - } - onError: ^ (CometChatException * _Nullable error) { - - NSLog(@ "error sending custom message %@", [error errorDescription]); - } -]; -``` - - - - - -Push Notification Payload sample for text and media messages- - - - -```json -{ - "alert": "Nancy Grace: Text Message", - "sound": "default", - "title": "CometChat", - "message": { - "receiver": "cometchat-uid-4", - "data": { - "entities": { - "receiver": { - "entityType": "user", - "entity": { - "uid": "cometchat-uid-4", - "role": "default", - "name": "Susan Marie", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-4.webp", - "status": "offline" - } - }, - "sender": { - "entityType": "user", - "entity": { - "uid": "cometchat-uid-3", - "role": "default", - "name": "Nancy Grace", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp", - "status": "offline" - } - } - }, - "text": "Text Message" - }, - "sender": "cometchat-uid-3", - "receiverType": "user", - "id": "142", - "sentAt": 1555668711, - "category": "message", - "type": "text" - } -} -``` - - - - -```json -{ - "alert": "Nancy Grace: has sent an image", - "sound": "default", - "title": "CometChat", - "message": { - "receiver": "cometchat-uid-4", - "data": { - "attachments": [ - { - "extension": "png", - "size": 14327, - "name": "extension_leftpanel.png", - "mimeType": "image/png", - "url": "https://s3-eu-west-1.amazonaws.com/data.cometchat.com/1255466c41bd7f/media/1555671238_956450103_extension_leftpanel.png" - } - ], - "entities": { - "receiver": { - "entityType": "user", - "entity": { - "uid": "cometchat-uid-4", - "role": "default", - "name": "Susan Marie", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-4.webp", - "status": "offline" - } - }, - "sender": { - "entityType": "user", - "entity": { - "uid": "cometchat-uid-3", - "role": "default", - "name": "Nancy Grace", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp", - "status": "offline" - } - } - }, - "url": "https://s3-eu-west-1.amazonaws.com/data.cometchat.com/1255466c41bd7f/media/1555671238_956450103_extension_leftpanel.png" - }, - "sender": "cometchat-uid-3", - "receiverType": "user", - "id": "145", - "sentAt": 1555671238, - "category": "message", - "type": "image" - } -} -``` - - - - - -## Advanced - -### Convert Push Notification payload to Message object - -CometChat SDK provides a method `CometChat.CometChatHelper.processMessage()` which will take the JSON received in The push notification as input, and return the corresponding `TextMessage`, `MediaMessage`,`CustomMessage` or `Call` object in return. Once the message object is received, you can use the entity as per your requirements. - -This code needs to be added to the `willPresent notification` method of the `UNUserNotificationCenterDelegate` delegate. - - - -```swift -func userNotificationCenter(_ center: UNUserNotificationCenter, - willPresent notification: UNNotification, - withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { - if let userInfo = notification.request.content.userInfo as? [String : Any], let messageObject = userInfo["message"], let str = messageObject as? String, let dict = str.stringTodictionary() { - - if let baseMessage = CometChat.processMessage(dict).0 { - switch baseMessage.messageCategory { - case .message: - if let message = baseMessage as? BaseMessage { - switch message.messageType { - case .text: - print("text Messagge is: \\((message as?TextMessage)?.stringValue())") - case .image: - print("image Messagge is: \\((message as? MediaMessage)?.stringValue())") - case .video: - print("video Messagge is: \\((message as? MediaMessage)?.stringValue())") - case .audio: - print("audio Messagge is: \\((message as? MediaMessage)?.stringValue())") - case .file: - print("file Messagge is: \\((message as? MediaMessage)?.stringValue())") - case .custom: - print("custom Messagge is: \\((message as? MediaMessage)?.stringValue())") - case .groupMember: break - @unknown default:break} - } - case .action: break - case .call: - if let call = baseMessage as? Call { - print("call is: \\(call.stringValue())") - } - case .custom: - if let customMessage = baseMessage as? CustomMessage { - print("customMessage is: \\(customMessage.stringValue())") - } - @unknown default: break - } - } - } - completionHandler([.alert, .badge, .sound]) - } - -extension String { - func stringTodictionary() -> [String:Any]? { - var dictonary:[String:Any]? - if let data = self.data(using: .utf8) { - do { - dictonary = try JSONSerialization.jsonObject(with: data, options: []) as? [String : Any] - if let myDictionary = dictonary - { - return myDictionary; - } - } catch let error as NSError { - print(error) - } - } - return dictonary; - } -} -``` - - - - - -### Miscellaneous - -1. [Increment App Icon Badge Count](/sdk/ios/increment-app-icon-badge-count) -2. [Launch chat window on tap of push notification](/sdk/ios/launch-chat-window-on-tap-of-push-notification) - -## iOS APNs - -Apple Push Notification service or APNs is used to send notifications to iOS devices. With this, you can also use Apple's CallKit for showing the call screen. - - - iOS Push notifications sample app - - View on Github - - -## Get APNS Credentials - -The following steps in this section are written on the assumption that you already have an app ID assigned to your client app. - -### Step 1: Create a Certificate Signing Request - -To obtain a signing certificate required to sign apps for installation on iOS devices, you should first create a certificate signing request (CSR) file through Keychain Access on your Mac. - -1. Open the Keychain Access from the utility folder, go to Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority, and then click. - - - - - -2. The Certificate Information dialog box appears. Enter the email address that you use in your Apple Developer account, and enter a common name for your private key. Don't enter CA email address, choose Saved to disk, and then click the Continue button. - - - - - -3. Specify the name of your CSR to save and choose the location to save the file on your local disk. Then your CSR file is created, which contains a public/private key pair. - -### Step 2: Create an SSL certificate - -1. Sign in to your account at the [Apple Developer Member Center](https://developer.apple.com/membercenter). -2. Go to Certificates, Identifiers & Profiles. - - - - - -3. Create new Certificate by clicking on the + icon. - - - - - -4. Under Services, select - Apple Push Notification services SSL (Sandbox & Production) - - - - - -5. Select your App ID from the dropdown. - - - - - -6. Upload CSR file., upload the CSR file you created through the **Choose File** button. To complete the process, choose Continue. When the certificate is ready, choose Download to save it to your Mac. - - - - - - - - - -### Step 3: Export and update .p8 certificate - -1. To generate a .p8 key file, go to [Apple Developer Account](https://developer.apple.com/account/), then select Certificates, IDs & Profiles. -2. Select Keys and click on the "+" button to add a new key. -3. In the new key page, type in your key name and check the Apple Push Notification service (APNs) box, then click "Continue" and click "Register". -4. Then proceed to download the key file by clicking Download. -5. Make note of the `Key ID`, `Team ID` and your `Bundle ID` for saving in the Extension's settings. - -**If you wish to use the .p12 certificate instead, do the following:** - -1. Type a name for the .p12 file and save it to your Mac. -2. Browse to the location where you saved your key, select it, and click Open. Add the key ID for the key (available in Certificates, Identifiers & Profiles in the Apple Developer Member Center) and export it. -3. DO NOT provide an export password when prompted. -4. The .p12 file will be required in the next step for uploading in the CometChat Dashboard. - -## Extension settings - -### Step 1: Enable the extension - -1. Login to [CometChat](https://app.cometchat.com/login) and select your app. -2. Go to the Extensions section and Enable the Push Notifications extension. -3. Open the settings for this extension and save the following. - -### Step 2: Save your settings - - - - - - - - - -On the Settings page you need to enter the following: - -1. **Set extension version** - - 1. The extension version has to be set to 'V2' or 'V1 & V2' in order to use APNs as the provider. - -2. **Select Platforms** - - 1. You can select the platforms on which you wish to receive Push Notifications. - -3. **APNs Settings** - - 1. You can turn off the Production mode when you create a development build of your application. - 2. Upload the .p8 or .p12 certificate exported in the previous step. - -4. **Push payload message options** - - - - - -The maximum payload size supported by FCM and APNs for push notifications is approximately 4 KB. Due to the inclusion of CometChat's message object, the payload size may exceed this limit, potentially leading to non-delivery of push notifications for certain messages. The options provided allow you to remove the sender's metadata, receiver's metadata, message metadata and trim the content of the text field. - -* The message metadata includes the outputs of the Thumbnail Generation, Image Moderation, and Smart Replies extensions. You may want to retain this metadata if you need to customize the notification displayed to the end user based on these outputs. - -5. **Notification Triggers** - - 1. Select the triggers for sending Push Notifications. These triggers can be classified into 3 main categories: - - 1. Message Notifications - 2. Call Notifications - 3. Group Notifications - - 2. These are pretty self-explanatory and you can toggle them as per your requirement. - -## iOS App Setup - -### Initial Setup - -1. Call `CometChat.init()` method to initialize CometChat in your application. This needs to be called only once. -2. The user has to be logged in using `CometChat.login()` method. On the success callback, register the token with the extension. Two tokens need to be registered, out of which one is APNs token and other is CallKit token: a. `CometChat.registerTokenForPushNotification(token: apnsToken, settings: ["voip":false])`\ - b. `CometChat.registerTokenForPushNotification(token: voipToken, settings: ["voip":true])` - - - -```swift -let authKey = "XXXX XXXX XXXXX" - -CometChat.login(UID: UID, authKey: authKey, onSuccess: { (current_user) in - DispatchQueue.main.async { - if let apnsToken = UserDefaults.standard.value(forKey: "apnsToken") as? String { - print("APNS token is: \(apnsToken)") - CometChat.registerTokenForPushNotification(token: apnsToken, settings: ["voip":false]) { (success) in - print("onSuccess to registerTokenForPushNotification: \(success)") - DispatchQueue.main.async {self.activityIndicator.stopAnimating() - print("login success with : \(current_user.stringValue())") - self.performSegue(withIdentifier: "presentPushNotification", sender: nil) - } - } onError: { (error) in - print("error to registerTokenForPushNotification") - } - } - if let voipToken = UserDefaults.standard.value(forKey: "voipToken") as? String { - print("VOIP token is: \(voipToken)") - CometChat.registerTokenForPushNotification(token: voipToken, settings: ["voip":true]) { (success) in - print("onSuccess to registerTokenForPushNotification: \(success)") - DispatchQueue.main.async {self.activityIndicator.stopAnimating() - print("login success with : \(current_user.stringValue())") - self.performSegue(withIdentifier: "presentPushNotification", sender: nil) - } - } onError: { (error) in - print("error to registerTokenForPushNotification") - } - } - } - } - }) { (error) in - print("error while login", error); - } - } -``` - - - - - -3. Import PushKit and CallKit in AppDelegate.Swift file. - - - -```swift -import PushKit -import CallKit -``` - - - - - -### Receive Push Notifications - -1. Registering for the APNs notifications - - - -```swift -var window: UIWindow? -var uuid: UUID? -var activeCall: Call? -var cancelCall: Bool = true -var onCall = true -var callController = CXCallController() -let voipRegistry = PKPushRegistry(queue: DispatchQueue.main) -var provider: CXProvider? = nil - -func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - self.voipRegistration() - // [START register_for_notifications] -if #available(iOS 10.0, *) { -UNUserNotificationCenter.current().delegate = self -let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound] -UNUserNotificationCenter.current().requestAuthorization( -options: authOptions, -completionHandler: {_, _ in }) -} else { -let settings: UIUserNotificationSettings = -UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil) -application.registerUserNotificationSettings(settings) -} -application.registerForRemoteNotifications() -// [END register_for_notifications] -return true -} -// Register for VoIP notifications -func voipRegistration() { -// Create a push registry object -let mainQueue = DispatchQueue.main -let voipRegistry: PKPushRegistry = PKPushRegistry(queue: mainQueue) -voipRegistry.delegate = self -voipRegistry.desiredPushTypes = [PKPushType.voIP] -} -``` - - - - - -2. Add AppDelegate extension for receiving Push Notifications - - - -```swift -extension AppDelegate : UNUserNotificationCenterDelegate { -// Receive displayed notifications for iOS 10 devices. -func userNotificationCenter(_ center: UNUserNotificationCenter, -willPresent notification: UNNotification, -withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { -print("willPresent notification: \(notification.request.content.userInfo)") -if let userInfo = notification.request.content.userInfo as? [String : Any], let messageObject = -userInfo["message"], let str = messageObject as? String, let dict = str.stringTodictionary() { -if let baseMessage = CometChat.processMessage(dict).0 { -switch baseMessage.messageCategory { -case .message: -if let message = baseMessage as? BaseMessage { -switch message.messageType { -case .text: -print("text Messagge is: \((message as? TextMessage)?.stringValue())") -case .image: -print("image Messagge is: \((message as? MediaMessage)?.stringValue())") -case .video: -print("video Messagge is: \((message as? MediaMessage)?.stringValue())") -case .audio: -print("audio Messagge is: \((message as? MediaMessage)?.stringValue())") -case .file: -print("file Messagge is: \((message as? MediaMessage)?.stringValue())") -case .custom: -print("custom Messagge is: \((message as? MediaMessage)?.stringValue())") -case .groupMember: -break -@unknown default: -break -} -} -case .action: break -case .call: -if let call = baseMessage as? Call { -print("call is: \(call.stringValue())") -} -case .custom: -if let customMessage = baseMessage as? CustomMessage { -print("customMessage is: \(customMessage.stringValue())") -} -@unknown default: break -} -} -} -completionHandler([.alert, .badge, .sound]) -} -func userNotificationCenter(_ center: UNUserNotificationCenter, -didReceive response: UNNotificationResponse, -withCompletionHandler completionHandler: @escaping () -> Void) { -let notification = response.notification.request.content.userInfo -print("notification is 11: \(notification)") -completionHandler() -} -func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { -let token = deviceToken.reduce("", {$0 + String(format: "%02X", $1)}) -print("Device Token : ",token) -let hexString = deviceToken.map { String(format: "%02.2hhx", $0) }.joined() -print("Device Token 11: ",hexString) -UserDefaults.standard.set(hexString, forKey: "apnsToken") -CometChat.registerTokenForPushNotification(token: hexString, settings: ["voip":false]) { (success) in -print("registerTokenForPushNotification voip: \(success)") -} onError: { (error) in -print("registerTokenForPushNotification error: \(error)") -} -} -} -``` - - - - - -3. Add AppDelegate extension for VOIP notifications. Launch CallKit screen when the VOIP notification is received. Once the CallKit screen is displayed, you can Accept or Reject the CometChat call accordingly. - - - -```swift -// MARK: CallKit & PushKit -extension AppDelegate: PKPushRegistryDelegate , CXProviderDelegate { - - -func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) { - let deviceToken = pushCredentials.token.reduce("", {$0 + String(format: "%02X", $1) }) - print("voip token is: \(deviceToken)") - UserDefaults.standard.set(deviceToken, forKey: "voipToken") - CometChat.registerTokenForPushNotification(token: deviceToken, settings: ["voip":true]) { (success) in - print("registerTokenForPushNotification voip: \(success)") - } onError: { (error) in - print("registerTokenForPushNotification error: \(error)") - } - } - -func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) { - if let userInfo = payload.dictionaryPayload as? [String : Any], let messageObject = - userInfo["message"], let dict = messageObject as? [String : Any] { - - if let baseMessage = CometChat.processMessage(dict).0 { - switch baseMessage.messageCategory { - case .message: break - case .action: break - case .call: - if let call = baseMessage as? Call { - switch call.callStatus { - case .initiated: - self.activeCall = call - self.uuid = UUID() - if let name = (call.sender)?.name { - let config = CXProviderConfiguration(localizedName: "APNS + Callkit") - config.iconTemplateImageData = #imageLiteral(resourceName: "your_app_icon").pngData() - config.includesCallsInRecents = false - config.ringtoneSound = "ringtone.caf" - config.supportsVideo = true - provider = CXProvider(configuration: config) - provider?.setDelegate(self, queue: nil) - let update = CXCallUpdate() - update.remoteHandle = CXHandle(type: .generic, value: name.capitalized) - if call.callType == .video { - update.hasVideo = true - }else{ - update.hasVideo = false - } - provider?.reportNewIncomingCall(with: self.uuid!, update: update, completion: { error in - if error == nil { - self.configureAudioSession() - } - }) - } - case .ongoing, .unanswered, .rejected, .busy, .cancelled: - if self.activeCall != nil { - if self.cancelCall { - self.end(uuid: self.uuid!) - } - } - case .ended: break - @unknown default: break } - } - case .custom: break - @unknown default: break - } - } - } - } - - internal func configureAudioSession() { - do { - try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playAndRecord, options: [.mixWithOthers, .allowBluetooth, .defaultToSpeaker]) - try AVAudioSession.sharedInstance().setActive(true) - - } catch let error as NSError { - print(error) - } - } - - func providerDidReset(_ provider: CXProvider) { - if let uuid = self.uuid { - onCall = true - provider.reportCall(with: uuid, endedAt: Date(), reason: .unanswered) - } - } - -func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) { - if let activeCall = activeCall { - startCall() - } - action.fulfill() - } - -func provider(_ provider: CXProvider, perform action: CXEndCallAction) { - NotificationCenter.default.post(name: NSNotification.Name(rawValue: "didRejectButtonPressed"), object: nil, userInfo: nil) - end(uuid: self.uuid!) - onCall = true - if let activeCall = activeCall { - CometChat.rejectCall(sessionID: activeCall.sessionID ?? "", status: .rejected, onSuccess: {(rejectedCall) in - DispatchQueue.main.async { - CometChatSnackBoard.display(message: "CALL_REJECTED".localized(), mode: .info, duration: .short) - } - }) { (error) in - DispatchQueue.main.async { - if let errorMessage = error?.errorDescription { - CometChatSnackBoard.display(message: "CALL_REJECTED".localized(), mode: .info, duration: .short) - } - } - } - provider.reportCall(with: self.uuid!, endedAt: Date(), reason: .remoteEnded) - } - action.fail() - } - - func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) { - print(#function) - } - - func provider(_ provider: CXProvider, timedOutPerforming action: CXAction) { - action.fulfill() - print(#function) - } - - func provider(_ provider: CXProvider, perform action: CXSetHeldCallAction) { - print(#function) - } - - func provider(_ provider: CXProvider, perform action: CXSetMutedCallAction) { - print(#function) - } - - func end(uuid: UUID) { - print("endUUID",uuid) - let endCallAction = CXEndCallAction(call: uuid) - let transaction = CXTransaction() - transaction.addAction(endCallAction) - requestTransaction(transaction, action: "") - } - - func setHeld(uuid: UUID, onHold: Bool) { - print("setHeld",uuid) - let setHeldCallAction = CXSetHeldCallAction(call: uuid, onHold: onHold) - let transaction = CXTransaction() - transaction.addAction(setHeldCallAction) - - requestTransaction(transaction, action: "") - } - - internal func requestTransaction(_ transaction: CXTransaction, action: String = "") { - callController.request(transaction) { error in - if let error = error { - print("Error requesting transaction: \(error)") - } else { - print("Requested transaction successfully") - } - } - } - - public func startCall(){ - let activeCall = CometChatCall() - cancelCall = false - activeCall.modalPresentationStyle = .fullScreen - if let window = UIApplication.shared.windows.first , let rootViewController = window.rootViewController { - var currentController = rootViewController - while let presentedController = currentController.presentedViewController { - currentController = presentedController - } - currentController.present(activeCall, animated: true, completion: nil) - } - } -} -``` - - - - - -## Miscellaneous - -### Create view controller for Calls - -Create a viewController which will start the call when the user starts the call. - - - -```swift -import UIKit -import CometChatPro -import CallKit - -class CometChatCall: UIViewController { - - - override func viewDidLoad() { - super.viewDidLoad() - if let appDelegate = UIApplication.shared.delegate as? AppDelegate { - if let call = appDelegate.activeCall { - - if (call.callInitiator as? User)?.uid != CometChat.getLoggedInUser()?.uid { - - CometChat.acceptCall(sessionID: call.sessionID ?? "") { acceptedCall in - - DispatchQueue.main.async { - let callSettings = CallSettings.CallSettingsBuilder(callView: self.view, sessionId: acceptedCall?.sessionID ?? "").setMode(mode: .MODE_SINGLE).build() - - CometChat.startCall(callSettings: callSettings) { userJoined in - appDelegate.onCall = true - } onUserLeft: { onUserLeft in - - } onUserListUpdated: { onUserListUpdated in - - } onAudioModesUpdated: { onAudioModesUpdated in - - } onUserMuted: { onUserMuted in - - } onCallSwitchedToVideo: { onCallSwitchedToVideo in - - } onRecordingStarted: { onRecordingStarted in - - } onRecordingStopped: { onRecordingStopped in - - } onError: { error in - DispatchQueue.main.async { - self.dismiss(animated: true, completion: nil) - } - } onCallEnded: { ended in - DispatchQueue.main.async { - var str = "" - if let uuuid = appDelegate.uuid { - print("CometChatCalls", uuuid) - } - self.dismiss(animated: true, completion: nil) - self.dismiss(animated: true) - } - } - } - } onError: { error in - - } - }else{ - - let callSettings = CallSettings.CallSettingsBuilder(callView: self.view, sessionId: call.sessionID ?? "").setMode(mode: .MODE_SINGLE).build() - - CometChat.startCall(callSettings: callSettings) { userJoined in - - } onUserLeft: { onUserLeft in - - } onUserListUpdated: { onUserListUpdated in - - } onAudioModesUpdated: { onAudioModesUpdated in - - } onUserMuted: { onUserMuted in - - } onCallSwitchedToVideo: { onCallSwitchedToVideo in - - } onRecordingStarted: { onRecordingStarted in - - } onRecordingStopped: { onRecordingStopped in - - } onError: { error in - DispatchQueue.main.async { - self.dismiss(animated: true, completion: nil) - } - } onCallEnded: { ended in - DispatchQueue.main.async { - self.dismiss(animated: true, completion: nil) - } - } - } - } - } - } -} -``` - - - - - -### Convert Push Notification payload to Message object - -CometChat SDK provides a method `CometChat.CometChatHelper.processMessage()` which will take the JSON received in The push notification as input, and return the corresponding `TextMessage`, `MediaMessage`,`CustomMessage` or `Call` object in return. Once the message object is received, you can use the entity as per your requirements. - -This code needs to be added to the `willPresent notification` method of the `UNUserNotificationCenterDelegate` delegate. - - - -```swift -func userNotificationCenter(_ center: UNUserNotificationCenter, - willPresent notification: UNNotification, - withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { - if let userInfo = notification.request.content.userInfo as? [String : Any], let messageObject = userInfo["message"], let str = messageObject as? String, let dict = str.stringTodictionary() { - - if let baseMessage = CometChat.processMessage(dict).0 { - switch baseMessage.messageCategory { - case .message: - if let message = baseMessage as? BaseMessage { - switch message.messageType { - case .text: - print("text Messagge is: \((message as?TextMessage)?.stringValue())") - case .image: - print("image Messagge is: \((message as? MediaMessage)?.stringValue())") - case .video: - print("video Messagge is: \((message as? MediaMessage)?.stringValue())") - case .audio: - print("audio Messagge is: \((message as? MediaMessage)?.stringValue())") - case .file: - print("file Messagge is: \((message as? MediaMessage)?.stringValue())") - case .custom: - print("custom Messagge is: \((message as? MediaMessage)?.stringValue())") - case .groupMember: break - @unknown default:break} - } - case .action: break - case .call: - if let call = baseMessage as? Call { - print("call is: \(call.stringValue())") - } - case .custom: - if let customMessage = baseMessage as? CustomMessage { - print("customMessage is: \(customMessage.stringValue())") - } - @unknown default: break - } - } - } - completionHandler([.alert, .badge, .sound]) - } - -extension String { - func stringTodictionary() -> [String:Any]? { - var dictonary:[String:Any]? - if let data = self.data(using: .utf8) { - do { - dictonary = try JSONSerialization.jsonObject(with: data, options: []) as? [String : Any] - if let myDictionary = dictonary - { - return myDictionary; - } - } catch let error as NSError { - print(error) - } - } - return dictonary; - } -} -``` - - - - - -## Flutter - -Learn how to implement Push notifications for the Flutter platform using FCM as well as APNs. This document guides you to set up Flutter push notifications as follows: - -1. Using FCM to implement push notifications for messaging on Android and iOS. -2. Using APN to implement push notifications for messaging on iOS. - - -Flutter Push notifications support - -Push Notifications are supported in Flutter for CometChat SDK v3.0.9 and above. - - - -## FCM: Push notifications for messaging on Android and iOS - -For Push notifications from FCM to work on both Android and iOS, the push payload has to be of type `Notification message`. - -A `Notification message` is a push payload that has the notification key in it. These push notifications are handled directly by the OS and as a developer, you cannot customize these notifications. - -This simple setup can be used for apps that only implement messaging feature of CometChat. - -Learn more about [FCM messages](https://firebase.google.com/docs/cloud-messaging/). - - - Flutter Push notifications sample app - - Implementation using FCM for Android and iOS. - - View on Github - - -### Step 1: Install packages - -Add the following to your pubspec.yaml file under dependencies. - - - -```yaml -firebase_core: ^2.8.0 -firebase_messaging: ^14.3.0 -``` - - - - - -Install the packages. - - - -```sh -flutter pub get -``` - - - - - -### Step 2: Configure with flutterfire\_cli - -Use the following command to install `flutterfire_cli` - - - -```sh -dart pub global activate flutterfire_cli -``` - - - - - - - -```sh -flutterfire configure --project= -``` - - - - - -This will ask you for the platforms. Select `android` and `ios`. - -The CLI tool will add the following files to your directory structure: - -1. `google-services.json` to the android folder. -2. `GoogleService-Info.plist` to the ios folder. -3. `firebase_options.dart` to the `lib` folder. - -In the build.gradle file, change: - - - -```gradle -// Change this: -classpath 'com.google.gms:google-services:4.3.10' - -// to -classpath 'com.google.gms:google-services:4.3.14' -``` - - - - - -In your Firebase Console, go to project settings and upload the .p8 file obtained from the Apple Developer dashboard along with the Key ID and Team ID. - - - - - -### Step 3: FCM setup in app - -This requires you to first set up a global context. It will help you in opening your app once your notification is tapped. Using this global context, you can write a function to navigate to the screen of choice once the notification is tapped. - - - -```dart -import 'package:flutter/material.dart'; -import 'package:flutter_pn/screens/chat_screen.dart'; - -class NavigationService { - static final GlobalKey navigatorKey = - GlobalKey(); - - static void navigateToChat(String text) { - navigatorKey.currentState?.push( - MaterialPageRoute(builder: (context) => ChatScreen(chatId: text)), - ); - } -} -``` - - - - - -Once the user has logged in to CometChat, do the following to setup firebase: - -1. Write a top-level function that is outside of any call. This function will handle the notifications when the app is not in the foreground. - -2. Initialize firebase with the FirebaseOptions from the previous step. - -3. Get an instance of firebase messaging - -4. Request permissions - -5. Set up listeners once the permission is granted: - - 1. Background notification listener - 2. Refreshed token listener that records the FCM token with the extension. - 3. Notification tap listeners for background and terminated states of the app. - -6. Make a call to save the FCM token with the extension. - -### Step 4: Setup for iOS - -1. Open the project in XCode (`ios/Runner.xcworkspace` ) -2. Add **Push notifications** capability. -3. Add **Background execution** capability with **Background fetch** & **Remote notification** enabled. -4. Inside the `ios` folder, execute `pod install` . - -Fore more details refer to the [Firebase documentation](https://firebase.google.com/docs/cloud-messaging/flutter/client#ios). - -### Step 5: Run your application - -Running the app in profile mode for iOS enables you to see the working once the app is terminated. - - - -``` -flutter run -``` - - - - - - - -``` -flutter run --profile -``` - - - - - -### Step 6: Extension setup (FCM) - -1. Login to CometChat dashboard. -2. Go to the extensions section. -3. Enable the Push notifications extension. -4. Click on the settings icon to open the settings. -5. Upload the service account file that is available on the Firebase Console. -6. Make sure that you are including the `notification` key in the payload. Otherwise, this won't work. -7. Push payload message options - - - - - -The maximum payload size supported by FCM and APNs for push notifications is approximately 4 KB. Due to the inclusion of CometChat's message object, the payload size may exceed this limit, potentially leading to non-delivery of push notifications for certain messages. The options provided allow you to remove the sender's metadata, receiver's metadata, message metadata and trim the content of the text field. - -The message metadata includes the outputs of the Thumbnail Generation, Image Moderation, and Smart Replies extensions. You may want to retain this metadata if you need to customize the notification displayed to the end user based on these outputs. - -## APN: Push notifications for messaging on iOS - -Apple Push Notifications service or APNs is only available for Apple devices. This will not work on Android devices. - -This setup ensures that the Push notifications for CometChat messages is sent using APNs `device token`. - - - Flutter Push notifications sample app - - Implementation using APNs for iOS. - - View on Github - - -### Step 1: Install dependencies - -Add the following to your pubspec.yaml file under dependencies. - - - -```yaml -flutter_apns_only: 1.6.0 -``` - - - - - -### Step 2: Add capabilities - -1. Open the project in XCode (`ios/Runner.xcworkspace` ) -2. Add **Push notifications** capability. -3. Add **Background modes** capability with: - 1. Remote notifications - -### Step 3: Update AppDelegate.swift - -Add the below to your AppDeletegate.swift file. - - - -```swift -if #available(iOS 11.0, *) { - UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate -} -``` - - - - - -### Step 4: APN setup in app - -Setup a global context to be able to open your app to a specific screen if the notification is tapped. Using the global context, write a function to navigate to the screen of your choice: - - - -```dart -import 'package:flutter/material.dart'; -import 'package:flutter_pn/screens/chat_screen.dart'; - -class NavigationService { - static final GlobalKey navigatorKey = - GlobalKey(); - - static void navigateToChat(String text) { - navigatorKey.currentState?.push( - MaterialPageRoute(builder: (context) => ChatScreen(chatId: text)), - ); - } -} -``` - - - - - -Once the CometChat has been initialized and the user has logged in, do the required setup for the above packages that handle APNs and VoIP notifications. - -### Step 5: Run on a device - -Run your app on a real device as Push notifications don't work on emulators. - -Use the profile mode to see the behavior when the app is in the background or terminated states. - - - -``` -flutter run --profile -``` - - - - - -### Step 6: Extension setup (APN) - -1. Login to CometChat dashboard. -2. Go to the extensions section. -3. Enable the Push notifications extension. -4. Click on the settings icon to open the settings. -5. Save the Team ID, Key ID, Bundle ID and upload the p8 certificate obtained from Apple Developer console. -6. Push payload message options - -The maximum payload size supported by FCM and APNs for push notifications is approximately 4 KB. Due to the inclusion of CometChat's message object, the payload size may exceed this limit, potentially leading to non-delivery of push notifications for certain messages. The options provided allow you to remove the sender's metadata, receiver's metadata, message metadata and trim the content of the text field. - -* The message metadata includes the outputs of the Thumbnail Generation, Image Moderation, and Smart Replies extensions. You may want to retain this metadata if you need to customize the notification displayed to the end user based on these outputs. - -7. Save the settings. - - - - - -## React Native - -Learn how to set up Push notifications for React Native using Firebase Cloud Messaging or FCM. - - - React Native Push notifications sample app - - View on Github - - -## Firebase Project Setup - -Visit [Firebase](https://console.firebase.google.com/) and login/signup using your Gmail ID. - -### Step 1: Create a new Firebase Project - -Head over to the [Firebase Console](https://console.firebase.google.com/) to create a new project. - - - - - -This is a simple 3 step process where: - -1. You give a name to your project -2. Add Google Analytics to your project (Optional) -3. Configure Google Analytics account (Optional) - -Click on Create and you are ready to go. - -### Step 2: Add Firebase to your App - -React native setup will require 2 files for Android and iOS: - -1. For Android, you need to download the google-services.json file from the Firebase console. -2. For iOS, you need to download the GoogleService-Info.plist file from the Firebase console. - -### Step 3: Download the service account file - - - - - -## Extension settings - -### Step 1: Enable the extension - -1. Login to [CometChat](https://app.cometchat.com/login) and select your app. -2. Go to the Extensions section and Enable the Push Notifications extension. -3. Open up the settings and save the following settings. - - - - - -### Step 2: Save your settings - -On the Settings page you need to enter the following: - -1. **Set extension version** - -* If you are setting it for the first time, Select `V2` to start using the token-based version of the Push Notification extension. -* If you already have an app using `V1` and want to migrate your app to use `V2`, then Select `V1 & V2` option. This ensures that the users viewing the older version of your app also receive Push Notifications. -* Eventually, when all your users are on the latest version of your app, you can change this option to `V2`, thus turning off `V1` (Topic-based) Push Notifications completely. - -2. **Select the platforms that you want to support** - -* Select from Web, Android, Ionic (Deprecated), React Native, Flutter & iOS. - -3. **Notification payload settings** - -* You can control if the notification key should be in the Payload or not. Learn more about the FCM Messages [here](https://firebase.google.com/docs/cloud-messaging/). - -4. **Push payload message options** - - - - - -The maximum payload size supported by FCM and APNs for push notifications is approximately 4 KB. Due to the inclusion of CometChat's message object, the payload size may exceed this limit, potentially leading to non-delivery of push notifications for certain messages. The options provided allow you to remove the sender's metadata, receiver's metadata, message metadata and trim the content of the text field. - -* The message metadata includes the outputs of the Thumbnail Generation, Image Moderation, and Smart Replies extensions. You may want to retain this metadata if you need to customize the notification displayed to the end user based on these outputs. - -5. **Notification Triggers** - - - - - -* Select the triggers for sending Push Notifications. These triggers can be classified into 3 main categories: - - 1. Message Notifications - 2. Call Notifications - 3. Group Notifications - -* These are pretty self-explanatory and you can toggle them as per your requirement. - -## App Setup - -### Step 1: Initial plugin setup - -1. For React Native, there are numerous plugins available via NPM which can be used to set up push notifications for your apps. [react-native-firebase](https://www.npmjs.com/package/react-native-firebase) and [react-native-notifications](https://www.npmjs.com/package/react-native-notifications) are just the two out of many available. -2. To setup Push Notification, you need to follow the steps mentioned in the Plugin's Documentation. - -At this point, you will have: - -1. Two separate apps created on the Firebase console. (For Android and iOS). -2. Plugin setup completed as per the respective documentation and our reference. - -### Step 2: Register FCM Token - -1. This step assumes that you already have a React Native app setup with CometChat installed. Make sure that the CometChat object is initialized and user has been logged in. -2. On the success callback of user login, you can fetch the FCM Token and register it with the extension as shown below: - - - -```js -// Pseudo-code with async-await syntax - -const APP_ID = 'APP_ID'; -const REGION = 'REGION'; -const AUTH_KEY = 'AUTH_KEY'; - -const UID = 'UID'; -const APP_SETTINGS = new CometChat.AppSettingsBuilder() - .subscribePresenceForAllUsers() - .setRegion(REGION) - .build(); - -try { - // First initialize the app - await CometChat.init(APP_ID, APP_SETTINGS); - - // Login the user - await CometChat.login(UID, AUTH_KEY); - - // Get the FCM device token - // You should have imported the following in the file: - // import messaging from '@react-native-firebase/messaging'; - const FCM_TOKEN = await messaging().getToken(); - - // Register the token with Push Notifications (Legacy) - await CometChat.registerTokenForPushNotification(FCM_TOKEN); -} catch (error) { - // Handle errors gracefully -} -``` - - - - - -3. Registration also needs to happen in case of token refresh as shown below: - - - -```js -// Pseudo-code - -// You should have imported the following in the file: -// import messaging from '@react-native-firebase/messaging'; -try { - // Listen to whether the token changes - return messaging().onTokenRefresh(FCM_TOKEN => { - await CometChat.registerTokenForPushNotification(FCM_TOKEN); - }); - // ... -} catch(error) { - // Handle errors gracefully -} -``` - - - - - -For React Native Firebase reference, visit the link below: - -### Step 3: Receive Notifications - - - -```js -// Pseudo-code -import messaging from '@react-native-firebase/messaging'; -import { Alert } from 'react-native'; - -// Implementation can be done in a life-cycle method or hook -const unsubscribe = messaging().onMessage(async (remoteMessage) => { - Alert.alert('A new FCM message arrived!', JSON.stringify(remoteMessage)); -}); -``` - - - - - - - -We send Data Notifications and you need to handle displaying notifications at your end. For eg: Using Notifee - - - -### Step 4: Stop receiving Notifications - -1. Simply logout the CometChat user and you will stop receiving notifications. -2. As a good practice, you can also delete the FCM Token by calling `deleteToken` on the messaging object. - - - -```js -// Pseudo-code using async-await syntax - -logout = async () => { - // User logs out of the app - await CometChat.logout(); - - // You should have imported the following in the file: - // import messaging from '@react-native-firebase/messaging'; - // This is a good practice. - await messaging().deleteToken(); -}; -``` - - - - - -## Advanced - -### Handle Custom Messages - -To receive notification of `CustomMessage`, you need to set metadata while sending the `CustomMessage`. - - - -```js -var receiverID = 'UID'; -var customData = { - latitude: '50.6192171633316', - longitude: '-72.68182268750002', -}; - -var customType = 'location'; -var receiverType = CometChat.RECEIVER_TYPE.USER; -var metadata = { - pushNotification: 'Your Notification Message', -}; - -var customMessage = new CometChat.CustomMessage( - receiverID, - receiverType, - customType, - customData -); - -customMessage.setMetadata(metadata); - -CometChat.sendCustomMessage(customMessage).then( - (message) => { - // Message sent successfully. - console.log('custom message sent successfully', message); - }, - (error) => { - console.log('custom message sending failed with error', error); - // Handle exception. - } -); -``` - - - - - -### Converting push notification payload to message object - -CometChat SDK provides a method `CometChat.CometChatHelper.processMessage()` to convert the message JSON to the corresponding object of TextMessage, MediaMessage,CustomMessage, Action or Call. - - - -```js -var processedMessage = CometChat.CometChatHelper.processMessage(JSON_MESSAGE); -``` - - - - - - - -Type of Attachment can be of the following the type\ -1.`CometChatConstants.MESSAGE_TYPE_IMAGE`\ -2.`CometChatConstants.MESSAGE_TYPE_VIDEO`\ -3.`CometChatConstants.MESSAGE_TYPE_AUDIO`\ -4.`CometChatConstants.MESSAGE_TYPE_FILE` - - - -Push Notification: Payload Sample for Text Message and Attachment/Media Message - - - -```json -{ - "alert": "Nancy Grace: Text Message", - "sound": "default", - "title": "CometChat", - "message": { - "receiver": "cometchat-uid-4", - "data": { - "entities": { - "receiver": { - "entityType": "user", - "entity": { - "uid": "cometchat-uid-4", - "role": "default", - "name": "Susan Marie", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-4.webp", - "status": "offline" - } - }, - "sender": { - "entityType": "user", - "entity": { - "uid": "cometchat-uid-3", - "role": "default", - "name": "Nancy Grace", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp", - "status": "offline" - } - } - }, - "text": "Text Message" - }, - "sender": "cometchat-uid-3", - "receiverType": "user", - "id": "142", - "sentAt": 1555668711, - "category": "message", - "type": "text" - } -} -``` - - - - -```json -{ - "alert": "Nancy Grace: has sent an image", - "sound": "default", - "title": "CometChat", - "message": { - "receiver": "cometchat-uid-4", - "data": { - "attachments": [ - { - "extension": "png", - "size": 14327, - "name": "extension_leftpanel.png", - "mimeType": "image/png", - "url": "https://s3-eu-west-1.amazonaws.com/data.cometchat.com/1255466c41bd7f/media/1555671238_956450103_extension_leftpanel.png" - } - ], - "entities": { - "receiver": { - "entityType": "user", - "entity": { - "uid": "cometchat-uid-4", - "role": "default", - "name": "Susan Marie", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-4.webp", - "status": "offline" - } - }, - "sender": { - "entityType": "user", - "entity": { - "uid": "cometchat-uid-3", - "role": "default", - "name": "Nancy Grace", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp", - "status": "offline" - } - } - }, - "url": "https://s3-eu-west-1.amazonaws.com/data.cometchat.com/1255466c41bd7f/media/1555671238_956450103_extension_leftpanel.png" - }, - "sender": "cometchat-uid-3", - "receiverType": "user", - "id": "145", - "sentAt": 1555671238, - "category": "message", - "type": "image" - } -} -``` - - - - - -### Integrating ConnectionService and CallKit Using CometChat Push Notification - - - - - - - - - - - -* Currently we can only handle default calling notification -* Whenever the user answers the call we use RNCallKeep.backToForeground(); method to bring the app in to foreground but in some devices you might need to add few more permissions for this to work For example, In MIUI 11 you need to permission for Display pop-up windows while running in the background -* When the iOS app is in lock state we are not able to open the app so the call start on callkeep it self and you can hear the audio but if you want a video call then the user has to unlock the phone click on the app icon on call screen. -* If you want to use the callkit and connection service in foreground then you might consider turning the callNotifications settings in UI kit settings. For more information in UI kit settings check the [documentation](/ui-kit/react-native/getting-started#initialise-cometchatuikit). - - - -#### Setup push notification - -* Android - -Kindly follow the instruction for setting Firebase Cloud Messaging explained [here](#react-native) - -* iOS - -For iOS we use Apple Push Notification service or APNs to send push notification and VOIP notification. To configure this we need to follow some additional steps - -#### Step 1: Create a Certificate Signing Request - -To obtain a signing certificate required to sign apps for installation on iOS devices, you should first create a certificate signing request (CSR) file through Keychain Access on your Mac. - -1. Open the Keychain Access from the utility folder, go to Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority, and then click. - - - - - -2. The Certificate Information dialog box appears. Enter the email address that you use in your Apple Developer account, and enter a common name for your private key. Don't enter CA email address, choose Saved to disk, and then click the Continue button. \ \
\
-3. Specify the name of your CSR to save and choose the location to save the file on your local disk. Then your CSR file is created, which contains a public/private key pair. - -#### Step 2: Create an SSL certificate - -1. Sign in to your account at the [Apple Developer Member Center](https://developer.apple.com/membercenter). -2. Go to Certificates, Identifiers & Profiles. - - - - - -3. Create new Certificate by clicking on the + icon. - - - - - -4. Under Services, select - Apple Push Notification services SSL (Sandbox & Production) - - - - - -5. Select your App ID from the dropdown. - - - - - -6. Upload CSR file., upload the CSR file you created through the **Choose File** button. To complete the process, choose Continue. When the certificate is ready, choose Download to save it to your Mac. - - - - - - - - - -#### Step 3: Export and update .p8 certificate - -1. To generate a .p8 key file, go to [Apple Developer Account](https://developer.apple.com/account/), then select Certificates, IDs & Profiles. -2. Select Keys and click on the "+" button to add a new key. -3. In the new key page, type in your key name and check the Apple Push Notification service (APNs) box, then click "Continue" and click "Register". -4. Then proceed to download the key file by clicking Download. -5. Make note of the `Key ID`, `Team ID` and your `Bundle ID` for saving in the Extension's settings. - -**If you wish to use the .p12 certificate instead, do the following:** - -1. Type a name for the .p12 file and save it to your Mac. -2. Browse to the location where you saved your key, select it, and click Open. Add the key ID for the key (available in Certificates, Identifiers & Profiles in the Apple Developer Member Center) and export it. -3. DO NOT provide an export password when prompted. -4. The .p12 file will be required in the next step for uploading in the CometChat Dashboard. - -#### Extension settings - -#### Step 1: Enable the extension - -1. Login to [CometChat](https://app.cometchat.com/login) and select your app. -2. Go to the Extensions section and Enable the Push Notifications extension. -3. Open the settings for this extension and save the following. - - - - - -#### Step 2: Save your settings - -On the Settings page you need to enter the following: - - - - - -1. **Set extension version** - - The extension version has to be set to 'V2' or 'V1 & V2' in order to use APNs as the provider. - -2. **Select Platforms** - - You can select the platforms on which you wish to receive Push Notifications. - -3. **Firebase Cloud Messaging Settings** - - This includes the FCM Server key that you can fetch from the Firebase Dashboard. - -4. **APNs Settings** - - You can turn off the Production mode when you create a development build of your application. Upload the .p12 certificate exported in the previous step. - -5. **Push Notifications Title** - - This is usually the name of your app. - -6. **Notification Triggers** - - Select the triggers for sending Push Notifications. These triggers can be classified into 3 main categories: - - 1. Message Notifications - 2. Call Notifications - 3. Group Notifications - - These are pretty self-explanatory and you can toggle them as per your requirement. - -#### Installation - -We need to add two packages for this - -* React-native-CallKeep - -This package also require some additional installation steps. Follow [this](https://github.com/react-native-webrtc/react-native-callkeep) link to install react-native-callkeep - - - -```sh -npm install react-native-callkeep -//or -yarn add react-native-callkeep -``` - - - - - -* React Native VoIP Push Notification - -This package also require some additional installation steps. Follow [this](https://github.com/react-native-webrtc/react-native-voip-push-notification#readme) link to install react-native-voip-push-notification. - - - -```sh -npm install react-native-voip-push-notification -# --- if using pod -cd ios/ && pod install -``` - - - - - -#### App Setup - -First you need to Setup CallKeep at the start of the app in Index.js - - - -```js -const options = { - ios: { - appName: 'My app name', - }, - android: { - alertTitle: 'Permissions required', - alertDescription: 'This application needs to access your phone accounts', - cancelButton: 'Cancel', - okButton: 'ok', - imageName: 'phone_account_icon', - - foregroundService: { - channelId: 'com.company.my', - channelName: 'Foreground service for my app', - notificationTitle: 'My app is running on background', - notificationIcon: 'Path to the resource icon of the notification', - }, - }, -}; -RNCallKeep.setup(options); -RNCallKeep.setAvailable(true); -let callKeep = new CallKeepHelper(); -``` - - - - - -In order to handle connectionService and CallKit we have made a helper call. - - - -```js -import { CometChat } from '@cometchat/chat-sdk-react-native'; -import { Platform } from 'react-native'; -import uuid from 'react-native-uuid'; -import RNCallKeep, { AnswerCallPayload } from 'react-native-callkeep'; -import { navigate } from '../StackNavigator'; -import messaging from '@react-native-firebase/messaging'; -import VoipPushNotification from 'react-native-voip-push-notification'; -import invokeApp from 'react-native-invoke-app'; -import KeepAwake from 'react-native-keep-awake'; -import { AppState } from 'react-native'; -import _BackgroundTimer from 'react-native-background-timer'; -export default class CallKeepHelper { - constructor(msg) { - if (msg) { - CallKeepHelper.msg = msg; - } - this.setupEventListeners(); - this.registerToken(); - this.checkLoggedInUser(); - this.addLoginListener(); - CallKeepHelper.callEndedBySelf = false; - } - static FCMToken = null; - static voipToken = null; - static msg = null; - static callEndedBySelf = null; - static callerId = ''; - static callerId1 = ''; - static isLoggedIn = false; - checkLoggedInUser = async () => { - try { - let user = await CometChat.getLoggedinUser(); - if (user) { - if (user) { - CallKeepHelper.isLoggedIn = true; - } - } - } catch (error) { - console.log('error checkLoggedInUser', error); - } - }; - - addLoginListener = () => { - var listenerID = 'UNIQUE_LISTENER_ID'; - CometChat.addLoginListener( - listenerID, - new CometChat.LoginListener({ - loginSuccess: (e) => { - CallKeepHelper.isLoggedIn = true; - this.registerTokenToCometChat(); - }, - }) - ); - }; - - registerTokenToCometChat = async () => { - if (!CallKeepHelper.isLoggedIn) { - return false; - } - - try { - if (Platform.OS == 'android') { - if (CallKeepHelper.FCMToken) { - let response = await CometChat.registerTokenForPushNotification( - CallKeepHelper.FCMToken - ); - } - } else { - if (CallKeepHelper.FCMToken) { - let response = await CometChat.registerTokenForPushNotification( - CallKeepHelper.FCMToken, - { voip: false } - ); - } - if (CallKeepHelper.voipToken) { - let response = await CometChat.registerTokenForPushNotification( - CallKeepHelper.voipToken, - { voip: true } - ); - } - } - } catch (error) {} - }; - - registerToken = async () => { - try { - const authStatus = await messaging().requestPermission(); - const enabled = - authStatus === messaging.AuthorizationStatus.AUTHORIZED || - authStatus === messaging.AuthorizationStatus.PROVISIONAL; - if (enabled) { - if (Platform.OS == 'android') { - let FCM = await messaging().getToken(); - - CallKeepHelper.FCMToken = FCM; - this.registerTokenToCometChat(); - } else { - VoipPushNotification.registerVoipToken(); - let FCM = await messaging().getAPNSToken(); - CallKeepHelper.FCMToken = FCM; - this.registerTokenToCometChat(); - } - } - } catch (error) {} - }; - - endCall = ({ callUUID }) => { - if (CallKeepHelper.callerId) RNCallKeep.endCall(CallKeepHelper.callerId); - _BackgroundTimer.start(); - setTimeout(() => { - this.rejectCall(); - }, 3000); - }; - - rejectCall = async () => { - if ( - !CallKeepHelper.callEndedBySelf && - CallKeepHelper.msg && - CallKeepHelper.msg.call?.category !== 'custom' - ) { - var sessionID = CallKeepHelper.msg.sessionId; - var status = CometChat.CALL_STATUS.REJECTED; - let call = await CometChat.rejectCall(sessionID, status); - _BackgroundTimer.stop(); - } else { - _BackgroundTimer.stop(); - } - }; - - static displayCallAndroid = () => { - this.IsRinging = true; - CallKeepHelper.callerId = CallKeepHelper.msg.conversationId; - RNCallKeep.displayIncomingCall( - CallKeepHelper.msg.conversationId, - CallKeepHelper.msg.sender.name, - CallKeepHelper.msg.sender.name, - 'generic' - ); - setTimeout(() => { - if (this.IsRinging) { - this.IsRinging = false; - RNCallKeep.reportEndCallWithUUID(CallKeepHelper.callerId, 6); - } - }, 15000); - }; - - // NOTE: YOU MIGHT HAVE TO MAKE SOME CHANGES OVER HERE AS YOU AS YOUR IMPLEMENTATION OF REACT-NATIVE-UI-KIT MIGHT BE DIFFERENT. YOU JUST NEED TO CALL THE ACCEPT CALL METHOD AND NAVIGATE TO CALL SCREEN. - answerCall = ({ callUUID }) => { - this.IsRinging = false; - CallKeepHelper.callEndedBySelf = true; - setTimeout( - () => - navigate({ - index: 0, - routes: [ - { name: 'Conversation', params: { call: CallKeepHelper.msg } }, - ], - }), - 2000 - ); - // RNCallKeep.endAllCalls(); - RNCallKeep.backToForeground(); - if (Platform.OS == 'ios') { - if (AppState.currentState == 'active') { - RNCallKeep.endAllCalls(); - _BackgroundTimer.stop(); - } else { - this.addAppStateListener(); - } - } else { - RNCallKeep.endAllCalls(); - _BackgroundTimer.stop(); - } - }; - - addAppStateListener = () => { - AppState.addEventListener('change', (newState) => { - if (newState == 'active') { - RNCallKeep.endAllCalls(); - _BackgroundTimer.stop(); - } - }); - }; - - didDisplayIncomingCall = (DidDisplayIncomingCallArgs) => { - if (DidDisplayIncomingCallArgs.callUUID) { - if (Platform.OS == 'ios') { - CallKeepHelper.callerId = DidDisplayIncomingCallArgs.callUUID; - } - } - if (DidDisplayIncomingCallArgs.error) { - console.log({ - message: `Callkeep didDisplayIncomingCall error: ${DidDisplayIncomingCallArgs.error}`, - }); - } - - this.IsRinging = true; - - setTimeout(() => { - if (this.IsRinging) { - this.IsRinging = false; - // 6 = MissedCall - // https://github.com/react-native-webrtc/react-native-callkeep#constants - RNCallKeep.reportEndCallWithUUID( - DidDisplayIncomingCallArgs.callUUID, - 6 - ); - } - }, 15000); - }; - - setupEventListeners() { - if (Platform.OS == 'ios') { - CometChat.addCallListener( - 'this.callListenerId', - new CometChat.CallListener({ - onIncomingCallCancelled: (call) => { - RNCallKeep.endAllCalls(); - }, - }) - ); - - RNCallKeep.addEventListener('didLoadWithEvents', (event) => { - for (let i = 0; i < event.length; i++) { - if (event[i]?.name == 'RNCallKeepDidDisplayIncomingCall') { - CallKeepHelper.callerId = event[i]?.data?.callUUID; - } - } - }); - - VoipPushNotification.addEventListener('register', async (token) => { - CallKeepHelper.voipToken = token; - this.registerTokenToCometChat(); - }); - VoipPushNotification.addEventListener('notification', (notification) => { - let msg = CometChat.CometChatHelper.processMessage( - notification.message - ); - - CallKeepHelper.msg = msg; - }); - - VoipPushNotification.addEventListener( - 'didLoadWithEvents', - async (events) => { - if (!events || !Array.isArray(events) || events.length < 1) { - return; - } - for (let voipPushEvent of events) { - let { name, data } = voipPushEvent; - if ( - name === - VoipPushNotification.RNVoipPushRemoteNotificationsRegisteredEvent - ) { - CallKeepHelper.voipToken = data; - } else if ( - name === - VoipPushNotification.RNVoipPushRemoteNotificationReceivedEvent - ) { - let msg = CometChat.CometChatHelper.processMessage(data.message); - - CallKeepHelper.msg = msg; - } - } - } - ); - } - - RNCallKeep.addEventListener('endCall', this.endCall); - - RNCallKeep.addEventListener('answerCall', this.answerCall); - } - - removeEventListeners() { - RNCallKeep.removeEventListener('endCall'); - RNCallKeep.removeEventListener('didDisplayIncomingCall'); - RNCallKeep.removeEventListener('didLoadWithEvents'); - VoipPushNotification.removeEventListener('didLoadWithEvents'); - VoipPushNotification.removeEventListener('register'); - VoipPushNotification.removeEventListener('notification'); - } -} -``` - - - - - -#### Android - -In android we are going to use Firebase push notification to display Call notification So basically when ever we receive a push notification for call we display call notification. - -we need to add a listener to listen to notification when the app is background or foreground state. - - - -```js -messaging().setBackgroundMessageHandler(async (remoteMessage) => { - RNCallKeep.setup(options); - RNCallKeep.setAvailable(true); - - try { - //Converting the message payload into CometChat Message. - let msg = CometChat.CometChatHelper.processMessage( - JSON.parse(remoteMessage.data.message) - ); - if (msg.category == 'call') { - //need to check if the notification we received for Call initiated or ended - if (msg.action == 'initiated') { - CallKeepHelper.msg = msg; //setting the msg object in call keep helper class - CallKeepHelper.displayCallAndroid(); //this method is used to display incoming calls in android t - } else { - //if sender cancels the call before receiver accept or reject call then we also need to stop our notification - RNCallKeep.endCall(msg.conversationId); - } - } - } catch (e) { - console.log(e); - } -}); -``` - - - - - -#### iOS - -In iOS we use APNs push and voip push notification to display push notification and display call CallKit for calls. The notification are handled in Native iOS You need to add the code in AppDelegate.m file to display CallKit - - - -```objc -//add this import at the top or the file -#import "RNCallKeep.h" -#import "RNFBMessagingModule.h" -#import -#import "RNVoipPushNotificationManager.h" - - - - -_* <------ add this function *_ -- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(PKPushType)type { - // Register VoIP push token (a property of PKPushCredentials) with server - - [RNVoipPushNotificationManager didUpdatePushCredentials:credentials forType:(NSString *)type]; -} - -- (void)pushRegistry:(PKPushRegistry *)registry didInvalidatePushTokenForType:(PKPushType)type -{ - // --- The system calls this method when a previously provided push token is no longer valid for use. No action is necessary on your part to re-register the push type. Instead, use this method to notify your server not to send push notifications using the matching push token. -} - -// --- Handle incoming pushes -- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion { - - // --- NOTE: apple forced us to invoke callkit ASAP when we receive voip push - // --- see: react-native-callkeep - - // --- Retrieve information from your voip push payload - NSDictionary *content = [payload.dictionaryPayload valueForKey:@"aps"]; - NSDictionary *sender = [content valueForKey:@"alert"]; - NSString *uuid =[[[NSUUID UUID] UUIDString] lowercaseString]; - NSString *callerName=[sender valueForKey:@"title"]; - NSString *handle = [sender valueForKey:@"title"]; - - // --- Process the received push - [RNVoipPushNotificationManager didReceiveIncomingPushWithPayload:payload forType:(NSString *)type]; - - [RNCallKeep reportNewIncomingCall: uuid - handle: handle - handleType: @"generic" - hasVideo: NO - localizedCallerName: callerName - supportsHolding: YES - supportsDTMF: YES - supportsGrouping: YES - supportsUngrouping: YES - fromPushKit: YES - payload: nil - withCompletionHandler: completion]; - -} -``` - - - - - -## Capacitor, Cordova & Ionic (Deprecated) - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility. - - -Learn how to setup Push Notifications for Capacitor, Cordova and Ionic framework using Firebase Cloud Messaging or FCM. - - - Ionic/Cordova Push notifications sample app (Deprecated) - - View on Github - - -## Firebase Project Setup - -Visit [Firebase Console](https://console.firebase.google.com/) and login/signup using your Gmail ID. - -### Step 1: Create a new Firebase Project - -On your Firebase Console, create a new project. - - - - - -This is a simple 3 step process where: - -1. You give a name to your project -2. Add Google Analytics to your project (Optional) -3. Configure Google Analytics account (Optional) - -Click on Create and you are ready to go. - -### Step 2: Add Firebase to your App - -React native setup will require 2 files for Android and iOS: - -1. For Android, you need to download the `google-services.json` file. You can refer to the [Android Firebase Project Setup - Step 2](#firebase-project-setup-2) and resume here once done. -2. For iOS, you need to download the `GoogleService-Info.plist` file. You can refer to the [iOS Firebase Project Setup - Step 2](#firebase-project-setup-4) and resume here once done. -3. For web, you need to have the Firebase Config object. You can refer to the [Web Firebase Project Setup - Step 2](#firebase-project-setup) and resume here once done. - -### Step 3: Download the service account file - - - - - -## Extension settings - -### Step 1: Enable the extension - -1. Login to [CometChat](https://app.cometchat.com/login) and select your app. -2. Go to the Extensions section and Enable the Push Notifications extension. -3. Open the settings for this extension and save the following. - - - - - -### Step 2: Save your settings - -On the Settings page you need to enter the following: - -1. **Set extension version** - -* If you are setting it for the first time, Select `V2` to start using the token-based version of the Push Notification extension. -* If you already have an app using `V1` and want to migrate your app to use `V2`, then Select `V1 & V2` option. This ensures that the users viewing the older version of your app also receive Push Notifications. -* Eventually, when all your users are on the latest version of your app, you can change this option to `V2`, thus turning off `V1` (Topic-based) Push Notifications completely. - -2. **Select the platforms that you want to support** - -* Select from Web, Android, Ionic (Deprecated), React Native, Flutter & iOS. - -3. **Notification payload settings** - -* You can control if the notification key should be in the Payload or not. Learn more about the FCM Messages [here](https://firebase.google.com/docs/cloud-messaging/). - -4. **Push payload message options** - - - - - -The maximum payload size supported by FCM and APNs for push notifications is approximately 4 KB. Due to the inclusion of CometChat's message object, the payload size may exceed this limit, potentially leading to non-delivery of push notifications for certain messages. The options provided allow you to remove the sender's metadata, receiver's metadata, message metadata and trim the content of the text field. - -* The message metadata includes the outputs of the Thumbnail Generation, Image Moderation, and Smart Replies extensions. You may want to retain this metadata if you need to customize the notification displayed to the end user based on these outputs. - -5. **Notification Triggers** - - - - - -* Select the triggers for sending Push Notifications. These triggers can be classified into 3 main categories: - - 1. Message Notifications - 2. Call Notifications - 3. Group Notifications - -* These are pretty self-explanatory and you can toggle them as per your requirement. - -## App Setup - -### Step 1: Initial plugin setup - -1. For Cordova & Ionic, there are numerous plugins available via NPM which can be used to set up push notifications for your apps like [FCM Plugin](https://ionicframework.com/docs/v3/native/fcm/) and [Push Plugin](https://ionicframework.com/docs/native/push). -2. To setup Push Notification, you need to follow the steps mentioned in the Plugin's Documentation. - -At this point, you will have: - -1. Separate apps created on the Firebase console. (For Web, Android and iOS). -2. Plugin setup completed as per the respective documentation. - -### Step 2: Register FCM Token - -1. This step assumes that you already have a React Native app setup with CometChat installed. Make sure that the CometChat object is initialized and user has been logged in. -2. On the success callback of user login, you can fetch the FCM Token and register it with the extension as shown below: - - - -```js -// Pseudo-code with async-await syntax -// Using the FCM Plugin - -const APP_ID = 'APP_ID'; -const REGION = 'REGION'; -const AUTH_KEY = 'AUTH_KEY'; - -const UID = 'UID'; -const APP_SETTINGS = new CometChat.AppSettingsBuilder() - .subscribePresenceForAllUsers() - .setRegion(REGION) - .build(); - -try { - // First initialize the app - await CometChat.init(APP_ID, APP_SETTINGS); - - // Login the user - await CometChat.login(UID, AUTH_KEY); - - // Login is successful so next step - // Get the FCM device token - // You should have imported the following in the file: - // import { FCM } from '@ionic-native_fcm'; - const FCM_TOKEN = await fcm.getToken(); - - // Register the token for Push Notifications (legacy) - await CometChat.registerTokenForPushNotification(FCM_TOKEN); -} catch (error) { - // Handle errors gracefully -} -``` - - - - - -3. Registration also needs to happen in case of token refresh as shown below: - - - -```js -// Pseudo-code - -// You should have imported the following in the file: -// import { FCM } from '@ionic-native_fcm'; -try { - // Listen to whether the token changes - return fcm.onTokenRefresh(FCM_TOKEN => { - await CometChat.registerTokenForPushNotification(FCM_TOKEN); - }); - // ... -} catch(error) { - // Handle errors gracefully -} -``` - - - - - -For more details, visit documentation. - -### Step 3: Receive Notifications - - - -```js -// Pseudo-code -import messaging from '@react-native-firebase_messaging'; -import { Alert } from 'react-native'; - -// Implementation can be done in a life-cycle method or hook -const unsubscribe = messaging().onMessage(async (remoteMessage) => { - Alert.alert('A new FCM message arrived!', JSON.stringify(remoteMessage)); -}); -``` - - - - - -### Step 4: Stop receiving Notifications - -1. On CometChat.logout will stop receiving notifications. -2. As a good practice, you can also delete the FCM Token by calling `deleteToken` on the fcm object. - - - -```js -// Pseudo-code using async-await syntax - -logout = async () => { - // User logs out of the app - await CometChat.logout(); -}; -``` - - - - - -## Advanced - -### Handle Custom Messages - -To receive notification of `CustomMessage`, you need to set metadata while sending the `CustomMessage`. - - - -```js -var receiverID = 'UID'; -var customData = { - latitude: '50.6192171633316', - longitude: '-72.68182268750002', -}; - -var customType = 'location'; -var receiverType = CometChat.RECEIVER_TYPE.USER; -var metadata = { - pushNotification: 'Your Notification Message', -}; - -var customMessage = new CometChat.CustomMessage( - receiverID, - receiverType, - customType, - customData -); - -customMessage.setMetadata(metadata); - -CometChat.sendCustomMessage(customMessage).then( - (message) => { - // Message sent successfully. - console.log('custom message sent successfully', message); - }, - (error) => { - console.log('custom message sending failed with error', error); - // Handle exception. - } -); -``` - - - - - -### Converting push notification payload to message object - -CometChat SDK provides a method `CometChat.CometChatHelper.processMessage()` to convert the message JSON to the corresponding object of TextMessage, MediaMessage,CustomMessage, Action or Call. - - - -```js -var processedMessage = CometChat.CometChatHelper.processMessage(JSON_MESSAGE); -``` - - - - - - - -Type of Attachment can be of the following the type:\ -`CometChatConstants.MESSAGE_TYPE_IMAGE`\ -`CometChatConstants.MESSAGE_TYPE_VIDEO`\ -`CometChatConstants.MESSAGE_TYPE_AUDIO`\ -`CometChatConstants.MESSAGE_TYPE_FILE` - - - -Push Notification: Payload Sample for Text Message and Attachment/Media Message - - - -```json -{ - "alert": "Nancy Grace: Text Message", - "sound": "default", - "title": "CometChat", - "message": { - "receiver": "cometchat-uid-4", - "data": { - "entities": { - "receiver": { - "entityType": "user", - "entity": { - "uid": "cometchat-uid-4", - "role": "default", - "name": "Susan Marie", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-4.webp", - "status": "offline" - } - }, - "sender": { - "entityType": "user", - "entity": { - "uid": "cometchat-uid-3", - "role": "default", - "name": "Nancy Grace", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp", - "status": "offline" - } - } - }, - "text": "Text Message" - }, - "sender": "cometchat-uid-3", - "receiverType": "user", - "id": "142", - "sentAt": 1555668711, - "category": "message", - "type": "text" - } -} -``` - - - - -```json -{ - "alert": "Nancy Grace: has sent an image", - "sound": "default", - "title": "CometChat", - "message": { - "receiver": "cometchat-uid-4", - "data": { - "attachments": [ - { - "extension": "png", - "size": 14327, - "name": "extension_leftpanel.png", - "mimeType": "image/png", - "url": "https://s3-eu-west-1.amazonaws.com/data.cometchat.com/1255466c41bd7f/media/1555671238_956450103_extension_leftpanel.png" - } - ], - "entities": { - "receiver": { - "entityType": "user", - "entity": { - "uid": "cometchat-uid-4", - "role": "default", - "name": "Susan Marie", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-4.webp", - "status": "offline" - } - }, - "sender": { - "entityType": "user", - "entity": { - "uid": "cometchat-uid-3", - "role": "default", - "name": "Nancy Grace", - "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp", - "status": "offline" - } - } - }, - "url": "https://s3-eu-west-1.amazonaws.com/data.cometchat.com/1255466c41bd7f/media/1555671238_956450103_extension_leftpanel.png" - }, - "sender": "cometchat-uid-3", - "receiverType": "user", - "id": "145", - "sentAt": 1555671238, - "category": "message", - "type": "image" - } -} -``` - - - - - -## Mute Functionality - -Learn how to enable your users to mute notifications for certain conversations - -You can silence one-on-one and/or group conversations for a specific amount of time using the Mute functionality. Aside from that, you can include a Push Notifications section in your apps' settings. Your users can use this feature to turn off Push Notifications for certain chats or to opt-out of receiving Push Notifications altogether. - -## Mute or Unmute Chats - -Chat comprises anything related to messages like: - -1. New Message (Text, media, or Custom messages like Polls) -2. Edited Message -3. Deleted Message -4. Response in threads - -### Mute Chats - -You can specify the UIDs and/or GUIDs to be muted. You can mute chats for these conversations for a specific amount of time. - -| Parameters | Value | Description | -| ---------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| uids | Array of UIDs | This parameter allows you to mute one-on-one chat for the mentioned UIDs. | -| guids | Array of GUIDs | This parameter allows you to mute group chat for the mentioned GUIDs. | -| timeInMS | String consisting of UNIX timestamp | This parameter allows you to mute chats for a specific amount of time for the required UIDs or GUIDs After the mentioned duration, the Push Notifications are received. Eg: "1628425767881" | - -This functionality uses the `callExtension()` method provided by CometChat SDK. - - - -```js -CometChat.callExtension('push-notification', 'POST', 'v2/mute-chat', { - "uids": ["cometchat-uid-1"], - "guids": ["cometchat-guid-1"], - "timeInMS": "1628610749081" -}).then(response => { - // Success -}) -.catch(error => { - // Error occured -}); -``` - - - - -```java -import org.json.simple.JSONObject; - -JSONObject body=new JSONObject(); -JSONArray uids = new JSONArray(); -JSONArray guids = new JSONArray(); - -uids.add("cometchat-uid-1"); -guids.add("cometchat-guid-1"); - -body.put("uids", uids); -body.put("guids", guids); -body.put("timeInMS", "1628425767881"); - -CometChat.callExtension("push-notification", "POST", "/v2/mute-chat", body, - new CometChat.CallbackListener < JSONObject > () { - @Override - public void onSuccess(JSONObject jsonObject) { - //On Success - } - @Override - public void onError(CometChatException e) { - //On Failure - } -}); -``` - - - - -```swift -CometChat.callExtension(slug: "push-notification", type: .post, endPoint: "v2/mute-chat", body: ["uids":["cometchat-uid-1"], "guids":["cometchat-guid-1"], "timeInMS":"1628610749081"] as [String : Any], onSuccess: { (response) in - // Success - }) { (error) in - // Error occured - } -``` - - - - - -### Unmute Chats - -Used to unmute the chats for certain conversations before the mentioned time during muting. - -| Parameters | Value | Description | -| ---------- | -------------- | --------------------------------------------------------------------------- | -| uids | Array of UIDs | This parameter allows you to unmute one-on-one chat for the mentioned UIDs. | -| guids | Array of GUIDs | This parameter allows you to unmute group chat for the mentioned GUIDs. | - -This functionality uses the `callExtension()` method provided by CometChat SDK. - - - -```js -CometChat.callExtension('push-notification', 'POST', 'v2/unmute-chat', { - "uids": ["cometchat-uid-1"], - "guids": ["cometchat-guid-1"] -}).then(response => { - // Success -}) -.catch(error => { - // Error occured -}); -``` - - - - -```java -import org.json.simple.JSONObject; - -JSONObject body=new JSONObject(); -JSONArray uids = new JSONArray(); -JSONArray guids = new JSONArray(); - -uids.add("cometchat-uid-1"); -guids.add("cometchat-guid-1"); - -body.put("uids", uids); -body.put("guids", guids); - -CometChat.callExtension("push-notification", "POST", "/v2/unmute-chat", body, - new CometChat.CallbackListener < JSONObject > () { - @Override - public void onSuccess(JSONObject jsonObject) { - //On Success - } - @Override - public void onError(CometChatException e) { - //On Failure - } -}); -``` - - - - -```swift -CometChat.callExtension(slug: "push-notification", type: .post, endPoint: "v2/unmute-chat", body: ["uids":["cometchat-uid-1"], "guids":["cometchat-guid-1"]] as [String : Any], onSuccess: { (response) in - // Success - }) { (error) in - // Error occured - } -``` - - - - - -## Mute or Unmute Calls - -You can mute the notifications for one-on-one or group calls. This works for Default calling (video or audio calls) offered by CometChat. - -### Mute Calls - -You can specify the UIDs and/or GUIDs to be muted. You can mute calls for these conversations for the said amount of time. - -| Parameters | Value | Description | -| ---------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| uids | Array of UIDs | This parameter allows you to mute one-on-one calls for the mentioned UIDs. | -| guids | Array of GUIDs | This parameter allows you to mute group calls for the mentioned GUIDs. | -| timeinMS | String consisting of UNIX timestamp | This parameter allows you to mute calls for a specific amount of time for the required UIDs or GUIDs After the mentioned duration, the Push Notifications are received. Eg: "1628425767881" | - -This functionality uses the `callExtension()` method provided by CometChat SDK. - - - -```js -CometChat.callExtension('push-notification', 'POST', 'v2/mute-calls', { - "uids": ["cometchat-uid-1"], - "guids": ["cometchat-guid-1"], - "timeInMS": "1628610749081" -}).then(response => { - // Success -}) -.catch(error => { - // Error occured -}); -``` - - - - -```java -import org.json.simple.JSONObject; - -JSONObject body=new JSONObject(); -JSONArray uids = new JSONArray(); -JSONArray guids = new JSONArray(); - -uids.add("cometchat-uid-1"); -guids.add("cometchat-guid-1"); - -body.put("uids", uids); -body.put("guids", guids); -body.put("timeInMS", "1628425767881"); - -CometChat.callExtension("push-notification", "POST", "/v2/mute-calls", body, - new CometChat.CallbackListener < JSONObject > () { - @Override - public void onSuccess(JSONObject jsonObject) { - //On Success - } - @Override - public void onError(CometChatException e) { - //On Failure - } -}); -``` - - - - -```swift -CometChat.callExtension(slug: "push-notification", type: .post, endPoint: "v2/mute-calls", body: ["uids":["cometchat-uid-1"], "guids":["cometchat-guid-1"], "timeInMS":"1628610749081"] as [String : Any], onSuccess: { (response) in - // Success - }) { (error) in - // Error occured - } -``` - - - - - -### Unmute Calls - -Used to unmute calls for certain conversations before the mentioned time during muting. - -| Parameters | Value | Description | -| ---------- | -------------- | ---------------------------------------------------------------------------- | -| uids | Array of UIDs | This parameter allows you to unmute one-on-one calls for the mentioned UIDs. | -| guids | Array of GUIDs | This parameter allows you to unmute group calls for the mentioned GUIDs. | - -Used to unmute the calls for certain conversations before the mentioned time during muting. - - - -```js -CometChat.callExtension('push-notification', 'POST', 'v2/unmute-calls', { - "uids": ["cometchat-uid-1"], - "guids": ["cometchat-guid-1"] -}).then(response => { - // Success -}) -.catch(error => { - // Error occured -}); -``` - - - - -```java -import org.json.simple.JSONObject; - -JSONObject body=new JSONObject(); -JSONArray uids = new JSONArray(); -JSONArray guids = new JSONArray(); - -uids.add("cometchat-uid-1"); -guids.add("cometchat-guid-1"); - -body.put("uids", uids); -body.put("guids", guids); - -CometChat.callExtension("push-notification", "POST", "/v2/unmute-calls", body, - new CometChat.CallbackListener < JSONObject > () { - @Override - public void onSuccess(JSONObject jsonObject) { - //On Success - } - @Override - public void onError(CometChatException e) { - //On Failure - } -}); -``` - - - - -```swift -CometChat.callExtension(slug: "push-notification", type: .post, endPoint: "v2/unmute-calls", body: ["uids":["cometchat-uid-1"], "guids":["cometchat-guid-1"]] as [String : Any], onSuccess: { (response) in - // Success - }) { (error) in - // Error occured - } -``` - - - - - -## User Settings - -Apart from the feature to mute/unmute a set of UIDs or GUIDs using the above APIs, apps can have push notifications according to the user settings. - -The following user settings can be set: - -| Settings | Description | -| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Do Not Disturb | When turned ON, the "Do Not Disturb" parameter disables the Push Notifications entirely for the user. The user stops receiving push notifications until this setting is explicitly turned OFF. This overrides all the following settings. | -| Allow only Mentions | Until turned OFF, the notifications are only sent for text messages for the mentioned receiver of the message | -| Mute all one-on-one chat | This parameter can be used to mute chat notifications for all one-on-one conversations. The user will not receive push notifications until this is turned OFF. | -| Mute all group chat | This parameter can be used to mute chat notifications for all group conversations. The user will not receive push notifications until the parameter is turned OFF. | -| Mute all one-on-one calls | This preference can be used to mute call notifications for all one-on-one conversations. The user will not receive push notifications until the parameter is turned OFF. | -| Mute all group calls | This parameter can be used to mute call notifications for all group conversations. The user will not receive push notifications until this is turned OFF. | - -### Save User Settings - -The User settings object needs to be submitted as follows. All the fields are mandatory: - - - -```json -{ - "user-settings": { - "dnd": "", - "chat": { - "allow_only_mentions": "", - "mute_group_actions": "", - "mute_all_guids": "", - "mute_all_uids": "" - }, - "call": { - "mute_all_guids": "", - "mute_all_uids": "" - } - } -} -``` - - - - - -This functionality uses the `callExtension()` method provided by CometChat SDK. - - - -```js -const userSettings = { - "user-settings": { - "dnd": false, - "chat": { - "allow_only_mentions": true, - "mute_group_actions": false, - "mute_all_guids": false, - "mute_all_uids": false - }, - "call": { - "mute_all_guids": false, - "mute_all_uids":false - } - } -}; -CometChat.callExtension('push-notification', 'POST', 'v2/user-settings', userSettings).then(response => { - // Success -}) -.catch(error => { - // Error occured -}); -``` - - - - -```java -JSONObject chatSettings = new JSONObject(); -chatSettings.put('allow_only_mentions', false); -chatSettings.put('mute_group_actions', false); -chatSettings.put('mute_all_guids', false); -chatSettings.put('mute_all_uids', false); - -JSONObject callSettings = new JSONObject(); -callSettings.put('mute_all_guids', false); -callSettings.put('mute_all_uids', false); - -JSONObject userSettings = new JSONObject(); -userSettings.put('dnd', true); -userSettings.put('chat', chatSettings); -userSettings.put('call', callSettings); - -CometChat.callExtension("push-notification", "GET", "/v2/user-settings", null, - new CometChat.CallbackListener < JSONObject > () { - @Override - public void onSuccess(JSONObject jsonObject) { - //On Success - } - @Override - public void onError(CometChatException e) { - //On Failure - } -}); -``` - - - - -```swift -CometChat.callExtension(slug: "push-notification", type: .get, endPoint: "v2/user-settings", body: { - "user-settings": { - "dnd": true_false, - "chat": { - "allow_only_mentions": true_false, - "mute_group_actions": true_false, - "mute_all_guids": true_false, - "mute_all_uids": true_false - }, - "call": { - "mute_all_guids": true_false, - "mute_all_uids":true_false - } - } -}, onSuccess: { (response) in - // Success - }) { (error) in - // Error occured - } -``` - - - - - -### Fetch User Settings - -Fetches all the user settings that are saved by the user. This also returns the list of muted UIDs and GUIDs along with the said time for muting. - -This functionality uses the `callExtension()` method provided by CometChat SDK. - - - -```js -CometChat.callExtension('push-notification', 'GET', 'v2/user-settings', null).then(response => { - // Success -}) -.catch(error => { - // Error occured -}); -``` - - - - -```java -CometChat.callExtension("push-notification", "GET", "/v2/user-settings", null, - new CometChat.CallbackListener < JSONObject > () { - @Override - public void onSuccess(JSONObject jsonObject) { - //On Success - } - @Override - public void onError(CometChatException e) { - //On Failure - } -}); -``` - - - - -```swift -CometChat.callExtension(slug: "push-notification", type: .get, endPoint: "v2/user-settings", body: nil, onSuccess: { (response) in - // Success - }) { (error) in - // Error occured - } -``` - - - - - -## Token Management - -## Register tokens - -Token registration can now be done using the callExtension method provided by the CometChat SDK. The token can be FCM token or APNs token and VoIP token. - -This can be achieved using the code snippet below: - -**For FCM token:** - - - -```js -// For FCM Token -CometChat.callExtension('push-notification', 'POST', 'v2/tokens', { - fcmToken: "fcm_token" -}) -.then(response => { - // Success response -}) -.catch(error => { - // Error occured -}) -``` - - - - -```java -import org.json.simple.JSONObject; - -JSONObject body=new JSONObject(); - -body.put("fcmToken", "fcm_token"); - -CometChat.callExtension("push-notification", "POST", "/v2/tokens", body, - new CometChat.CallbackListener < JSONObject > () { - @Override - public void onSuccess(JSONObject jsonObject) { - //On Success - } - @Override - public void onError(CometChatException e) { - //On Failure - } -}); -``` - - - - -```swift -CometChat.callExtension(slug: "push-notification", type: .post, endPoint: "v2/tokens", body: ["fcmToken": "fcm_token"] as [String : Any], onSuccess: { (response) in - // success response - }) { (error) in - // Error occured - } -``` - - - - - -**For APNs tokens:** - - - -```js -// For APNs tokens -CometChat.callExtension('push-notification', 'POST', 'v2/tokens', { - apnsToken: "apns_token", - voipToken: "voip_token" -}) -.then(response => { - // Success response -}) -.catch(error => { - // Error occured -}) -``` - - - - -```java -import org.json.simple.JSONObject; - -JSONObject body=new JSONObject(); - -body.put("apnsToken", "apns_token"); -body.put("voipToken", "voip_token"); - -CometChat.callExtension("push-notification", "POST", "/v2/tokens", body, - new CometChat.CallbackListener < JSONObject > () { - @Override - public void onSuccess(JSONObject jsonObject) { - //On Success - } - @Override - public void onError(CometChatException e) { - //On Failure - } -}); -``` - - - - -```swift -CometChat.callExtension(slug: "push-notification", type: .post, endPoint: "v2/tokens", body: ["apnsToken": "apns_token", "voipToken": "voip_token"] as [String : Any], onSuccess: { (response) in - // Success response - }) { (error) in - // Error occured - } -``` - - - - - -## Get tokens - -This provides a list of all the Push Notifications tokens that have been registered for the current user. The tokens are segregated based on the platform. - - - -```js -CometChat.callExtension('push-notification', 'GET', 'v2/tokens', null) -.then(response => { - // Success response -}) -.catch(error => { - // Error occured -}) -``` - - - - -```java -CometChat.callExtension("push-notification", "GET", "/v2/tokens", null, - new CometChat.CallbackListener < JSONObject > () { - @Override - public void onSuccess(JSONObject jsonObject) { - //On Success - } - @Override - public void onError(CometChatException e) { - //On Failure - } -}); -``` - - - - -```swift -CometChat.callExtension(slug: "push-notification", type: .get, endPoint: "v2/tokens", body: nil, onSuccess: { (response) in - // Success response - }) { (error) in - // Error occured - } -``` - - - - - -The response will be as follows: - - - -```json -{ - "ios": [ - "cLztQGbuPA91bG3rkRcgcQYvlKuTlWGmHC1RnCwrTrbyT0VF" - ], - "web": [ - "cLztQGbuPA91bG3rkRcgcQYvlKuTlWGmHC1RnxyzTrbyT0VF" - ], - "android": [ - "dLztQGbuPA91bG3rkRckcQYvlKuTlWGmHC1RnxyzTrbyT0VF" - ] -} -``` - - - - - -## Delete tokens - -Token deletion is handled implicitly by the `CometChat.logout()` method. That is, once the user is logged out of the current CometChat session, his/her registered Push Notification token automatically gets deleted. - -The same can be achieved explicitly by making a call to the extension using `callExtension` method as shown below. However, the token that is deleted belongs to the current session of the end-user by passing `all=false` as a parameter. - - - -```js -CometChat.callExtension('push-notification', 'DELETE', 'v2/tokens', { - all: false, // true when ALL the registered tokens for the logged-in user need to be deleted -}) - .then((response) => { - // Success response - }) - .catch((error) => { - // Error occured - }); -``` - - - - -```java -import org.json.simple.JSONObject; - -JSONObject body=new JSONObject(); - -body.put("all", false); // true when ALL the registered tokens for the logged-in user need to be deleted - -CometChat.callExtension("push-notification", "DELETE", "/v2/tokens", body, - new CometChat.CallbackListener < JSONObject > () { - @Override - public void onSuccess(JSONObject jsonObject) { - //On Success - } - @Override - public void onError(CometChatException e) { - //On Failure - } -}); -``` - - - - -```swift -CometChat.callExtension(slug: "push-notification", type: .delete, endPoint: "v2/tokens", body: ["all": false] as [String : Any], onSuccess: { (response) in // true when ALL the registered tokens for the logged-in user need to be deleted - // Details about the created poll - }) { (error) in - // Error occured - } -``` - - - - - - - -All the tokens for the current user will be deleted if you pass `all=true`. This needs to be used with care as the other logins of the current user will stop receiving Push Notifications. - - diff --git a/notifications/sms-notifications-extension-legacy.mdx b/notifications/sms-notifications-extension-legacy.mdx deleted file mode 100644 index f02bdf341..000000000 --- a/notifications/sms-notifications-extension-legacy.mdx +++ /dev/null @@ -1,83 +0,0 @@ ---- -title: "SMS Notifications (Legacy)" ---- - - - -**Legacy Notice**: This extension is already included as part of the core messaging experience and is scheduled for deprecation in the near future. - -Please note: Legacy extensions are no longer actively maintained and will not receive feature updates or enhancements. - - - -## About the extension - -The SMS Notification extension helps you to notify offline users via SMS, when they have unread text messages. - -After you've configured the extension, your users will receive SMS for unread messages in one-on-one conversations. - - -Required: Read Receipts - -Make sure to implement read receipts so that your users receive SMS notifications for only unread messages. - - - -## Create a new App on Twilio - -We have partnered with Twilio for sending SMS Notifications so need to set up an account on [Twilio](https://www.twilio.com) before you start using the extension. - -1. Once you log in to Twilio, create a new app. -2. Note down the Account SID, Auth Token. -3. Click on "Get a Trial number" to get the Sender number. (Use the paid number if you already have one) -4. Note down the above details as these will be required in the next steps. - -## Extension settings - -1. Login to [CometChat](https://app.cometchat.com/login) and select your app. -2. Go to the Extensions section and enable the SMS Notification extension. -3. Open the Settings for this extension and save the below details. - - - - - -## Configure your backend to store phone number - -You can use our [Update user](https://api-explorer.cometchat.com/reference/update-user) API to set private metadata for a user. We recommend adding this code when you call our [Create user](https://api-explorer.cometchat.com/reference/creates-user) API. - -Alternatively, just for the sake of testing purposes, you can add this from the CometChat Dashboard as well. - -1. Login to the [CometChat](https://app.cometchat.com/login). -2. Select your app and go to the "Users" section. -3. Click on the Edit option available under the three dots for the user under consideration. -4. Click on the Edit button on the Details section. -5. Paste the below JSON in the Metadata input box and hit Save. - -The Metadata is a JSON that should have the `@private` key present and should have the value `contactNumber` specified for the user. The format for the private metadata must be as follows: - - - -```json -{ - "@private": - { - "contactNumber":"+12345678910" - } -} -``` - - - - - - -Country code is required - -It is important to store the contact number with the correct country code to receive SMS notifications. - - - -## Receive SMS Notification - -Send a message to an offline user and watch them receive an SMS! diff --git a/sdk/ionic-legacy/2.0/advanced-connection-listener.mdx b/sdk/ionic-legacy/2.0/advanced-connection-listener.mdx deleted file mode 100644 index 1fcc666b2..000000000 --- a/sdk/ionic-legacy/2.0/advanced-connection-listener.mdx +++ /dev/null @@ -1,71 +0,0 @@ ---- -title: "Connection Status" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -CometChat SDK provides you with a mechanism to get real-time status of the connection to CometChat web-socket servers. - -Connection Status provides you with the below 3 methods to get the status of the connection to CometChat web-socket servers: - -| Delegate Method | Information | -| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | -| connecting | This method is triggered when CometChat SDK is trying to establish a connection to the web-socket server. | -| connected | This method is called when CometChat SDK has successfully established a connection and now is connected. | -| disconnected | This method is called when the CometChat SDK gets disconnected due to any issue while maintaining the connection like network fluctuations, etc. | - -Once the connection is broken, the disconnected callback is triggered, the SDK automatically tries to establish the connection again, thus going into the connecting state and triggering the `connecting` method. Once the attempt to connect is successful, the `connected` method is triggered thus letting the developer know that the connection is established and is active. - -To receive real-time connection status, you need to register `ConnectionListener` wherever you wish to receive the real-time status. You can use the `addConnectionListener()` method to do so. - - - -```js -var listenerID = "UNIQUE_LISTENER_ID"; -CometChat.addConnectionListener( - listenerID, - new CometChat.ConnectionListener({ - onConnected: () => { - console.log("ConnectionListener => On Connected"); - }, - inConnecting: () => { - console.log("ConnectionListener => In connecting"); - }, - onDisconnected: () => { - console.log("ConnectionListener => On Disconnected"); - }, - }) -); -``` - - - - - - - -We recommend you to add the Connection Listener in your method on app startup, preferably in the index.js file. Once you have successfully initialized CometChat. - - - -You can also get the current connection status by using `getConnectionStatus` property provided by CometChat SDK - - - -```js -var connectionStatus = CometChat.getConnectionStatus(); -``` - - - - - -The `CometChat.getConnectionStatus` method will return either of the below 3 values: - -1. connecting -2. connected -3. disconnected diff --git a/sdk/ionic-legacy/2.0/advanced.mdx b/sdk/ionic-legacy/2.0/advanced.mdx deleted file mode 100644 index 07e7ab601..000000000 --- a/sdk/ionic-legacy/2.0/advanced.mdx +++ /dev/null @@ -1,12 +0,0 @@ ---- -title: "Advanced" -sidebarTitle: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -This section helps you to know about the Connection Listeners. diff --git a/sdk/ionic-legacy/2.0/authentication-login-listeners.mdx b/sdk/ionic-legacy/2.0/authentication-login-listeners.mdx deleted file mode 100644 index 379d4f65a..000000000 --- a/sdk/ionic-legacy/2.0/authentication-login-listeners.mdx +++ /dev/null @@ -1,62 +0,0 @@ ---- -title: "Login Listeners" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -The CometChat SDK provides you with real-time updates for the `login` and `logout` events. This can be achieved using the `LoginListener` class provided. LoginListener consists of 4 events that can be triggered. These are as follows: - -Login Listener provides you with the below 4 methods: - -| Callback Method | Information | -| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| loginSuccess(event) | Informs you that the login was successful and provides you with a user object containing the data for the user that logged in. | -| loginFailure(event) | Informs you about the failure while logging in the user and provides you with the reason for the failure wrapped in an object of the `CometChatException` class. | -| logoutSuccess() | Informs you about the user being logged out successfully. | -| logoutFailure(event) | Informs you about the failure while logging out the user. The reason for the failure can be obtained from the object of the `CometChatException` class. | - -To add the `LoginListener`, you need to use the `addLoginListener()` method provided by the SDK which takes a unique identifier for the listener and of the the `LoginListener` class itself. - - - -``` -var listenerID = "UNIQUE_LISTENER_ID"; -CometChat.addLoginListener( - listenerID, - new CometChat.LoginListener({ - loginSuccess: (e) => { - console.log("LoginListener :: loginSuccess", e); - }, - loginFailure: (e) => { - console.log("LoginListener :: loginFailure", e); - }, - logoutSuccess: () => { - console.log("LoginListener :: logoutSuccess"); - }, - logoutFailure: (e) => { - console.log("LoginListener :: logoutFailure", e); - }, - }) -); -``` - - - - - -In order to stop receiving events related to login and logout you need to use the `removeLoginListener()` method provided by the SDK and pass the ID of the listener that needs to be removed. - - - -``` -var listenerID = "UNIQUE_LISTENER_ID"; -CometChat.removeLoginListener(listenerID); -``` - - - - diff --git a/sdk/ionic-legacy/2.0/authentication.mdx b/sdk/ionic-legacy/2.0/authentication.mdx deleted file mode 100644 index 45ce91c68..000000000 --- a/sdk/ionic-legacy/2.0/authentication.mdx +++ /dev/null @@ -1,143 +0,0 @@ ---- -title: "Authentication" -sidebarTitle: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Create User - -Before you login the user, you must add the user to CometChat. - -1. **For proof of concept/MVPs**: Create the user using the [CometChat Dashboard](https://app.cometchat.com). -2. **For production apps**: Use the CometChat [Create User API](https://api-explorer.cometchat.com/reference/creates-user) to create the user when your user signs up in your app. - - -**Sample Users** - -We have setup 5 users for testing having UIDs: `cometchat-uid-1`, `cometchat-uid-2`, `cometchat-uid-3`, `cometchat-uid-4` and `cometchat-uid-5`. - - - -Once initialization is successful, you will need to log the user into CometChat using the `login()` method. - -We recommend you call the CometChat `login` method once your user logs into your app. The `login()` method needs to be called only once. - - - -The CometChat SDK maintains the session of the logged in user within the SDK. Thus you do not need to call the login method for every session. You can use the CometChat.getLoggedinUser() method to check if there is any existing session in the SDK. This method should return the details of the logged-in user. If this method returns null, it implies there is no session present within the SDK and you need to log the user into ComeChat. - - - -## Login using Auth Key - -This simple authentication procedure is useful when you are in development or if you do not require additional security. - - - -```js -var UID = "UID"; -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 }); - } - ); - } - }, - (error) => { - console.log("Something went wrong", error); - } -); -``` - - - - - -| Parameters | Description | -| ---------- | ------------------------------------------------ | -| UID | The UID of the user that you would like to login | -| authKey | CometChat Auth Key | - -After the user logs in, their information is returned in the `User` object on `Promise` resolved. - - - -Be sure to use the **Auth Key** and not the **Rest API Key**. This ensures that even if a malicious user reverse engineers your client code, they will only be able to log in to CometChat and not call any other APIs. - - - -## Login using Auth Token - -This advanced authentication procedure does not use the Auth Key directly in your client code and thus ensuring that your Auth Key is not leaked even if the client code is reverse engineered. - -1. [Create a User](https://api-explorer.cometchat.com/reference/creates-user) via the CometChat API when the user signs up in your app. -2. [Create an Auth Token](https://api-explorer.cometchat.com/reference/create-authtoken) via the CometChat API for the new user and save the token in your database. -3. Load the Auth Token in your client and pass it to the `login()` method. - - - -```js -var authToken = "AUTH_TOKEN"; - -CometChat.getLoggedinUser().then( - (user) => { - if (!user) { - CometChat.login(authToken).then( - (user) => { - console.log("Login Successful:", { user }); - }, - (error) => { - console.log("Login failed with exception:", { error }); - } - ); - } - }, - (error) => { - console.log("Something went wrong", error); - } -); -``` - - - - - -| Parameter | Description | -| --------- | ---------------------------------------------- | -| authToken | Auth Token of the user you would like to login | - -After the user logs in, their information is returned in the `User` object on the `Promise` resolved. - -## Logout - -You can use the `logout()` method to log out the user from CometChat. We suggest you call this method once your user has been successfully logged out from your app. - - - -```js -CometChat.logout().then( - () => { - console.log("Logout completed successfully"); - }, - (error) => { - console.log("Logout failed with exception:", { error }); - } -); -``` - - - - diff --git a/sdk/ionic-legacy/2.0/bots.mdx b/sdk/ionic-legacy/2.0/bots.mdx deleted file mode 100644 index e224024de..000000000 --- a/sdk/ionic-legacy/2.0/bots.mdx +++ /dev/null @@ -1,25 +0,0 @@ ---- -title: "Bots" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -Bots are special users, in CometChat, who can send and receive messages autonomously. Users can text bots privately in one-on-one conversations as well as in groups. When a bot receives a message, either in a one-on-one conversation or in a group conversation, CometChat forwards the message to a Callback URL that you specify. Once you receive this message, you can send a reply using our API. - -## The flow - -### Create a user - -CometChat requires you to connect every bot to a user. This has one major advantage- at any time, you can log in as that bot user and send out personalized replies. So before you create a bot, you must first create a new user. - -### Create the bot - -Once you've created a user, you can create a new bot. The actual implementation of the bot is entirely up to you. You simply need to specify a `Callback URL` and CometChat will automatically start forwarding all messages that fit the criteria to the URL. - -### Reply to a message - -When you receive a message from CometChat, you can process it and provide a response using our [Send Bot Message](https://www.cometchat.com/docs/rest-api/messages/send-bot-message) Rest API. diff --git a/sdk/ionic-legacy/2.0/calling-default-calling.mdx b/sdk/ionic-legacy/2.0/calling-default-calling.mdx deleted file mode 100644 index 60bad1fce..000000000 --- a/sdk/ionic-legacy/2.0/calling-default-calling.mdx +++ /dev/null @@ -1,336 +0,0 @@ ---- -title: "Default Calling" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -This section will provide information on how a complete calling workflow can be set up using CometChat. We've built the complete workflow to help your users make calls, receive calls as well as accept/reject calls. - -Let us assume Alex to be the call initiator and Bob is the receiver. - -1. Alex initiates the call to Bob using the **initiateCall()** method. - -2. Bob now has two choices: - - 1. Accept the call from Alex using the **acceptCall()** method. - 2. Reject the call from Alex using the **rejectCall()** method passing the status as `rejected`. - -3. In the meantime, Alex has the option to cancel the call he initiated to Bob using the **rejectCall()** method passing the status as `cancelled`. - -4. If Bob accepts the call from Alex, both Alex and Bob need to call the **startCall()** method. Alex in the **onOutgoingCallAccepted()** method of the `CallListener` and Bob in the success obtained from the `**acceptCall()**` method and both will be connected to each other. - -## Initiate Call - -The `initiateCall()` method sends a call request to a user or a group. - - - -``` -var receiverID = "UID"; -var callType = CometChat.CALL_TYPE.VIDEO; -var receiverType = CometChat.RECEIVER_TYPE.USER; - -var call = new CometChat.Call(receiverID, callType, receiverType); - -CometChat.initiateCall(call).then( - (outGoingCall) => { - console.log("Call initiated successfully:", outGoingCall); - // perform action on success. Like show your calling screen. - }, - (error) => { - console.log("Call initialization failed with exception:", error); - } -); -``` - - - - -``` -var receiverID = "GUID"; -var callType = CometChat.CALL_TYPE.VIDEO; -var receiverType = CometChat.RECEIVER_TYPE.GROUP; - -var call = new CometChat.Call(receiverID, callType, receiverType); - -CometChat.initiateCall(call).then( - (outGoingCall) => { - console.log("Call initiated successfully:", outGoingCall); - // perform action on success. Like show your calling screen. - }, - (error) => { - console.log("Call initialization failed with exception:", error); - } -); -``` - - - - - -This method takes an object of the `Call` class. The constructor for `Call` class takes the following parameters: - -| Parameter | Description | -| -------------- | -------------------------------------------------------------------------------------------- | -| `receiverID` | The `UID` or `GUID` of the recipient | -| `receiverType` | The type of the receiver. 1.`CometChat.RECEIVER_TYPE.USER` 2.`CometChat.RECEIVER_TYPE.GROUP` | -| `callType` | The type of call. 1.`CometChat.CALL_TYPE.AUDIO` 2.`CometChat.CALL_TYPE.VIDEO` | - -On successful initialization, a `Call` object is returned with the details of the call including a unique session ID for the call. - -## Receive Calls - -Wherever you wish to receive the call events in, you need to register the `CallListener` listener using the `addCallListener()` method. - - - -```js -var listnerID = "UNIQUE_LISTENER_ID"; -CometChat.addCallListener( - listnerID, - new CometChat.CallListener({ - onIncomingCallReceived: (call) => { - console.log("Incoming call:", call); - // Handle incoming call - }, - onOutgoingCallAccepted: (call) => { - console.log("Outgoing call accepted:", call); - // Outgoing Call Accepted - }, - onOutgoingCallRejected: (call) => { - console.log("Outgoing call rejected:", call); - // Outgoing Call Rejected - }, - onIncomingCallCancelled: (call) => { - console.log("Incoming call calcelled:", call); - }, - }) -); -``` - - - - - -| Parametrer | Description | -| ------------ | ---------------------------------------------------------------------------------------------- | -| `listenerID` | An ID that uniquely identifies that listener. We recommend using the activity or fragment name | - -We recommend you remove the listener once the activity or fragment is not in use. - - - -```js -var listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.removeCallListener(listenerID); -``` - - - - - -As mentioned in the [Overview](/sdk/ionic-legacy/2.0/calling-default-calling) section, Once the call is initiated, there are three options that can be possible: - -1. The receiver of the call accepts the call. -2. The receiver of the call rejects the call. -3. The initiator of the call cancels the call. - -Please find below how these three scenarios can be implemented: - -### Accept the Incoming Call - -Once you have received an incoming call from a user or in any group, to accept the call using the `acceptCall()` method. - - - -```js -var sessionID = "SESSION_ID"; - -CometChat.acceptCall(sessionID).then( - (call) => { - console.log("Call accepted successfully:", call); - // start the call using the startCall() method - }, - (error) => { - console.log("Call acceptance failed with error", error); - // handle exception - } -); -``` - - - - - -| Parameter | Description | -| ----------- | ---------------------------------------------------- | -| `sessionID` | The unique session ID available in the `Call` object | - -### Reject the Incoming Call - -To reject the incoming call once it is received using the `rejectCall()` method. - - - -```js -var sessionID = "SESSION_ID"; -var status = CometChat.CALL_STATUS.REJECTED; - -CometChat.rejectCall(sessionID, status).then( - (call) => { - console.log("Call rejected successfully", call); - }, - (error) => { - console.log("Call rejection failed with error:", error); - } -); -``` - - - - - -| Parameter | Description | -| ----------- | ---------------------------------------------------- | -| `sessionID` | The unique session ID available in the `Call` object | -| `status` | Reason for rejection of the call | - -Here the status needs to be set as `CometChat.CALL_STATUS.REJECTED` as the call is being rejected by the receiver of the call. - -### Cancel the Outgoing Call - -In the case where the initiator wishes to cancel the call, use the same above `rejectCall()` method and just pass the status to the `rejectCall()` method as `CometChat.CALL_STATUS.CANCELLED` - -## Start a Call - -Once the call request is sent and the receiver has accepted the call, both the initiator and the receiver need to call the `startCall()` method. - -You need to call this method for two scenarios: - -1. After you accept an incoming call i.e. in the `onSuccess()` callback of the `acceptCall()` method. -2. After the recipient accepts an outgoing call i.e. in the `onOutgoingCallAccepted()` callback of the `CallListener` listener. - - - -```js -/** - * You can get the call Object from the success of acceptCall() or from the onOutgoingCallAccepted() callback of the CallListener. - */ -var sessionId = call.sessionId; -var callType = call.type; -let callListener = new CometChat.OngoingCallListener({ - onUserJoined: (user) => { - console.log("User joined call:", user); - }, - onUserLeft: (user) => { - console.log("User left call:", user); - }, - onUserListUpdated: (userList) => { - console.log("user list:", userList); - }, - onCallEnded: (call) => { - console.log("Call ended listener", call); - }, - onAudioModesUpdated: (audioModes) => { - console.log("audio modes:", audioModes); - }, -}); -var callSettings = new CometChat.CallSettingsBuilder() - .setSessionID(sessionId) - .enableDefaultLayout(true) - .setIsAudioOnlyCall(callType == "audio" ? true : false) - .setCallEventListener(callListener) - .build(); -CometChat.startCall(callSettings); -``` - - - - - -| Parameter | Description | -| -------------- | ----------------------------- | -| `callSettings` | Object of CallSettings class. | - -The `OngoingCallListener` listener provides you with the below callback methods: - -| Callback Method | Description | -| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | -| `onUserJoined(User user)` | This method is called when any other user joins the call. The user details can be obtained from the `User` object provided. | -| `onUserLeft(User user)` | This method is called when a user leaves the call. The details of the user can be obtained from the provided `User` object. | -| `onCallEnded()` | This method is called when the call is successfully ended. The call details can be obtained from the `Call` object provided. | -| `onUserListUpdated(userList)` | This method is triggered every time a participant joins or leaves the call providing the list of users active in the call. | -| `onAudioModesUpdated(audioModes)` | This callback is triggered if any new audio output source is available or becomes unavailable. | - -## Settings - -The `CallSettings` class is the most important class when it comes to the implementation of the Calling feature. This is the class that allows you to customize the overall calling experience. The properties for the call/conference can be set using the `CallSettingsBuilder` class. This will eventually give you an object of the `CallSettings` class which you can pass to the `startCall()` method to start the call. - -The **mandatory** parameters that are required to be present for any call/conference to work are: - -1. sessionId - The unique session Id for the call/conference session. - -The options available for customization of calls are: - -| Setting | Description | -| --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `enableDefaultLayout(defaultLayout: boolean)` | If set to `true` enables the default layout for handling the call operations.
If set to `false` it hides the button layout and just displays the Call View.
**Default value = true** | -| `showEndCallButton(showEndCallButton: boolean)` | If set to `true` it displays the EndCallButton in Button Layout.
if set to `false` it hides the EndCallButton in Button Layout.
**Default value = true** | -| `showPauseVideoButton(showPauseVideoButton: boolean)` | If set to `true` it displays the PauseVideoButton in Button Layout.
if set to `false` it hides the PauseVideoButton in Button Layout.
**Default value = true** | -| `showMuteAudioButton(showMuteAudioButton: boolean)` | If set to `true` it displays the MuteAudioButton in Button Layout.
if set to `false` it hides the MuteAudioButton in Button Layout.
**Default value = true** | -| `showSwitchCameraButton(showSwitchCameraButton: boolean)` | If set to `true` it displays the SwitchCameraButton in Button Layout.
if set to `false` it hides the SwitchCameraButton in Button Layout.
**Default value = true** | -| `showAudioModeButton(showAudioModeButton: boolean)` | If set to `true` it displays the AudioModeButton in Button Layout.
if set to `false` it hides the AudioModeButton in Button Layout.
**Default value = true** | -| `setIsAudioOnlyCall(audioOnly: boolean)` | If set to true, the call will be strictly an audio call.
If ser to false, the call will be an audio-video call.
**Default value = false** | -| `setMode(mode: string)` | CometChat provides 3 options for the calling UI.
1. CometChat.CALL\_MODE.DEFAULT
2. CometChat.CALL\_MODE.SPOTLIGHT
3. CometChat.CALL\_MODE.SINGLE
**Default value = CometChat.CALL\_MODE.DEFAULT** | -| `startWithAudioMuted(audioMuted: boolean)` | This ensures the call is started with the audio muted if set to true.
**Default value = false** | -| `startWithVideoMuted(videoMuted: boolean)` | This ensures the call is started with the video paused if set to true.
**Default value = false** | -| `setDefaultAudioMode(audioMode: string)` | This method can be used if you wish to start the call with a specific audio mode. The available options are
1. CometChat.AUDIO\_MODE.SPEAKER = "SPEAKER"
2. CometChat.AUDIO\_MODE.EARPIECE = "EARPIECE"
3. CometChat.AUDIO\_MODE.BLUETOOTH = "BLUETOOTH"
4. CometChat.AUDIO\_MODE.HEADPHONES = "HEADPHONES" | - -## Active Call - -CometChat provides a method to get the details of the call that is currently active. The `CometChat.getActiveCall()` will return an object of the `Call` class containing the details of the ongoing call. If there is no ongoing call this method will return null. - - - -```js -let activeCall = CometChat.getActiveCall(); -``` - - - - - - - -The `getActiveCall()` method will only return the details of the active call for the ongoing session in which the call has been started. If the app is restarted, the data will be lost. - - - -## Call Participant Count - -In order to get the number of participants in any call, you can use the `getCallParticipantCount()` method. This method takes the session id for the call and returns the number of participants that are active in the call. - - - -```js -let sessionId = "CALL_SESSION_ID"; -let callType = "DEFAULT"; - -CometChat.getCallParticipantCount(sessionId, callType).then( - (count) => { - console.log("Participants count =", count); - }, - (error) => { - console.log("Some error occurred =", error); - } -); -``` - - - - diff --git a/sdk/ionic-legacy/2.0/calling-direct-calling.mdx b/sdk/ionic-legacy/2.0/calling-direct-calling.mdx deleted file mode 100644 index c4468c1bd..000000000 --- a/sdk/ionic-legacy/2.0/calling-direct-calling.mdx +++ /dev/null @@ -1,106 +0,0 @@ ---- -title: "Direct Calling" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -This section will guide you to start the call/conference directly with the session id of your choice. The session id is the most important parameter as all the users joining the same session id will be connected to the same call/conference. - -## Implementation - -The most important class that will be used in the implementation is the `CallSettings` class. This class allows you to set the various parameters for the call/conference. In order to set the various parameters of the `CallSettings` class, you need to use the `CallSettingsBuilder` class. Below are the various options available with the `CallSettings` class. - -The mandatory parameter is the sessionId for the call/conference. You can use the setSessionId() method of the `CallSettingsBuilder` to set the session Id of the call. - -A basic example of how to start a direct call: - - - -```js -let sessionID = "SESSION_ID"; -let audioOnly = false; -let deafaultLayout = true; -let callListener = new CometChat.OngoingCallListener({ - onUserListUpdated: userList => { - console.log("user list:", userList); - }, - onCallEnded: call => { - console.log("Call ended:", call); - }, - onAudioModesUpdated: (audioModes) => { - console.log("audio modes:", audioModes); - } -}); - -let callSettings = new CometChat.CallSettingsBuilder() - .enableDefaultLayout(deafaultLayout) - .setSessionID(sessionID) - .setIsAudioOnlyCall(audioOnly) - .setCallEventListener(callListener) - .build(); - -CometChat.startCall(callSettings); -``` - - - - - -The `setAudioOnlyCall()` method allows you to set if the call is supposed to be an audio call or an audio-video call. If set to true, the call will be an audio-only call else when set to false the call will be an audio-video call. The default is false, so if not set, the call will be an audio-video call. - -## Settings - -The `CallSettings` class is the most important class when it comes to the implementation of the Calling feature. This is the class that allows you to customize the overall calling experience. The properties for the call/conference can be set using the `CallSettingsBuilder` class. This will eventually give you and object of the `CallSettings` class which you can pass to the `startCall()` method to start the call. - -The **mandatory** parameters that are required to be present for any call/conference to work are: - -1. sessionId - The unique session Id for the call/conference session. - -The options available for customization of calls are: - -| Setting | Description | -| --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `enableDefaultLayout(defaultLayout: boolean)` | If set to `true` enables the default layout for handling the call operations.
If set to `false` it hides the button layout and just displays the Call View.
**Default value = true** | -| `showEndCallButton(showEndCallButton: boolean)` | If set to `true` it displays the EndCallButton in Button Layout.
if set to `false` it hides the EndCallButton in Button Layout.
**Default value = true** | -| `showPauseVideoButton(showPauseVideoButton: boolean)` | If set to `true` it displays the PauseVideoButton in Button Layout.
if set to `false` it hides the PauseVideoButton in Button Layout.
**Default value = true** | -| `showMuteAudioButton(showMuteAudioButton: boolean)` | If set to `true` it displays the MuteAudioButton in Button Layout.
if set to `false` it hides the MuteAudioButton in Button Layout.
**Default value = true** | -| `showSwitchCameraButton(showSwitchCameraButton: boolean)` | If set to `true` it displays the SwitchCameraButton in Button Layout.
if set to `false` it hides the SwitchCameraButton in Button Layout.
**Default value = true** | -| `showAudioModeButton(showAudioModeButton: boolean)` | If set to `true` it displays the AudioModeButton in Button Layout.
if set to `false` it hides the AudioModeButton in Button Layout.
**Default value = true** | -| `setIsAudioOnlyCall(audioOnly: boolean)` | If set to true, the call will be strictly an audio call.
If ser to false, the call will be an audio-video call.
**Default value = false** | -| `setMode(mode: string)` | CometChat provides 3 options for the calling UI.
1. CometChat.CALL\_MODE.DEFAULT
2. CometChat.CALL\_MODE.SPOTLIGHT
3. CometChat.CALL\_MODE.SINGLE
**Default value = CometChat.CALL\_MODE.DEFAULT** | -| `startWithAudioMuted(audioMuted: boolean)` | This ensures the call is started with the audio muted if set to true.
**Default value = false** | -| `startWithVideoMuted(videoMuted: boolean)` | This ensures the call is started with the video paused if set to true.
**Default value = false** | -| `setDefaultAudioMode(audioMode: string)` | This method can be used if you wish to start the call with a specific audio mode. The available options are
1. CometChat.AUDIO\_MODE.SPEAKER = "SPEAKER"
2. CometChat.AUDIO\_MODE.EARPIECE = "EARPIECE"
3. CometChat.AUDIO\_MODE.BLUETOOTH = "BLUETOOTH"
4. CometChat.AUDIO\_MODE.HEADPHONES = "HEADPHONES" | - - - -The `CometChat.getActiveCall()` method in case of Direct Calling will return null and all the details related to the call session will have to be saved and maintained at your end. - - - -## Call Participant Count - -In order to get the number of participants in any call, you can use the `getCallParticipantCount()` method. This method takes the session id for the call and returns the number or participants that are active in the call. - - - -```js -let sessionId = "CALL_SESSION_ID"; -let callType = "DIRECT"; - -CometChat.getCallParticipantCount(sessionId, callType).then( - count => { - console.log("Participants count =", count); - }, error => { - console.log("Some error occurred =", error); - } -); -``` - - - - diff --git a/sdk/ionic-legacy/2.0/calling.mdx b/sdk/ionic-legacy/2.0/calling.mdx deleted file mode 100644 index eb795df46..000000000 --- a/sdk/ionic-legacy/2.0/calling.mdx +++ /dev/null @@ -1,44 +0,0 @@ ---- -title: "Calling" -sidebarTitle: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -Calling is a core feature of CometChat. Calling allows users to connect over voice/video calls. - -## Prerequisites - -1. CometChat Core SDK installed. -2. Performed the steps mentioned in the [Setup](/sdk/ionic-legacy/2.0/setup#calling-component-configuration) guide - - - -v2.4+ onwards, Voice & Video Calling functionality has been moved to a separate library. Please add the following dependency to your package.json file in case you plan on using the Voice and Video Calling feature. - -dependencies: \{ "@cometchat-pro/ionic-calls": "2.1.2" } - -And run npm install to install the package. - - - -**CometChat allows two mechanisms for calling:** - -1. **Direct Calling** -2. **Default Calling** - - - - - -## Direct Calling - -Direct Calling allows you to start the call/conference sessions directly with the session Id of your choice. All the users joining the same session Id are connected to the same call/conference. For more information on Direct Calling, please visit the [Direct Calling docs](/sdk/ionic-legacy/2.0/calling-direct-calling). - -## Default Calling - -The second approach that CometChat allows is to implement the entire calling flow where one user initiates a call/conference and other user/users who want to be a part of the call accept/reject the call. All the users that accept the call are connected to the same session. For more information on Default Calling, please visit the [Default Calling docs](/sdk/ionic-legacy/2.0/calling-default-calling). diff --git a/sdk/ionic-legacy/2.0/groups-add-members-to-group.mdx b/sdk/ionic-legacy/2.0/groups-add-members-to-group.mdx deleted file mode 100644 index f5aab4a85..000000000 --- a/sdk/ionic-legacy/2.0/groups-add-members-to-group.mdx +++ /dev/null @@ -1,93 +0,0 @@ ---- -title: "Add Members To A Group" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Add Members to Group - -You can add members to the group using the `addMembersToGroup()` method. This method takes the below parameters: - -1. `GUID` - GUID of the group the members are to be added to. -2. `Array members` - This is a list of `GroupMember` objects. In order to add members, you need to create an object of the `GroupMember` class. The UID and the scope of the `GroupMember` are mandatory. -3. `Array bannedMembers` - This is the list of `UID's` that need to be banned from the Group. This can be set to `null` if there are no members to be banned. - - - -``` -let GUID = "GUID"; -let UID = "UID"; -let membersList = [ - new CometChat.GroupMember(UID, CometChat.GROUP_MEMBER_SCOPE.PARTICIPANT), -]; - -CometChat.addMembersToGroup(GUID, membersList, []).then( - (response) => { - console.log("response", response); - }, - (error) => { - console.log("Something went wrong", error); - } -); -``` - - - - - -It will return a Array which will contain the `UID` of the users and the value will either be `success` or an error message describing why the operation to add the user to the group. - -## Real-Time Group Member Added Events - -*In other words, as a member of a group, how do I know when someone is added to the group when my app is running?* - - - -When a group member is added by another member, this event is triggered. When a user joins a group on their own, the joined event is triggered. - - - -To receive real-time events whenever a new member is added to a group, you need to implement the `onMemberAddedToGroup()` methods of the `GroupListener` class. - -`onMemberAddedToGroup()` - This method is triggered when any user is added to the group so that the logged in user is informed of the other members added to the group. - - - -``` -var listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.addGroupListener( - listenerID, - new CometChat.GroupListener({ - onMemberAddedToGroup: (message, userAdded, userAddedBy, userAddedIn) => { - console.log("User joined", { - message, - userAdded, - userAddedBy, - userAddedIn, - }); - }, - }) -); -``` - - - - - -## Member Added to Group event in Message History - -*In other words, as a member of a group, how do I know when someone is added to the group when my app is not running?* - -When you retrieve the list of previous messages if a member has been added to any group that the logged-in user is a member of, the list of messages will contain an `Action` message. An `Action` message is a sub-class of `BaseMessage` class. - -For the group member added event, in the `Action` object received, the following fields can help you get the relevant information- - -1. `action` - `added` -2. `actionOn` - User object containing the details of the user who was added to the group -3. `actionBy` - User object containing the details of the user who added the member to the group -4. `actionFor` - Group object containing the details of the group to which the member was added diff --git a/sdk/ionic-legacy/2.0/groups-change-member-scope.mdx b/sdk/ionic-legacy/2.0/groups-change-member-scope.mdx deleted file mode 100644 index 9e2cd541e..000000000 --- a/sdk/ionic-legacy/2.0/groups-change-member-scope.mdx +++ /dev/null @@ -1,96 +0,0 @@ ---- -title: "Change Member Scope" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Change Scope of a Group Member - -In order to change the scope of a group member, you can use the `changeGroupMemberScope()`. - - - -```js -var GUID = "GUID"; -var UID = "UID"; -var scope = CometChat.GROUP_MEMBER_SCOPE.ADMIN; - -CometChat.updateGroupMemberScope(GUID, UID, scope).then( - (response) => { - console.log("Group member scopped changed", response); - }, - (error) => { - console.log("Group member scopped changed failed", error); - } -); -``` - - - - - -This method takes the below parameters: - -| Parameter | Description | -| --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `UID` | The UID of the member whose scope you would like to change | -| `GUID` | The GUID of the group for which the member's scope needs to be changed | -| `scope` | The updated scope of the member. This can be either of the 3 values: 1.`CometChatConstants.SCOPE_ADMIN` (admin) 2.`CometChatConstants.SCOPE_MODERATOR` (moderator) 3.`CometChatConstants.SCOPE_PARTICIPANT` (participant) | - -The default scope of any member is `participant`. Only the **Admin** of the group can change the scope of any participant in the group. - -## Real-Time Group Member Scope Changed Events - -*In other words, as a member of a group, how do I know when someone's scope is changed when my app is running?* - -In order to receive real-time events for the change member scope event, you will need to override the `onGroupMemberScopeChanged()` method of the `GroupListener` class - - - -``` -let listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.addGroupListener( - listenerID, - new CometChat.GroupListener({ - onGroupMemberScopeChanged: ( - message, - changedUser, - newScope, - oldScope, - changedGroup - ) => { - console.log("User joined", { - message, - changedUser, - newScope, - oldScope, - changedGroup, - }); - }, - }) -); -``` - - - - - -## Missed Group Member Scope Changed Events - -*In other words, as a member of a group, how do I know when someone's scope is changed when my app is not running?* - -When you retrieve the list of previous messages if a member's scope has been changed for any group that the logged-in user is a member of, the list of messages will contain an `Action` message. An `Action` message is a sub-class of `BaseMessage` class. - -For the group member scope changed event, in the `Action` object received, the following fields can help you get the relevant information- - -1. `action` - `scopeChanged` -2. `actionOn` - User object containing the details of the user whose scope has been changed -3. `actionBy` - User object containing the details of the user who changed the scope of the member -4. `actionFor` - Group object containing the details of the group in which the member scope was changed -5. `oldScope` - The original scope of the member -6. `newScope` - The updated scope of the member diff --git a/sdk/ionic-legacy/2.0/groups-create-group.mdx b/sdk/ionic-legacy/2.0/groups-create-group.mdx deleted file mode 100644 index b1f38bd33..000000000 --- a/sdk/ionic-legacy/2.0/groups-create-group.mdx +++ /dev/null @@ -1,86 +0,0 @@ ---- -title: "Create A Group" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Create a Group - -*In other words, as a logged-in user, how do I create a public, private or password-protected group?* - -You can create a group using `createGroup()` method. This method takes a `Group` object as input. - -To create an object of `Group` class, you can use either of the below two constructors: - -1. `new Group(String GUID, String name, String groupType, String password)` -2. `new Group(String GUID, String name, String groupType, String password, String icon, String description)` - -The `groupType` needs to be either of the below 3 values: - -1.`CometChatConstants.GROUP_TYPE_PUBLIC` (public) - -2.`CometChatConstants.GROUP_TYPE_PASSWORD` (password) - -3.`CometChatConstants.GROUP_TYPE_PRIVATE` (private) - - - -``` -var GUID = "GUID"; -var groupName = "Hello Group!"; -var groupType = CometChat.GROUP_TYPE.PUBLIC; -var password = ""; - -var group = new CometChat.Group(GUID, groupName, groupType, password); - -CometChat.createGroup(group).then( - (group) => { - console.log("Group created successfully:", group); - }, - (error) => { - console.log("Group creation failed with exception:", error); - } -); -``` - - - - - -The createGroup() method takes the following parameters: - -| Parameter | Description | -| --------- | ---------------------------- | -| `group` | An instance of `Group` class | - -After successful creation of the group, you will receive an instance of `Group` class which contains all the information about the particular group. - - - -GUID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed. - - - -## Group Class - -| Field | Editable | Information | -| ------------ | --------------------------------------------------------------- | ------------------------------------------------------------------------- | -| guid | Needs to be specified at group creation. Cannot be edited later | A unique identifier for a group | -| name | Yes | Name of the group | -| type | No | Type of the group: Can be 1. Public 2. Password 3. Private | -| password | No | Password for the group in case the group is of type password. | -| icon | Yes | An URL to group icon | -| description | Yes | Description about the group | -| owner | Yes | UID of the owner of the group. | -| metadata | Yes | Additional data for the group as JSON | -| createdAt | No | The unix timestamp of the time the group was created | -| updatedAt | No | The unix timestamp of the time the group was last updated | -| hasJoined | No | A boolean to determine if the logged in user is a member of the group. | -| joinedAt | No | The unix timestamp of the time the logged in user joined the group. | -| scope | Yes | Scope of the logged in user. Can be: 1. Admin 2. Moderator 3. Participant | -| membersCount | No | The number of members in the groups | -| tags | Yes | A list of tags to identify specific groups. | diff --git a/sdk/ionic-legacy/2.0/groups-delete-group.mdx b/sdk/ionic-legacy/2.0/groups-delete-group.mdx deleted file mode 100644 index aa08b2155..000000000 --- a/sdk/ionic-legacy/2.0/groups-delete-group.mdx +++ /dev/null @@ -1,37 +0,0 @@ ---- -title: "Delete A Group" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Delete a Group - -To delete a group you need to use the `deleteGroup()` method. The user must be an `Admin` of the group they are trying to delete. - - - -```js -var GUID = "GUID"; - -CometChat.deleteGroup(GUID).then( -response => { - console.log("Groups deleted successfully:", response); -}, error => { - console.log("Group delete failed with exception:", error); -} -); -``` - - - - - -The `deleteGroup()` method takes the following parameters: - -| Parameter | Description | -| --------- | ---------------------------------------------- | -| `GUID` | The GUID of the group you would like to delete | diff --git a/sdk/ionic-legacy/2.0/groups-join-group.mdx b/sdk/ionic-legacy/2.0/groups-join-group.mdx deleted file mode 100644 index b09b7c7a0..000000000 --- a/sdk/ionic-legacy/2.0/groups-join-group.mdx +++ /dev/null @@ -1,83 +0,0 @@ ---- -title: "Join A Group" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Join a Group - -In order to start participating in group conversations, you will have to join a group. You can do so using the `joinGroup()` method. - - - -``` -var GUID = "GUID"; -var password = ""; -var groupType = CometChat.GROUP_TYPE.PUBLIC; - -CometChat.joinGroup(GUID, groupType, password).then( - (group) => { - console.log("Group joined successfully:", group); - }, - (error) => { - console.log("Group joining failed with exception:", error); - } -); -``` - - - - - -The `joinGroup()` method takes the below parameters - -| Parameter | Description | -| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `GUID` | The GUID of the group you would like to join. | -| `groupType` | Type of the group. CometChat provides 3 types of groups viz. a. CometChatConstants.GROUP\_TYPE\_PUBLIC (public) b. CometChatConstants.GROUP\_TYPE\_\_\_PASSWORD (password) c. CometChatConstants.GROUP\_TYPE\_PRIVATE (private) | -| `password` | Password is mandatory in case of a password protected group. | - -Once you have joined a group successfully, you can send and receive messages in that group. - -CometChat keeps a track of the groups joined and you do not need to join the group every time you want to communicate in the group. - -You can identify if a group is joined using the `hasJoined` parameter in the `Group` object. - -## Real-time Group Member Joined Events - -*In other words, as a member of a group, how do I know if someone joins the group when my app is running?* - -If a user joins any group, the members of the group receive a real-time event in the `onGroupMemberJoined()` method of the `GroupListener` class. - - - -``` -CometChat.addGroupListener( - "UNIQUE_LISTNER_ID", - new CometChat.GroupListener({ - onGroupMemberJoined: (message, joinedUser, joinedGroup) => { - console.log("User joined", { message, joinedUser, joinedGroup }); - }, - }) -); -``` - - - - - -## Missed Group Member Joined Events - -*In other words, as a member of a group, how do I know if someone joins the group when my app is not running?* - -When you retrieve the list of previous messages if a member has joined any group that the logged-in user is a member of, the list of messages will contain an `Action` message. An `Action` message is a sub-class of `BaseMessage` class. - -For the group member joined event, in the `Action` object received, the following fields can help you get the relevant information- - -1. `action` - `joined` -2. `actionBy` - User object containing the details of the user who joined the group -3. `actionFor`- Group object containing the details of the group the user has joined diff --git a/sdk/ionic-legacy/2.0/groups-kick-ban-members.mdx b/sdk/ionic-legacy/2.0/groups-kick-ban-members.mdx deleted file mode 100644 index 0ac48174b..000000000 --- a/sdk/ionic-legacy/2.0/groups-kick-ban-members.mdx +++ /dev/null @@ -1,268 +0,0 @@ ---- -title: "Ban/Kick Member From A Group" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -There are certain actions that can be performed on the group members: - -1. Kick a member from the group -2. Ban a member from the group -3. Unban a member from the group -4. Update the scope of the member of the group - -All the above actions can only be performed by the **Admin** or the **Moderator** of the group. - -## Kick a Group Member - -The Admin or Moderator of a group can kick a member out of the group using the `kickGroupMember()` method. - - - -``` -var GUID = "GUID"; -var UID = "UID"; - -CometChat.kickGroupMember(GUID, UID).then( - (response) => { - console.log("Group member kicked successfully", response); - }, - (error) => { - console.log("Group member kicking failed with error", error); - } -); -``` - - - - - -The `kickGroupMember()` takes following parameters - -| Parameter | Description | -| --------- | ----------------------------------------------------- | -| `UID` | The UID of the user to be kicked. | -| `GUID` | The GUID of the group from which user is to be kicked | - -The kicked user will be no longer part of the group and can not perform any actions in the group, but the kicked user can rejoin the group. - -## Ban a Group Member - -The Admin or Moderator of the group can ban a member from the group using the `banGroupMember()` method. - - - -``` -var GUID = "GUID"; -var UID = "UID"; - -CometChat.banGroupMember(GUID, UID).then( - (response) => { - console.log("Group member banned successfully", response); - }, - (error) => { - console.log("Group member banning failed with error", error); - } -); -``` - - - - - -The `banGroupMember()` method takes the following parameters: - -| Parameter | Description | -| --------- | ------------------------------------------------------ | -| `UID` | The UID of the user to be banned. | -| `GUID` | The GUID of the group from which user is to be banned. | - -The banned user will be no longer part of the group and can not perform any actions in the group. A banned user cannot rejoin the same group without being unbanned. - -## Unban a Banned Group Member from a Group - -Only Admin or Moderators of the group can unban a previously banned member from the group using the `unbanGroupMember()` method. - - - -``` -var GUID = "GUID"; -var UID = "UID"; - -CometChat.unbanGroupMember(GUID, UID).then( - (response) => { - console.log("Group member unbanned successfully", response); - }, - (error) => { - console.log("Group member unbanning failed with error", error); - } -); -``` - - - - - -The `unbanGroupMember()` method takes the following parameters - -| Parameter | Description | -| --------- | ---------------------------------------------------- | -| `UID` | The UID of the user to be unbanned. | -| `GUID` | The UID of the group from which user is to be banned | - -The unbanned user can now rejoin the group. - -## Get List of Banned Members for a Group - -In order to fetch the list of banned groups members for a group, you can use the `BannedGroupMembersRequest` class. To use this class i.e to create an object of the BannedGroupMembersRequest class, you need to use the `BannedGroupMembersRequestBuilder` class. The `BannedGroupMembersRequestBuilder` class allows you to set the parameters based on which the banned group members are to be fetched. - -The `BannedGroupMembersRequestBuilder` class allows you to set the below parameters: - -The `GUID` of the group for which the banned members are to be fetched must be specified in the constructor of the `GroupMembersRequestBuilder` class. - -### Set Limit - -This method sets the limit i.e. the number of banned members that should be fetched in a single iteration. - - - -```js -let GUID = "GUID"; -let limit = 30; -let bannedGroupMembersRequest = new CometChat.BannedMembersRequestBuilder(GUID) - .setLimit(limit) - .build(); -``` - - - - - -### Set Search Keyword - -This method allows you to set the search string based on which the banned group members are to be fetched. - - - -```js -let GUID = "GUID"; -let limit = 30; -let searchKeyword = "super"; -let bannedGroupMembersRequest = new CometChat.BannedMembersRequestBuilder(GUID) - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - - -Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the `BannedGroupMembersRequest` class. - -Once you have the object of the `BannedGroupMembersRequest` class, you need to call the `fetchNext()` method. Calling this method will return a list of `GroupMember` objects containing n number of banned members where n is the limit set in the builder class. - - - -``` -let GUID = "GUID"; -let limit = 30; -let bannedMembersRequest = new CometChat.BannedMembersRequestBuilder(GUID) - .setLimit(limit) - .build(); - -bannedMembersRequest.fetchNext().then( - (bannedMembers) => { - console.log( - "Banned Group Member list fetched successfully:", - bannedMembers - ); - }, - (error) => { - console.log( - "Banned Group Member list fetching failed with exception:", - error - ); - } -); -``` - - - - - -## Real-Time Group Member Kicked/Banned Events - -*In other words, as a member of a group, how do I know when someone is banned/kicked when my app is running?* - -In order to get real-time events for the kick/ban/unban group members you need to override the following methods of the `GroupListener` class. - -1. `onGroupMemberKicked()` - triggered when any group member has been kicked. -2. `onGroupMemberBanned()` - triggered when any group member has been banned. -3. `onGroupMemberUnbanned()` - triggered when any group member has been unbanned. - - - -``` -let listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.addGroupListener( - listenerID, - new CometChat.GroupListener({ - onGroupMemberKicked: (message, kickedUser, kickedBy, kickedFrom) => { - console.log("User kicked", { message, kickedUser, kickedBy, kickedFrom }); - }, - onGroupMemberBanned: (message, bannedUser, bannedBy, bannedFrom) => { - console.log("User banned", { message, bannedUser, bannedBy, bannedFrom }); - }, - onGroupMemberUnbanned: ( - message, - unbannedUser, - unbannedBy, - unbannedFrom - ) => { - console.log("User unbanned", { - message, - unbannedUser, - unbannedBy, - unbannedFrom, - }); - }, - }) -); -``` - - - - - -## Missed Group Member Kicked/Banned Events - -*In other words, as a member of a group, how do I know when someone is banned/kicked when my app is not running?* - -When you retrieve the list of previous messages if a member has been kicked/banned/unbanned from any group that the logged-in user is a member of, the list of messages will contain an `Action` message. An `Action` message is a sub-class of `BaseMessage` class. - -For group member kicked event, the details can be obtained using the below fields of the `Action` class- - -1. `action` - `kicked` -2. `actionBy` - User object containing the details of the user who has kicked the member -3. `actionOn` - User object containing the details of the member that has been kicked -4. `actionFor` - Group object containing the details of the Group from which the member was kicked - -For group member banned event, the details can be obtained using the below fields of the `Action` class- - -1. `action` - `banned` -2. `actionBy` - User object containing the details of the user who has banned the member -3. `actionOn` - User object containing the details of the member that has been banned -4. `actionFor` - Group object containing the details of the Group from which the member was banned - -For group member unbanned event, the details can be obtained using the below fields of the `Action` class- - -1. `action` - `unbanned` -2. `actionBy` - User object containing the details of the user who has unbanned the member -3. `actionOn` - User object containing the details of the member that has been unbanned -4. `actionFor` - Group object containing the details of the Group from which the member was unbanned diff --git a/sdk/ionic-legacy/2.0/groups-leave-group.mdx b/sdk/ionic-legacy/2.0/groups-leave-group.mdx deleted file mode 100644 index 2f3bddd70..000000000 --- a/sdk/ionic-legacy/2.0/groups-leave-group.mdx +++ /dev/null @@ -1,73 +0,0 @@ ---- -title: "Leave A Group" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Leave a Group - -In order to stop receiving updates and messages for any particular joined group, you will have to leave the group using the `leaveGroup()` method. - - - -```js -var GUID = "GUID"; // guid of the group to join - -CometChat.leaveGroup(GUID).then( - (hasLeft) => { - console.log("Group left successfully:", hasLeft); - }, - (error) => { - console.log("Group leaving failed with exception:", error); - } -); -``` - - - - - -| Parameter | Description | -| --------- | -------------------------------------------- | -| `GUID` | The UID of the group you would like to leave | - -Once a group is left, the user will no longer receive any updates or messages pertaining to the group. - -## Real-time Group Member Left Events - -*In other words, as a member of a group, how do I know if someone has left it?* - -If a user leaves any group, The members of the group receive a real-time event in the `onGroupMemberLeft()` method of the `GroupListener` class. - - - -``` -CometChat.addGroupListener( - "UNIQUE_LISTENER_ID", - new CometChat.GroupListener({ - onGroupMemberLeft: (message, leavingUser, group) => { - console.log("User left", { message, leavingUser, group }); - }, - }) -); -``` - - - - - -## Missed Group Member Left Events - -*In other words, as a member of a group, how do I know if someone has left it when my app is not running?* - -When you retrieve the list of previous messages if a member has left any group that the logged-in user is a member of, the list of messages will contain an `Action` message. An `Action` message is a sub-class of `BaseMessage` class. - -For the group member left event, in the `Action` object received, the following fields can help you get the relevant information- - -1. `action` - `left` -2. `actionBy` - User object containing the details of the user who left the group -3. `actionFor` - Group object containing the details of the group the user has left diff --git a/sdk/ionic-legacy/2.0/groups-retrieve-group-members.mdx b/sdk/ionic-legacy/2.0/groups-retrieve-group-members.mdx deleted file mode 100644 index c17f5810c..000000000 --- a/sdk/ionic-legacy/2.0/groups-retrieve-group-members.mdx +++ /dev/null @@ -1,101 +0,0 @@ ---- -title: "Retrieve Group Members" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Retrieve the List of Group Members - -In order to fetch the list of groups members for a group, you can use the `GroupMembersRequest` class. To use this class i.e to create an object of the GroupMembersRequest class, you need to use the `GroupMembersRequestBuilder` class. The `GroupMembersRequestBuilder` class allows you to set the parameters based on which the groups are to be fetched. - -The `GroupMembersRequestBuilder` class allows you to set the below parameters: - -The GUID of the group for which the members are to be fetched must be specified in the constructor of the `GroupMembersRequestBuilder` class. - -### Set Limit - -This method sets the limit i.e. the number of members that should be fetched in a single iteration. - - - -``` -let GUID = "GUID"; -let limit = 30; -let groupMembersRequest = new CometChat.GroupMembersRequestBuilder(GUID) - .setLimit(limit) - .build(); -``` - - - - - -### Set Search Keyword - -This method allows you to set the search string based on which the group members are to be fetched. - - - -``` -let GUID = "GUID"; -let limit = 30; -let searchKeyword = "super"; -let groupMembersRequest = new CometChat.GroupMembersRequestBuilder(GUID) - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - - -### Set Scopes - -This method allows you to fetch group members based on multiple scopes. - - - -``` -let GUID = "GUID"; -let limit = 30; -let scopes = ["admin", "moderator"]; -let groupMembersRequest = new CometChat.GroupMembersRequestBuilder(GUID) - .setLimit(limit) - .setScopes(scopes) - .build(); -``` - - - - - -Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the `GroupMembersRequest` class. - -Once you have the object of the `GroupMembersRequest` class, you need to call the `fetchNext()` method. Calling this method will return a list of `GroupMember` objects containing n number of members where n is the limit set in the builder class. - - - -``` -let GUID = "GUID"; -let limit = 30; -lett groupMemberRequest = new CometChat.GroupMembersRequestBuilder(GUID) -.setLimit(limit) -.build(); - -groupMemberRequest.fetchNext().then( -groupMembers => { - console.log("Group Member list fetched successfully:", groupMembers); -}, error => { - console.log("Group Member list fetching failed with exception:", error); -} -); -``` - - - - diff --git a/sdk/ionic-legacy/2.0/groups-retrieve-groups.mdx b/sdk/ionic-legacy/2.0/groups-retrieve-groups.mdx deleted file mode 100644 index 2c2003572..000000000 --- a/sdk/ionic-legacy/2.0/groups-retrieve-groups.mdx +++ /dev/null @@ -1,166 +0,0 @@ ---- -title: "Retrieve Groups" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Retrieve List of Groups - -*In other words, as a logged-in user, how do I retrieve the list of groups I've joined and groups that are available?* - -In order to fetch the list of groups, you can use the `GroupsRequest` class. To use this class i.e to create an object of the `GroupsRequest` class, you need to use the `GroupsRequestBuilder` class. The `GroupsRequestBuilder` class allows you to set the parameters based on which the groups are to be fetched. - -The `GroupsRequestBuilder` class allows you to set the below parameters: - -### Set Limit - -This method sets the limit i.e. the number of groups that should be fetched in a single iteration. - - - -```js -let limit = 30; -let groupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .build(); -``` - - - - - -### Set Search Keyword - -This method allows you to set the search string based on which the groups are to be fetched. - - - -```js -let limit = 30; -let searchKeyword = "group"; -let groupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - - -### Joined Only - -This method when used, will ask the SDK to only return the groups that the user has joined or is a part of. - - - -```js -let limit = 30; -let groupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .joinedOnly(true) - .build(); -``` - - - - - -### Set Tags - -This method accepts a list of tags based on which the list of groups is to be fetched. The list fetched will only contain the groups that have been tagged with the specified tags. - - - -```js -let limit = 30; -let tags = ["tag1", "tag2"]; -let groupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .setTags(tags) - .build(); -``` - - - - - -### With Tags - -This property when set to true will fetch tags data along with the list of groups. - - - -``` -let limit = 30; -let groupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .withTags(true) - .build(); -``` - - - - - -Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the `GroupsRequest` class. - -Once you have the object of the `GroupsRequest` class, you need to call the `fetchNext()` method. Calling this method will return a list of `Group` objects containing n number of groups where n is the limit set in the builder class. - -The list of groups fetched will only have the public and password type groups. The private groups will only be available if the user is a member of the group. - - - -``` -let limit = 30; -let groupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .build(); - -groupsRequest.fetchNext().then( - (groupList) => { - console.log("Groups list fetched successfully", groupList); - }, - (error) => { - console.log("Groups list fetching failed with error", error); - } -); -``` - - - - - -## Retrieve Particular Group Details - -*In other words, as a logged-in user, how do I retrieve information for a specific group?* - -To get the information of a group, you can use the `getGroup()` method. - - - -```js -var GUID = "GUID"; -CometChat.getGroup(GUID).then( - (group) => { - console.log("Group details fetched successfully:", group); - }, - (error) => { - console.log("Group details fetching failed with exception:", error); - } -); -``` - - - - - -| Parameter | Description | -| --------- | ------------------------------------------------------------ | -| `GUID` | The GUID of the group for whom the details are to be fetched | - -It returns `Group` object containing the details of the group. diff --git a/sdk/ionic-legacy/2.0/groups-transfer-group-ownership.mdx b/sdk/ionic-legacy/2.0/groups-transfer-group-ownership.mdx deleted file mode 100644 index 08f89aa6f..000000000 --- a/sdk/ionic-legacy/2.0/groups-transfer-group-ownership.mdx +++ /dev/null @@ -1,33 +0,0 @@ ---- -title: "Transfer Group Ownership" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -*In other words, as a logged-in user, how do I transfer the ownership of any group if I am the owner of the group?* - -In order to transfer the ownership of any group, the first condition is that you must be the owner of the group. In case you are the owner of the group, you can use the `transferGroupOwnership()` method provided by the `CometChat` class. - -This will be helpful as the owner is not allowed to leave the group. In case, you as the owner would like to leave the group, you will have to use this method and transfer your ownership first to any other member of the group and only then you will be allowed to leave the group. - - - -```js -let GUID = "GUID"; -let UID = "UID"; -CometChat.transferGroupOwnership(GUID, UID).then( - () => { - console.log("Successfully transferred ownership of the group."); - }, error => { - console.log("Could not transfer ownership of the group: ", error); - } -) -``` - - - - diff --git a/sdk/ionic-legacy/2.0/groups-update-group.mdx b/sdk/ionic-legacy/2.0/groups-update-group.mdx deleted file mode 100644 index d4a198bbe..000000000 --- a/sdk/ionic-legacy/2.0/groups-update-group.mdx +++ /dev/null @@ -1,47 +0,0 @@ ---- -title: "Update A Group" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Update Group - -*In other words, as a group owner, how can I update the group details?* - -You can update the existing details of the group using the `updateGroup()` method. - - - -``` -var GUID = "GUID"; -var groupName = "Hello Group"; -var groupType = CometChat.GROUP_TYPE.PUBLIC; -var group = new CometChat.Group(GUID, groupName, groupType); - -CometChat.updateGroup(group).then( - (group) => { - console.log("Groups details updated successfully:", group); - }, - (error) => { - console.log("Group details update failed with exception:", error); - } -); -``` - - - - - -This method takes an instance of the `Group` class as a parameter which should contain the data that you wish to update. - -| Parameter | Description | -| --------- | ---------------------------- | -| `group` | an instance of class `Group` | - -After a successful update of the group, you will receive an instance of `Group` class containing update information of the group. - -For more information on the `Group` class, please check [here](/sdk/ionic-legacy/2.0/groups-create-group#group-class). diff --git a/sdk/ionic-legacy/2.0/groups.mdx b/sdk/ionic-legacy/2.0/groups.mdx deleted file mode 100644 index 8a5496978..000000000 --- a/sdk/ionic-legacy/2.0/groups.mdx +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: "Groups" -sidebarTitle: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -Groups help your users to converse together in a single space. You can have three types of groups- private, public and password protected. - -Each group includes three kinds of users- owner, moderator, member. diff --git a/sdk/ionic-legacy/2.0/key-concepts.mdx b/sdk/ionic-legacy/2.0/key-concepts.mdx deleted file mode 100644 index b5b8b87a3..000000000 --- a/sdk/ionic-legacy/2.0/key-concepts.mdx +++ /dev/null @@ -1,129 +0,0 @@ ---- -title: "Key Concepts" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -### CometChat Dashboard - -The CometChat Dashboard enables you to create new apps (projects) and manage your existing apps. - - -**How many apps to create?** - -Ideally, you should create two apps- one for development and one for production. And you should use a single app irrespective of the number of platforms. - -Do not create separate apps for every platform; if you do, your users on different platforms will not be able to communicate with each other! - - - -* For every app, a unique App ID is generated. This App ID will be required when integrating CometChat within your app. -* Along with the App ID, you will need to create an Auth Key (from the Dashboard) which can be used for user authentication. - -### Auth & Rest API Keys - -You can generate two types of keys from the dashboard. - -| Type | Privileges | Recommended Use | -| ------------ | ---------------------------------------------------------------- | --------------------------------------------- | -| Auth Key | The Auth Key can be used to create & login users. | In your client side code (during development) | -| Rest API Key | The Rest API Key can be used to perform any CometChat operation. | In your server side code | - -### Users - -A user is anyone who uses CometChat. - -### UID - -* Each user is uniquely identified using UID. -* The UID is typically the primary ID of the user from your database. - - - -UID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed. - - - -### Auth Token - -* A single user can have multiple auth tokens. The auth tokens should be per user per device. -* It should be generated by API call ideally, via server to server call. The auth token should then be given to CometChat for login. -* An Auth Token can only be deleted via dashboard or using REST API. - -### Authentication - -To allow a user to use CometChat, the user must log in to CometChat. - -**CometChat does not handle user management.** You must handle user registration and login at your end. Once the user is logged into your app/site, you can log in the user to CometChat **programmatically**. So the user does not ever directly login to CometChat. - -**CometChat does not handle friends management.** If you want to associate friends with your users, you must handle friends management in your app. Once two users are friends (i.e. they have accepted each other as friends), then you can associate them as friends in CometChat. - -### Typical Workflow - -| Your App | Your Server | CometChat | -| ----------------------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ | -| User registers in your app | You store the user information in your database (e.g. ID, name, email, phone, location etc. in `users` table) | You add the user to CometChat (only ID & name) using the Rest API | -| User logs in to your app | You verify the credentials, login the user and retrieve the user ID | You log in the user to CometChat using the same user ID programmatically | -| User sends a friend request | You display the request to the potential friend | No action required | -| User accepts a friend request | You display the users as friends | You add both the users as friends using the Rest API | - -### User Roles - -A role is a category for a group of similar users. For example, you may want to group your premium users using the role "Premium". You then use this to filter users or enable/disable features by writing conditional code. - -### User List - -* The User List can be used to build the **Contacts** or **Who's Online** view in your app. -* The list of users can be different based on the logged-in user. - -### Groups - -A group can be used for multiple users to communicate with each other on a particular topic/interest. - -### GUID - -* Each group is uniquely identified using GUID. -* The GUID is typically the primary ID of the group from your database. If you do not store group information in your database, you can generate a random string for use as GUID. - - - -GUID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed. - - - -### Types - -CometChat supports three different types of groups: - -| Type | Visibility | Participation | -| -------- | ---------------------------- | ------------------------------------------------- | -| Public | All users | Any user can choose to join | -| Password | All users | Any user with a valid password can choose to join | -| Private | Only users part of the group | Invited users will be auto-joined | - -### Members - -Once a participant joins a group, they become a member of the group. Members are part of the group indefinitely i.e. they will keep receiving messages, calls & notifications. To stop, the participant must either be kicked, banned or intentionally leave the group. - -CometChat supports three different types of member scopes in a group: - -| Member | Default | Privileges | -| ----------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Admin | Group creator is assigned Admin scope | - Change scope of Group Members to admin, moderator or participant.
- Can add members to a group.
- Kick & Ban Participants/Moderators/Admins
- Send & Receive Messages & Calls
- Update group
- Delete group | -| Moderator | - | - Change scope of moderator or participant.
- Update group
- Kick & Ban Participants
- Send & Receive Messages & Calls | -| Participant | Any other user is assigned Participant scope | - Send & Receive Messages & Calls | - -### Messaging - -Any message in CometChat can belong to either one of the below categories - -| Category | Description | -| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| message | Any message belonging to the category `message` can belong to either one of the below types:
1. text
2. image
3. video
4. audio
5. file | -| custom | Custom messages are an option available for developers to send custom data across to users/groups. To send any additional data that does not fit in the default categories and types provided by CometChat, you can use the custom messages. | -| action | Action messages are system-generated messages. These can belong to either of the below types:
1. groupMember - when the action is performed on a group member
2. message - when the action is performed on a message | -| call | These are call-related messages. These can belong to either one of the two types:
1. audio
2. video | diff --git a/sdk/ionic-legacy/2.0/message-structure-and-hierarchy.mdx b/sdk/ionic-legacy/2.0/message-structure-and-hierarchy.mdx deleted file mode 100644 index 6c0a7034d..000000000 --- a/sdk/ionic-legacy/2.0/message-structure-and-hierarchy.mdx +++ /dev/null @@ -1,75 +0,0 @@ ---- -title: "Message Structure And Hierarchy" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -The below diagram helps you better understand the various message categories and types that a CometChat message can belong to. - - - - - -As you can see in the above diagram, every message belongs to a particular category. A message can belong to either one of the 4 categories - -1. Message -2. Custom -3. Action -4. Call - -Each category can be further be classified into types. - -\#Message A message belonging to the category `message` can be classified into either 1 of the below types: - -1. text - A plain text message -2. image- An image message -3. video- A video message -4. audio- An audio message -5. file- A file message - -## Custom - -In the case of messages that belong to the `custom` category, there are no predefined types. Custom messages can be used by developers to send messages that do not fit in the default category and types provided by CometChat. For messages with the category `custom`, the developers can set their own type to uniquely identify the custom message. A very good example of a custom message would be the sharing of location co-ordinates. In this case, the developer can decide to use the custom message with type set to `location`. - -## Action - -Action messages are system-generated messages. Messages belonging to the `action` category can further be classified into one of the below types: - -1. groupMember - action performed on a group member. -2. message - action performed on a message. - -Action messages hold another property called `action` which actually determine the action that has been performed For the type `groupMember` the action can be either one of the below: - -1. joined - when a group member joins a group -2. left - when a group member leaves a group -3. kicked - when a group member is kicked from the group -4. banned - when a group member is banned from the group -5. unbanned - when a group member is unbanned from the group -6. added - when a user is added to the group -7. scopeChanged - When the scope of a group member is changed. - -For the type `message`, the action can be either one of the below: - -1. edited - when a message is edited. -2. deleted - when a message is deleted. - -## Call - -Messages with the category `call` are Calling related messages. These can belong to either one of the 2 types - -1. audio -2. video - -The call messages have a property called status that helps you figure out the status of the call. The status can be either one of the below values: - -1. initiated - when a is initiated to a user/group -2. ongoing - when the receiver of the call has accepted the call -3. canceled - when the call has been canceled by the initiator of the call -4. rejected - when the call has been rejected by the receiver of the call -5. unanswered - when the call was not answered by the receiver. -6. busy - when the receiver of the call was busy on another call. -7. ended - when the call was successfully completed and ended by either the initiator or receiver. diff --git a/sdk/ionic-legacy/2.0/messaging-additional-message-filtering.mdx b/sdk/ionic-legacy/2.0/messaging-additional-message-filtering.mdx deleted file mode 100644 index 58712ee47..000000000 --- a/sdk/ionic-legacy/2.0/messaging-additional-message-filtering.mdx +++ /dev/null @@ -1,526 +0,0 @@ ---- -title: "Additional Message Filtering" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -The `MessagesRequest` class as you must be familiar with helps you to fetch messages based on the various parameters provided to it. This document will help you understand better the various options that are available using the `MessagesRequest` class. - -The `MessagesRequest` class is designed using the `Builder design pattern`. In order to obtain an object of the `MessagesRequest` class, you will have to make use of the `MessagesRequestBuilder` class in the `MessagesRequest` class. - -The `MessagesRequestBuilder` class allows you to set various parameters to the `MessagesRequest` class based on which the messages are fetched. - -Steps to generate an object of the MessagesRequest class: - -1. Create an object of the `MessagesRequestBuilder` class. -2. Set all the parameters you wish to set. -3. Call the `build()` method of the `MessagesRequestBuilder` class to get an object of the `MessagesRequest` class. - -Once you have an object of the `MessagesRequest` class, you can call either the `fetchNext()` method or the `fetchPrevious()` method using the object. - -1. fetchNext() - Calling this method will return the messages after the specified parameters. -2. fetchPrevious() - Calling this method will give you messages before the specified parameters. - -Since messages are obtained in a paginated manner, a maximum of 100 messages can be pulled in a single iteration. Calling the `fetchPrevious()`/`fetchNext()` method on the same `MessagesRequest` object will get you the next set of messages. - -Now that you are clear how to use the `MessagesRequest` class, below are the various options available: - -## Number of messages fetched - -*In other words, how do I set the number of messages fetched in a single iteration* - -To achieve this, you can use the `setLimit()` method. This method takes an integer value as the input and informs the SDK to fetch the specified number of messages in one iteration. The maximum number of messages that can be fetched in one go is 100. - - - -``` -let UID = "UID"; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(50) - .build(); -``` - - - - -``` -let GUID = "GUID"; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(50) - .build(); -``` - - - - - -## Messages for a user conversation - -\_In other words, how do I fetch messages between me and any user \_ - -This can be achieved using the `setUID()` method. This method takes the UID of the user with whom the conversation is to be fetched. When a valid UID is passed, the SDK will return all the messages that are a part of the conversation between the logged-in user and the UID that has been specified. - - - -``` -let UID = "UID"; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(50) - .build(); -``` - - - - - -## Messages for a group conversation - -*In other words, how do I fetch messages for any group conversation* - -You can achieve this using the `setGUID()` method. This method takes the GUID of a group for which the conversations are to be fetched. Passing a valid GUID to this method will return all the messages that are a part of the group conversation. Please note that the logged-in user must be a member of the group to fetch the messages for that group. - - - -``` -let GUID = "GUID"; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(50) - .build(); -``` - - - - - -## Messages before/after a message - -In other words, how do I fetch messages before or after a particular message - -This can be achieved using the `setMessageId()` method. This method takes the message-id as input and provides messages only after/before the message-id based on if the fetchNext() or fetchPrevious() method is triggered. - - - -```js -let UID = "UID"; -let messageId = 1; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setMessageId(messageId) - .setLimit(limit) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let messageId = 1; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setMessageId(messageId) - .setLimit(limit) - .build(); -``` - - - - - -This method can be used along with `setUID()` or `setGUID()` methods to fetch messages after/before any specific message-id for a particular user/group conversation. - -## Messages before/after a given time - -**In other words, how do I fetch messages before or after a particular date or time** - -You can easily achieve this using the `setTimestamp()` method. This method takes the Unix timestamp as input and provides messages only after/before the timestamp based on if fetchNext() or fetchPrevious() method is triggered. - - - -```js -let UID = "UID"; -let timestamp = 1602221371; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setTimestamp(timestamp) - .setLimit(limit) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let timestamp = 1602221371; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setTimestamp(timestamp) - .setLimit(limit) - .build(); -``` - - - - - -This method can be used along with `setUID()` or `setGUID()` methods to fetch messages after/before any specific date or time for a particular user/group conversation. - -## Unread messages - -**In other words, how do I fetch messages before or after a particular date or time** - -This can easily be achieved using setting the unread flag to true. For this, you need to use the `setUnread()` method. This method takes a boolean value as input. If the value is set to true, the SDK will return just the unread messages. - - - -```js -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setUnread(true) - .setLimit(limit) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setUnread(true) - .setLimit(limit) - .build(); -``` - - - - - -This method along with `setGUID()` or `setUID()` can be used to fetch unread messages for a particular group or user conversation respectively. - -## Exclude messages from blocked users - -**In other words, how do I fetch messages before or after a particular date or time** - -This can be easily achieved using the `hideMessagesFromBlockedUsers()` method. This method accepts a boolean value which determines if the messages from users blocked by the logged-in user need to be a part if the fetched messages. If the value is set to true, the messages will be hidden and won't be a part of the messages fetched. The default value is false i.e if this method is not used, the messages from blocked users will be included in the fetched messages. - - - -```js -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .hideMessagesFromBlockedUsers(true) - .setLimit(limit) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .hideMessagesFromBlockedUsers(true) - .setLimit(limit) - .build(); -``` - - - - - -This method can be used to hide the messages by users blocked by logged in user in groups that both the members are a part of. - -## Updated and received messages - -**In other words, how do I fetch messages before or after a particular date or time** - -This method accepts a Unix timestamp value and will return all the messages that have been updated and the ones that have been sent/received after the specified time. The messages updated could mean the messages that have been marked as read/delivered or if the messages are edited or deleted. - - - -```js -let UID = "UID"; -let limit = 30; -let timestamp = 1602221371; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setUpdatedAfter(timestamp) - .setLimit(limit) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let limit = 30; -let timestamp = 1602221371; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setUpdatedAfter(timestamp) - .setLimit(limit) - .build(); -``` - - - - - -This can be useful in finding the messages that have been received or updated after a certain time. Can prove very useful if you are saving the messages locally and would like to know the messages that have been updated or received after the last message available in your local databases. - -## Updated messages only - -**In other words, how do I fetch messages before or after a particular date or time** - -This can be achieved easily by setting the updatesOnly parameter to true. To do so, you can use the updatesOnly() method. This method takes a boolean input and can be used with the `setUpdatedAfter()` method to get jus the updated messages and not the messages sent/received after the specified time. This method cannot be used independently and always needs to be used with the `setUpdatedAfter()` method. - - - -```js -let UID = "UID"; -let limit = 30; -let timestamp = 1602221371; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setUpdatedAfter(timestamp) - .updatesOnly(true) - .setLimit(limit) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let limit = 30; -let timestamp = 1602221371; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setUpdatedAfter(timestamp) - .updatesOnly(true) - .setLimit(limit) - .build(); -``` - - - - - -Messages for multiple categories - -**In other words, how do I fetch messages before or after a particular date or time** - -We recommend before trying this, you refer to the [Message structure and hierarchy guide](/sdk/ionic-legacy/2.0/message-structure-and-hierarchy) to get familiar with the various categories of messages. - -For this, you will have to use the `setCategories()` method. This method accepts a list of categories. This tells the SDK to fetch messages only belonging to these categories. - - - -```js -let UID = "UID"; -let limit = 30; -let categories = ["message", "custom"]; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setCategories(categories) - .setLimit(limit) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let limit = 30; -let categories = ["message", "custom"]; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setCategories(categories) - .setLimit(limit) - .build(); -``` - - - - - -The above snippet will help you get only the messages belonging to the `message` and `custom` category. This can also be used to disable certain categories of messages like `call` and `action`. This along with `setGUID()` and `setUID()` can help display only the messages you wish to display avoiding the other category of messages. - -## Messages for multiple types - -**In other words, how do I fetch messages before or after a particular date or time** - -We recommend before trying this, you refer to the [Message structure & hierarchy guide](/sdk/ionic-legacy/2.0/message-structure-and-hierarchy) to get familiar with the various types of messages. - -This can be easily achieved using the `setTypes()` method. This method accepts a list of types. This tells the SDK to fetch messages only belonging to these types. - - - -```js -let UID = "UID"; -let limit = 30; -let categories = ["message"]; -let types = ["image", "video", "audio", "file"]; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setCategories(categories) - .setTypes(types) - .setLimit(limit) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let limit = 30; -let categories = ["message"]; -let types = ["image", "video", "audio", "file"]; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setCategories(categories) - .setTypes(types) - .setLimit(limit) - .build(); -``` - - - - - -Using the above code snippet, you can fetch all the media messages. This along with setUID() or setGUID() can be used to fetch media messages for any particular conversation. This can be useful in many other scenarios as well. - -## Messages for a specific thread - -**In other words, how do I fetch messages before or after a particular date or time** - -This can be done using the `setParentMessageId()` method. This method needs to be used when you have implemented threaded conversations in your app. This method will return the messages only belonging to the thread with the specified parent Id. - - - -```js -let UID = "UID"; -let messageId = 1; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .setParentMessageId(messageId) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let messageId = 1; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .setParentMessageId(messageId) - .build(); -``` - - - - - -The above code snippet returns the messages that belong to the thread with parent id 100. - -## Hide threaded messages in user/group conversations - -**In other words, how do I fetch messages before or after a particular date or time** - -In order to do this, you can use the `hideReplies()` method. This method is also related to threaded conversations. This method takes boolean as input. This boolean when set to true will make sure that the messages that belong to threads are not fetched. If set to false, which is also the default value, the messages belong to the threads will also be fetched along with other messages. - - - -```js -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .hideReplies(true) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hideReplies(true) - .build(); -``` - - - - - -## Hide deleted messages in user/group conversations - -**In other words, how do I fetch messages before or after a particular date or time** - -In order to do this, you can use the `hideDeletedMessages()` method. This method takes boolean as input. This boolean when set to true will make sure that the deleted messages are not fetched. If set to false, which is also the default value, the deleted messages will also be fetched along with other messages. - - - -```js -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .hideDeletedMessages(true) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hideDeletedMessages(true) - .build(); -``` - - - - diff --git a/sdk/ionic-legacy/2.0/messaging-delete-conversation.mdx b/sdk/ionic-legacy/2.0/messaging-delete-conversation.mdx deleted file mode 100644 index 5c21dc502..000000000 --- a/sdk/ionic-legacy/2.0/messaging-delete-conversation.mdx +++ /dev/null @@ -1,57 +0,0 @@ ---- -title: "Delete A Conversation" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -In case you want to delete a conversation, you can use the `deleteConversation()` method. - -This method takes two parameters. The unique id (UID/GUID) of the conversation to be deleted & the type (user/group) of conversation to be deleted. - - - -``` -let UID = "UID"; -let type = "user"; -CometChat.deleteConversation(UID, type).then( - (deletedConversation) => { - console.log(deletedConversation); - }, - (error) => { - console.log("error while deleting a conversation", error); - } -); -``` - - - - -``` -let GUID = "GUID"; -let type = "group"; -CometChat.deleteConversation(GUID, type).then( - (deletedConversation) => { - console.log(deletedConversation); - }, - (error) => { - console.log("error while deleting a conversation", error); - } -); -``` - - - - - -This method deletes the conversation only for the logged-in user. To delete a conversation for all the users of the conversation, please refer to our REST API documentation [here](https://api-explorer.cometchat.com/reference/deletes-conversation). - -The `deleteConversation()` method takes the following parameters: - -| Parameter | Description | Required | -| ---------------- | --------------------------------------------------------------------------------- | -------- | -| conversationWith | `UID` of the user or `GUID` of the group whose conversation you want to delete. | YES | -| conversationType | The type of conversation you want to delete . It can be either `user` or `group`. | YES | diff --git a/sdk/ionic-legacy/2.0/messaging-delete-message.mdx b/sdk/ionic-legacy/2.0/messaging-delete-message.mdx deleted file mode 100644 index 612051070..000000000 --- a/sdk/ionic-legacy/2.0/messaging-delete-message.mdx +++ /dev/null @@ -1,94 +0,0 @@ ---- -title: "Delete A Message" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -While [deleting a message](/sdk/ionic-legacy/2.0/messaging-delete-message#delete-a-message) is straightforward, receiving events for deleted messages with CometChat has two parts: - -1. Adding a listener to receive [real-time message deletes](/sdk/ionic-legacy/2.0/messaging-delete-message#real-time-message-delete-events) when your app is running. -2. Calling a method to retrieve [missed message deletes](/sdk/ionic-legacy/2.0/messaging-delete-message#missed-message-delete-events) when your app was not running. - -## Delete a Message - -*In other words, as a sender, how do I delete a message?* - -In case you have to delete a message, you can use the `deleteMessage()` method. This method takes the message ID of the message to be deleted. - - - -```js -let messageId = "ID_OF_THE_MESSAGE_YOU_WANT_TO_DELETE"; - -CometChat.deleteMessage(messageId).then( - (message) => { - console.log("Message deleted", message); - }, - (error) => { - console.log("Message delete failed with error:", error); - } -); -``` - - - - - -Once the message is deleted, In the `onSuccess()` callback, you get an object of the `BaseMessage` class, with the `deletedAt` field set with the timestamp of the time the message was deleted. Also, the `deletedBy` field is set. These two fields can be used to identify if the message is deleted while iterating through a list of messages. - -By default, CometChat allows certain roles to delete a message. - -| User Role | Conversation Type | Deletion Capabilities | -| --------------- | ----------------------- | ------------------------------ | -| Message Sender | One-on-One Conversation | Messages they have sent. | -| Message Sender | Group Conversation | Messages they have sent. | -| Group Admin | Group Conversation | All the messages in the group. | -| Group Moderator | Group Conversation | All the messages in the group. | - -## Real-time Message Delete Events - -*In other words, as a recipient, how do I know when someone deletes a message when my app is running?* - -In order to receive real-time events for a message being deleted, you need to override the `onMessageDeleted()` method of the `MessageListener` class. - - - -```js -var listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener( - listenerID, - new CometChat.MessageListener({ - onMessageDeleted: (message) => { - console.log("Deleted Message", message); - }, - }) -); -``` - - - - - -## Missed Message Delete Events - -*In other words, as a recipient, how do I know if someone deleted a message when my app was not running?* - -When you retrieve the list of previous messages, for the messages that were deleted, the `deletedAt` and the `deletedBy` fields will be set. Also, for example, of the total number of messages for a conversation are 100, and the message with message ID 50 was deleted. Now the message with id 50 will have the `deletedAt` and the `deletedBy` fields set whenever it is pulled from the history. Also, the 101st message will be and \[Action] message informing you that the message with id 50 has been deleted. - -For the message deleted event, in the `Action` object received, the following fields can help you get the relevant information- - -1. `action` - `deleted` -2. `actionOn` - Updated message object which was deleted. -3. `actionBy` - User object containing the details of the user who has deleted the message. -4. `actionFor` - User/group object having the details of the receiver to which the message was sent. - - - -In order to edit or delete a message you need to be either the sender of the message or the admin/moderator of the group in which the message was sent. - - diff --git a/sdk/ionic-legacy/2.0/messaging-edit-message.mdx b/sdk/ionic-legacy/2.0/messaging-edit-message.mdx deleted file mode 100644 index c5eb32232..000000000 --- a/sdk/ionic-legacy/2.0/messaging-edit-message.mdx +++ /dev/null @@ -1,104 +0,0 @@ ---- -title: "Edit A Message" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -While [editing a message](/sdk/ionic-legacy/2.0/messaging-edit-message#edit-a-message) is straightforward, receiving events for edited messages with CometChat has two parts: - -1. Adding a listener to receive [real-time message edits](/sdk/ionic-legacy/2.0/messaging-edit-message#real-time-message-edit-events) when your app is running -2. Calling a method to retrieve [missed message edits](/sdk/ionic-legacy/2.0/messaging-edit-message#missed-message-edit-events) when your app was not running - -## Edit a Message - -*In other words, as a sender, how do I edit a message?* - -In order to edit a message, you can use the `editMessage()` method. This method takes an object of the `BaseMessage` class. At the moment, you are only allowed to edit `TextMessage` and `CustomMessage`. Thus, the `BaseMessage` object must either be a Text or a Custom Message. - - - -``` -let receiverID = "RECEIVER_UID"; -let messageText = "Hello world!"; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let messageId = "MESSAGE_ID_OF_THE_MESSAGE_TO_BE_EDITED"; -let textMessage = new CometChat.TextMessage( - receiverID, - messageText, - receiverType -); - -textMessage.setId(messageId); - -CometChat.editMessage(textMessage).then( - (message) => { - console.log("Message Edited", message); - }, - (error) => { - console.log("Message editing failed with error:", error); - } -); -``` - - - - - -The object of the edited message will be returned in the `onSuccess()` callback method of the listener. The message object will contain the `editedAt` field set with the timestamp of the time the message was edited. This will help you identify if the message was edited while iterating through the list of messages. The `editedBy` field is also set to the UID of the user who edited the message. - -By default, CometChat allows certain roles to edit a message. - -| User Role | Conversation Type | Edit Capabilities | -| --------------- | ----------------------- | -------------------------- | -| Message Sender | One-on-One Conversation | Messages they have sent. | -| Message Sender | Group Conversation | Messages they have sent. | -| Group Owner | Group Conversation | All messages in the group. | -| Group Moderator | Group Conversation | All messages in the group. | - -## Real-time Message Edit Events - -*In other words, as a recipient, how do I know when someone has edited their message when my app is running?* - -In order to receive real-time events for message being edited, you need to override the `onMessageEdited()` method of the `MessageListener` class. - - - -``` -var listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener( - listenerID, - new CometChat.MessageListener({ - onMessageEdited: (message) => { - console.log("Edited Message", message); - }, - }) -); -``` - - - - - -## Missed Message Edit Events - -*In other words, as a recipient, how do I know when someone edited their message when my app was not running?* - -When you retrieve the list of previous messages, for the message that was edited, the `editedAt` and the `editedBy` fields will be set. Also, for example, of the total number of messages for a conversation are 100, and the message with message ID 50 was edited. Now the message with id 50 will have the `editedAt` and the `editedBy` fields set whenever it is pulled from the history. Also, the 101st message will be and \[Action] message informing you that the message with id 50 has been edited. - -For the message edited event, in the `Action` object received, the following fields can help you get the relevant information- - -1. `action` - `edited` -2. `actionOn` - Updated message object with the edited details. -3. `actionBy` - User object containing the details of the user who has edited the message. -4. `actionFor` - User/group object having the details of the receiver to which the message was sent. - - - -In order to edit a message, you need to be either the sender of the message or the admin/moderator of the group in which the message was sent. - - diff --git a/sdk/ionic-legacy/2.0/messaging-receipts.mdx b/sdk/ionic-legacy/2.0/messaging-receipts.mdx deleted file mode 100644 index 4b55d422b..000000000 --- a/sdk/ionic-legacy/2.0/messaging-receipts.mdx +++ /dev/null @@ -1,133 +0,0 @@ ---- -title: "Delivery & Read Receipts" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Mark Messages as Delivered - -*In other words, as a recipient, how do I inform the sender that I've received a message?* - -Messages are marked as delivered automatically by the SDK whenever the message is received. - -## Mark Messages as Read - -*In other words, as a recipient, how do I inform the sender I've read a message?* - -You can mark the messages for a particular conversation as read using the `markAsRead()` method. This method takes the below parameters as input: - -| Parameter | Information | -| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `messageId` | The ID of the message above which all the messages for a particular conversation are to be marked as read. | -| `receiverId` | In case of one to one conversation message's sender `UID` will be the receipt's receiver Id. In case of group conversation message's receiver Id will be the receipt's receiver Id. | -| `receiverType` | Type of the receiver. Could be either of the two values( user or group). | - -Messages for both User conversation and Groups can be marked as read using this method. - -Ideally, you would like to mark all the messages as read for any conversation when the user opens the chat window for that conversation. This includes two scenarios: - -1. **When the list of messages for the conversation is fetched**: In this case you need to obtain the last message in the list of messages and pass the message Id of that message to the markAsRead() method. -2. **When the user is on the chat window and a real-time message is received:** In this case you need to obtain the message Id of the message and pass it to the markAsRead() method. - - - -``` -var messageId = "MESSAGE_ID"; -var receiverId = "MESSAGE_SENDER_UID"; -var receiverType = "user"; -CometChat.markAsRead(messageId, receiverId, receiverType); -``` - - - - -``` -var messageId = "MESSAGE_ID"; -var receiverId = "MESSAGE_RECEIVER_GUID"; -var receiverType = "group"; -CometChat.markAsRead(messageId, receiverId, receiverType); -``` - - - - - -This method will mark all the messages before the messageId specified, for the conversation with receiverId and receiverType(user/group) as read. - -## Receive Delivery & Read Receipts - -*In other words, as a recipient, how do I know when a message I sent has been delivered or read by someone?* - -### Real-time Receipts - -Real-time events for messages of a conversation being read or delivered can be obtained in the `onMessagesRead()` and the `onMessagesDelivered()` methods of the `MessageListener` class. - - - -``` -let listenerId = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener( - listenerId, - new CometChat.MessageListener({ - onMessagesDelivered: (messageReceipt) => { - console.log("MessageDeliverd", { messageReceipt }); - }, - onMessagesRead: (messageReceipt) => { - console.log("MessageRead", { messageReceipt }); - }, - }) -); -``` - - - - - -You will receive events in the form of `MessageReceipt` objects. The message receipt contains the below parameters: - -| Parameter | Information | -| -------------- | -------------------------------------------------------------------------------------------------------------------- | -| `messageId` | The Id of the message prior to which all the messages for that particular conversation have been marked as read. | -| `sender` | User object containing the details of the user who has marked the message as read. | -| `receiverId` | Id of the receiver whose conversation has been marked as read. | -| `receiverType` | Type of the receiver (user/group) | -| `receiptType` | Type of the receipt (read/delivered) | -| `deliveredAt` | The timestamp of the time when the message was delivered. This will only be present if the receiptType is delivered. | -| `readAt` | The timestamp of the time when the message was read. This will only be present when the receiptType is read. | - -### Missed Receipts - -You will receive message receipts when you load offline messages. For groups, we do not include the list the users that have received it. You need to call the `getMessageReceipts()` method for it. - -While fetching messages in bulk, if the message is a part of a user conversation, the message object will have two fields viz. `deliveredAt` and `readAt` which hold the timestamp for the time the message was delivered and read respectively. using these two variables, the delivery and read status for a user message can be obtained. - -However, for a group message, the `deliveredAt` and `readAt` fields are never set and hence to get the status of the message you can use the below-described method. - -### Receipt History for a Single Message - -In order to fetch the message receipts, you can use the `getMessageReceipts()` method. - - - -```js -let messageId = msgId; -CometChat.getMessageReceipts(messageId).then( - (receipts) => { - console.log("Message details fetched:", receipts); - }, - (error) => { - console.log("Error in getting messag details ", error); - } -); -``` - - - - - -You will receive a list of `MessageReceipt` objects. diff --git a/sdk/ionic-legacy/2.0/messaging-receive-messages.mdx b/sdk/ionic-legacy/2.0/messaging-receive-messages.mdx deleted file mode 100644 index 26eabcb46..000000000 --- a/sdk/ionic-legacy/2.0/messaging-receive-messages.mdx +++ /dev/null @@ -1,580 +0,0 @@ ---- -title: "Receive Messages" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -Receiving messages with CometChat has two parts: - -1. Adding a listener to receive [real-time messages](/sdk/ionic-legacy/2.0/messaging-receive-messages#real-time-messages) when your app is running. -2. Calling a method to retrieve [missed messages](/sdk/ionic-legacy/2.0/messaging-receive-messages#missed-messages) when your app was not running. - -## Real-Time Messages - -*In other words, as a recipient, how do I receive messages when my app is running?* - -To receive real-time incoming messages, you need to register the `MessageListener` wherever you wish to receive the incoming messages. You can use the `addMessageListener()` method to do so. - - - -```js -let listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener( - listenerID, - new CometChat.MessageListener({ - onTextMessageReceived: (textMessage) => { - console.log("Text message received successfully", textMessage); - }, - onMediaMessageReceived: (mediaMessage) => { - console.log("Media message received successfully", mediaMessage); - }, - onCustomMessageReceived: (customMessage) => { - console.log("Custom message received successfully", customMessage); - }, - }) -); -``` - - - - - -| Parameter | Description | -| -------------- | --------------------------------------------- | -| **listenerId** | An ID that uniquely identifies that listener. | - -We recommend you remove the listener once you don't want to receive a message for particular listener. - - - -``` -var listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.removeMessageListener(listenerID); -``` - - - - - - - -As a sender, you will not receive your own message in a real-time message event. However, if a user is logged-in using multiple devices, they will receive an event for their own message in other devices. - - - -## Missed Messages - -*In other words, as a recipient, how do I receive messages that I missed when my app was not running?* - -For most use cases, you will need to add functionality to load missed messages. If you're building an on-demand or live streaming app, you may choose to skip this and fetch message history instead. - -Using the same `MessagesRequest` class and the filters provided by the `MessagesRequestBuilder` class, you can fetch the message that we sent to the logged-in user but were not delivered to him as he was offline. For this, you will require the ID of the last message received. You can either maintain it at your end or use the `getLastDeliveredMessageId()` method provided by the CometChat class. This ID needs to be passed to the `setMessageId()` method of the builder class. - -Now using the `fetchNext()` method, you can fetch all the messages that were sent to the user when he/she was offline. - -Calling the `fetchNext()` method on the same object repeatedly allows you to fetch all the offline messages for the logged in user. - -### For a Particular One-on-one Conversation - - - -``` -let UID = "UID"; -let limit = 30; -let latestId = await CometChat.getLastDeliveredMessageId(); - -var messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setMessageId(latestId) - .setLimit(limit) - .build(); - -messagesRequest.fetchNext().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -### For a Particular Group - - - -``` -let GUID = "GUID"; -let limit = 30; -let latestId = await CometChat.getLastDeliveredMessageId(); - -var messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setMessageId(latestId) - .setLimit(limit) - .build(); - -messagesRequest.fetchNext().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -## Unread Messages - -*In other words, as a logged-in user, how do I fetch the messages I've not read?* - -Using the `MessagesRequest` class described above, you can fetch the unread messages for the logged in user. In order to achieve this, you need to set the `unread` variable in the builder to `true` using the `setUnread()` method so that only the unread messages are fetched. - -### For a Particular One-on-one Conversation - - - -``` -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setUnread(true) - .setLimit(limit) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -### For a Particular Group - - - -``` -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setUnread(true) - .setLimit(limit) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - - - -The list of messages received is in the form of objects of `BaseMessage` class. A BaseMessage can either be an object of the `TextMessage`, `MediaMessage`, `CustomMessage`, `Action` or `Call` class. You can use the `instanceOf` operator to check the type of object. - - - -## Message History - -*In other words, as a logged-in user, how do I fetch the complete message history?* - -### For a Particular One-on-one Conversation - -Using the `MessagesRequest` class and the filters for the `MessagesRequestBuilder` class as shown in the below code snippet, you can fetch the entire conversation between the logged in user and any particular user. For this use case, it is mandatory to set the UID parameter using the `setUID()` method of the builder. This UID is the unique id of the user for which the conversation needs to be fetched. - - - -``` -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -Calling the `fetchPrevious()` method on the same object repeatedly allows you to fetch the entire conversation between the logged in user and the specified user. This can be implemented with upward scrolling to display the entire conversation. - -### For a Particular Group - -Using the `MessagesRequest` class and the filters for the `MessagesRequestBuilder` class as shown in the below code snippet, you can fetch the entire conversation for any group provided you have joined the group. For this use case, it is mandatory to set the GUID parameter using the `setGUID()` method of the builder. This GUID is the unique identifier of the Group for which the messages are to be fetched. - - - -``` -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -Calling the `fetchPrevious()` method on the same object repeatedly allows you to fetch the entire conversation for the group. This can be implemented with upward scrolling to display the entire conversation. - -## Search Messages - -Along with the other parameters mentioned above, you can use the `setSearchKeyword()` method provided by the `MessagesRequestBuilder` class. This method takes a string as input. This is the string that is to be searched amongst the messages. This can be used to fetch all the messages that contain the string in a paginated way. Calling the `fetchPrevious()` method on the same object repeatedly allows you to fetch all the messages with the keyword specified in all your conversations. - -### For a Particular One-on-one Conversation - - - -``` -let UID = "UID"; -let limit = 30; -let searchKeyword = "Hello"; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -### For a Particular Group - - - -```js -let GUID = "GUID"; -let limit = 30; -let searchKeyword = "Hello"; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -## Unread Message Count - -*In other words, as a logged-in user, how do I find out the number of unread messages that I have?* - -### Fetch Unread Count for a Particular One-on-one Conversation - -*In other words, how do I find out the number of unread messages I have from a particular user?* - -In order to get the unread message count for a particular user, you can use the `getUnreadMessageCountForUser()`. - -This method has the below two variants: - - - -``` -CometChat.getUnreadMessageCountForUser(UID); -``` - - - - - -if you wish to ignore the messages from blocked users you can use the below syntax setting the boolean parameter to true: - - - -``` -CometChat.getUnreadMessageCountForUser(UID, hideMessagesFromBlockedUsers); -``` - - - - - - - -``` -let UID = "UID"; - -CometChat.getUnreadMessageCountForUser(UID).then( - (array) => { - console.log("Message count fetched", array); - }, - (error) => { - console.log("Error in getting message count", error); - } -); -``` - - - - - -In the `then()` callback, you will receive an array which will contain the `UID` of the user as the key and the unread message count as the value. - -### Fetch Unread Count for a Particular Group Conversation - -*In other words, how do I find out the number of unread messages I have in a single group?* - -In order to get the unread message count for a particular group, you can use the `getUnreadMessageCountForGroup()`. - -This method has the below two variants: - - - -``` -CometChat.getUnreadMessageCountForGroup(GUID); -``` - - - - - -if you wish to ignore the messages from blocked users you can use the below syntax setting the boolean parameter to true: - - - -``` -CometChat.getUnreadMessageCountForGroup(GUID, hideMessagesFromBlockedUsers); -``` - - - - - - - -``` -let GUID = "GUID"; - -CometChat.getUnreadMessageCountForGroup(GUID).then( - (array) => { - console.log("Message count fetched", array); - }, - (error) => { - console.log("Error in getting message count", error); - } -); -``` - - - - - -In the `then()` callback, you will receive an array which will contain the `UID` of the user as the key and the unread message count as the value. - -### Fetch Unread Count for All One-on-one & Group Conversations - -*In other words, how do I find out the number of unread messages for every one-on-one and group conversation?* - -In order to get all the unread message count combined i.e unread message counts for all the users and groups, you can use the `getUnreadMessageCount()` method. - -This method has two variants: - - - -``` -CometChat.getUnreadMessageCount(); -``` - - - - - -if you wish to ignore the messages from blocked users you can use the below syntax setting the boolean parameter to true: - - - -``` -CometChat.getUnreadMessageCount(hideMessagesFromBlockedUsers); -``` - - - - - - - -``` -CometChat.getUnreadMessageCount().then( - (array) => { - console.log("Message count fetched", array); - }, - (error) => { - console.log("Error in getting message count", error); - } -); -``` - - - - - -It return array having two keys: - -1. user - The value for this key holds another array that holds the UIDs of the users and their corresponding unread message counts -2. group - The value for this key holds another array that holds the GUIDs of the groups and their corresponding unread message counts - -### Fetch Unread Count for All One-on-one Conversations - -In order to fetch the unread message counts for just the users, you can use the `getUnreadMessageCountForAllUsers()` method. This method just like others has two variants: - - - -``` -CometChat.getUnreadMessageCountForAllUsers(); -``` - - - - - -if you wish to ignore the messages from blocked users you can use the below syntax setting the boolean parameter to true: - - - -``` -CometChat.getUnreadMessageCountForAllUsers(hideMessagesFromBlockedUsers); -``` - - - - - - - -``` -CometChat.getUnreadMessageCountForAllUsers().then( - (array) => { - console.log("Message count fetched", array); - }, - (error) => { - console.log("Error in getting message count", error); - } -); -``` - - - - - -It returns a Array which will contain the UIDs of the users as the key and the unread message counts as the values. - -### Fetch Unread Count for All Group Conversations - -In order to fetch the unread message counts for just the groups, you can use the `getUnreadMessageCountForAllGroups()` method. This method just like others has two variants: - - - -``` -CometChat.getUnreadMessageCountForAllGroups(); -``` - - - - - -if you wish to ignore the messages from blocked users you can use the below syntax setting the boolean parameter to true: - - - -``` -CometChat.getUnreadMessageCountForAllGroups(hideMessagesFromBlockedUsers); -``` - - - - - - - -``` -CometChat.getUnreadMessageCountForAllGroups().then( - (array) => { - console.log("Message count fetched", array); - }, - (error) => { - console.log("Error in getting message count", error); - } -); -``` - - - - - -It returns a Array which will contain the GUIDs of the groups as the key and the unread message counts as the values. diff --git a/sdk/ionic-legacy/2.0/messaging-retrieve-conversations.mdx b/sdk/ionic-legacy/2.0/messaging-retrieve-conversations.mdx deleted file mode 100644 index 1abc9226d..000000000 --- a/sdk/ionic-legacy/2.0/messaging-retrieve-conversations.mdx +++ /dev/null @@ -1,154 +0,0 @@ ---- -title: "Retrieve Conversations" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -Conversations provide the last messages for every one-on-one and group conversation the logged-in user is a part of. This makes it easy for you to build a **Recent Chats** list. - -## Retrieve List of Conversations - -*In other words, as a logged-in user, how do I retrieve the latest conversations that I've been a part of?* - -In order to fetch the list of conversations, you can use the `ConversationsRequest` class. To use this class i.e to create an object of the `ConversationsRequest` class, you need to use the `ConversationsRequestBuilder` class. The `ConversationsRequestBuilder` class allows you to set the parameters based on which the conversations are to be fetched. - -The `ConversationsRequestBuilder` class allows you to set the below parameters: - -### Set Limit - -This method sets the limit i.e. the number of conversations that should be fetched in a single iteration. - - - -```js -let limit = 30; -let conversationRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .build(); -``` - - - - - -### Set Conversation Type - -This method can be used to fetch user or group conversations specifically. The `conversationType` variable can hold one of the below two values: - -* user - Only fetches user conversation. -* group - Only fetches group conversations. - -If none is set, the list of conversations will include both user and group conversations. - - - -```js -let limit = 30; -let conversationType = "group"; -let conversationRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setConversationType(conversationType) - .build(); -``` - - - - - -Finally, once all the parameters are set to the builder class, you need to call the `build()` method to get the object of the `ConversationsRequest` class. - -Once you have the object of the `ConversationsRequest` class, you need to call the `fetchNext()` method. Calling this method will return a list of `Conversation` objects containing X number of users depending on the limit set. - -A Maximum of only 50 Conversations can be fetched at once. - - - -```js -let limit = 30; -let conversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .build(); - -conversationsRequest.fetchNext().then( - (conversationList) => { - console.log("Conversations list received:", conversationList); - }, - (error) => { - console.log("Conversations list fetching failed with error:", error); - } -); -``` - - - - - -The `Conversation` Object consists of the below fields: - -| Field | Information | -| ------------------ | ----------------------------------------------------------------- | -| conversationId | ID of the conversation. | -| conversationType | Type of conversation. (user/group) | -| lastMessage | Last message the conversation. | -| conversationWith | User or Group object containing the details of the user or group. | -| unreadMessageCount | Unread message count for the conversation. | - -## Retrieve Single Conversation - -*In other words, as a logged-in user, how do I retrieve a specific conversation?* - -In order to fetch a specific conversation, you can use the `getConversation` method. The `getConversation` method accepts two parameters. - -1. `conversationWith`: UID/GUID of the user/group whose conversation you want to fetch. -2. `conversationType`: The `conversationType` variable can hold one of the below two values: - -* user - Only fetches user conversation. -* group - Only fetches group conversations. - - - -```js -CometChat.getConversation("conversationWith", "conversationType").then( - (conversation) => { - console.log("conversation", conversation); - }, - (error) => { - console.log("error while fetching a conversation", error); - } -); -``` - - - - - -## Convert Messages to Conversations - -As per our [receive messages](/sdk/ionic-legacy/2.0/messaging-receive-messages) guide, for real-time messages, you will always receive `Message` objects and not `Conversation` objects. Thus, you will need a mechanism to convert the Message object to `Conversation` object. You can use the `getConversationFromMessage(BaseMessage message)` of the `CometChatHelper` class. - - - -```js -CometChat.CometChatHelper.getConversationFromMessage(message).then( - (conversation) => { - console.log("Conversation Object", conversation); - }, - (error) => { - console.log("Error while converting message object", error); - } -); -``` - - - - - - - -While converting `Message` object to `Conversation` object, the `unreadMessageCount` will not be available in the `Conversation` object. As this is for the real-time events, the unread message count needs to be managed in your client-side code. - - diff --git a/sdk/ionic-legacy/2.0/messaging-send-message.mdx b/sdk/ionic-legacy/2.0/messaging-send-message.mdx deleted file mode 100644 index 0b323eb2f..000000000 --- a/sdk/ionic-legacy/2.0/messaging-send-message.mdx +++ /dev/null @@ -1,391 +0,0 @@ ---- -title: "Send A Message" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -Using CometChat, you can send three types of messages: - -1. A [text message](/sdk/ionic-legacy/2.0/messaging-send-message#text-message), the most common and standard message type. -2. A [media message](/sdk/ionic-legacy/2.0/messaging-send-message#media-message), for sending photos, videos and files. -3. A [custom message](/sdk/ionic-legacy/2.0/messaging-send-message#custom-message), for sending completely custom data using JSON structures. - -You can also send metadata along with a text, media or custom message. Think, for example, if you'd want to share the user's location with every message, you can use the metadata field - -## Text Message - -*In other words, as a sender, how do I send a text message?* - -To send a text message to a single user or group, you need to use the `sendMessage()` method and pass a `TextMessage` object to it. - - - -``` -let receiverID = "UID"; -let messageText = "Hello world!"; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let textMessage = new CometChat.TextMessage( - receiverID, - messageText, - receiverType -); - -CometChat.sendMessage(textMessage).then( - (message) => { - console.log("Message sent successfully:", message); - }, - (error) => { - console.log("Message sending failed with error:", error); - } -); -``` - - - - -``` -let receiverID = "GUID"; -let messageText = "Hello world!"; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; -let textMessage = new CometChat.TextMessage( - receiverID, - messageText, - receiverType -); - -CometChat.sendMessage(textMessage).then( - (message) => { - console.log("Message sent successfully:", message); - }, - (error) => { - console.log("Message sending failed with error:", error); - } -); -``` - - - - - -The `TextMessage` class constructor takes the following parameters: - -| Parameter | Description | | -| ---------------- | ------------------------------------------------------------------------------------------------------------- | -------- | -| **receiverID** | `UID` of the user or `GUID` of the group receiving the message | Required | -| **messageText** | The text message | Required | -| **receiverType** | The type of the receiver- `CometChatConstants.RECEIVER_TYPE_USER` or `CometChatConstants.RECEIVER_TYPE_GROUP` | Required | - -When a text message is sent successfully, the response will include a `TextMessage` object which includes all information related to the sent message. - -### Add Metadata - -To send custom data along with a text message, you can use the `setMetadata` method and pass a `JSONObject` to it. - - - -``` -let receiverID = "UID"; -let messageText = "Hello World!"; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let textMessage = new CometChat.TextMessage( - receiverID, - messageText, - receiverType -); - -let metadata = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002", -}; - -textMessage.setMetadata(metadata); - -CometChat.sendMessage(textMessage).then( - (message) => { - console.log("Message sent successfully:", message); - }, - (error) => { - console.log("Message sending failed with error:", error); - } -); -``` - - - - -``` -let receiverID = "GUID"; -let messageText = "Hello World!"; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; -let textMessage = new CometChat.TextMessage( - receiverID, - messageText, - receiverType -); - -var metadata = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002", -}; - -textMessage.setMetadata(metadata); - -CometChat.sendMessage(textMessage).then( - (message) => { - console.log("Message sent successfully:", message); - }, - (error) => { - console.log("Message sending failed with error:", error); - } -); -``` - - - - - -## Media Message - -*In other words, as a sender, how do I send a media message like photos, videos & files?* - -To send a media message to any user or group, you need to use the `sendMediaMessage()` method and pass a `MediaMessage` object to it. - -Getting file Object: You can use different ionic packages for sending media messages. We demonstrate how to send images using CometChat. - - - -```js -ImagePicker.showImagePicker(options, (response) => { -if (response.didCancel) { - console.log('User cancelled photo picker'); -} else if (response.error) { - console.log('ImagePicker Error: ', response.error); -} else if (response.customButton) { - console.log('User tapped custom button: ', response.customButton); -} else { - console.log('ImagePicker Response: ', response); - if (Platform.OS === 'ios' && response.fileName != undefined) { - var ext = response.fileName.split('.')[1].toLowerCase(); - var type = this.getMimeType(ext); - var name = response.fileName; - } else { - var type = response.type; - var name = 'Camera_001.jpeg'; - } - var file = { - name: Platform.OS === "android" ? response.fileName : name, - type: Platform.OS === "android" ? response.type : type, - uri: Platform.OS === "android" ? response.uri : response.uri.replace("file://", ""), - } - console.log('file: ', file); - this.setState({ mediaMsg: file }) -} -}); -} -``` - - - - - - - -``` -let receiverID = "UID"; -let messageType = CometChat.MESSAGE_TYPE.FILE; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let mediaMessage = new CometChat.MediaMessage( - receiverID, - this.state.mediaMsg, - messageType, - receiverType -); - -CometChat.sendMediaMessage(mediaMessage).then( - (message) => { - console.log("Media message sent successfully", message); - }, - (error) => { - console.log("Media message sending failed with error", error); - } -); -``` - - - - -``` -let receiverID = "GUID"; -let messageType = CometChat.MESSAGE_TYPE.FILE; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; -let mediaMessage = new CometChat.MediaMessage( - receiverID, - this.state.mediaMsg, - messageType, - receiverType -); - -CometChat.sendMediaMessage(mediaMessage).then( - (message) => { - console.log("Media message sent successfully", message); - }, - (error) => { - console.log("Media message sending failed with error", error); - } -); -``` - - - - - -The `MediaMessage` class constructor takes the following parameters: - -| Parameter | Description | | -| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -| **receiverId** | The `UID` or `GUID` of the recipient. | Required | -| **file** | The file object to be sent | Required | -| **messageType** | The type of the message that needs to be sent which in this case can be:
1.`CometChat.MESSAGE_TYPE.IMAGE`
2.`CometChat.MESSAGE_TYPE.VIDEO`
3.`CometChat.MESSAGE_TYPE.AUDIO`
4.`CometChat.MESSAGE_TYPE.FILE` | Required | -| **receiverType** | The type of the receiver to whom the message is to be sent.
`1. CometChat.RECEIVER_TYPE.USER`
`2. CometChat.RECEIVER_TYPE.GROUP` | Required | - -When a media message is sent successfully, the response will include a `MediaMessage` object which includes all information related to the sent message. If you wish to send a caption or some text along with the Media Message, you can use the `caption field` provided by the MediaMessage class. While sending the Media Message use the `setCaption()` method and at the receiver end in the MediaMessage object you can use the `getCaption()` method to obtain the caption shared. - -### Add Metadata - -To send custom data along with a media message, you can use the `setMetadata` method and pass a `JSONObject` to it. - - - -``` -var metadata = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002", -}; - -mediaMessage.setMetadata(metadata); -``` - - - - - -### Add Caption(Text along with Media Message) - -To send a caption with a media message, you can use `setCaption` method and pass text to it. - - - -``` -var caption = "Random Caption"; - -mediaMessage.setCaption(caption); -``` - - - - - -## Custom Message - -*In other words, as a sender, how do I send a custom message like location co-ordinates?* - -CometChat allows you to send custom messages which are neither text nor media messages. - -In order to send a custom message, you need to use the `sendCustomMessage()` method. - -The `sendCustomMessage()` methods takes an object of the `CustomMessage` which can be obtained using the below constructor. - - - -``` -var customMessage = new CometChat.CustomMessage( - receiverID, - receiverType, - customType, - customData -); -``` - - - - - -The above constructor, helps you create a custom message with the message type set to whatever is passed to the constructor and the category set to `custom`. - -The parameters involved are: - -1. `receiverId` - Unique id of the user or group to which the message is to be sent. -2. `receiverType` - Type of the receiver i.e user or group -3. `customType` - custom message type that you need to set -4. `customData` - The data to be passed as the message in the form of a JSONObject. - -You can also use the subType field of the `CustomMessage` class to set a specific type for the custom message. This can be achieved using the `setSubtype()` method. - -Once the object of `CustomMessage` class is ready you can send the custom message using the `sendCustomMessage()` method. - - - -```js -let receiverID = "UID"; -let customData = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002", -}; -let customType = "location"; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let customMessage = new CometChat.CustomMessage( - receiverID, - receiverType, - customType, - customData -); - -CometChat.sendCustomMessage(customMessage).then( - (message) => { - console.log("custom message sent successfully", message); - }, - (error) => { - console.log("custom message sending failed with error", error); - } -); -``` - - - - -```js -let receiverID = "GUID"; -let customData = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002", -}; -let customType = "location"; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; -let customMessage = new CometChat.CustomMessage( - receiverID, - receiverType, - customType, - customData -); - -CometChat.sendCustomMessage(customMessage).then( - (message) => { - console.log("custom message sent successfully", message); - }, - (error) => { - console.log("custom message sending failed with error", error); - } -); -``` - - - - - -The above sample explains how custom messages can be used to share the location with a user. The same can be achieved for groups. - -On success, you will receive an object of the `CustomMessage` class. diff --git a/sdk/ionic-legacy/2.0/messaging-typing-indicators.mdx b/sdk/ionic-legacy/2.0/messaging-typing-indicators.mdx deleted file mode 100644 index 86d243c0d..000000000 --- a/sdk/ionic-legacy/2.0/messaging-typing-indicators.mdx +++ /dev/null @@ -1,126 +0,0 @@ ---- -title: "Typing Indicators" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Send a Typing Indicator - -*In other words, as a sender, how do I let the recipient(s) know that I'm typing?* - -### Start Typing - -You can use the `startTyping()` method to inform the receiver that the logged in user has started typing. The receiver will receive this information in the `onTypingStarted()` method of the `MessageListener` class. In order to send the typing indicator, you need to use the `TypingIndicator` class. - - - -``` -let receiverId = "UID"; -let receiverType = CometChat.RECEIVER_TYPE.USER; - -let typingNotification = new CometChat.TypingIndicator( - receiverId, - receiverType -); -CometChat.startTyping(typingNotification); -``` - - - - -``` -let receiverId = "GUID"; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; - -let typingNotification = new CometChat.TypingIndicator( - receiverId, - receiverType -); -CometChat.startTyping(typingNotification); -``` - - - - - -### Stop Typing - -You can use the `endTyping()` method to inform the receiver that the logged in user has stopped typing. The receiver will receive this information in the `onTypingEnded()` method of the `MessageListener` class. In order to send the typing indicator, you need to use the `TypingIndicator` class. - - - -``` -let receiverId = "UID"; -let receiverType = CometChat.RECEIVER_TYPE.USER; - -let typingNotification = new CometChat.TypingIndicator( - receiverId, - receiverType -); -CometChat.endTyping(typingNotification); -``` - - - - -``` -let receiverId = "GUID"; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; - -let typingNotification = new CometChat.TypingIndicator( - receiverId, - receiverType -); -CometChat.endTyping(typingNotification); -``` - - - - - - - -You can use the `metadata` field of the `TypingIndicator` class to pass additional data along with the typing indicators. The metadata field is a JSONObject and can be set using the `setMetadata()` method of the `TypingIndicator` class. This data will be received at the receiver end and can be obtained using the `getMetadata()` method. - - - -## Real-time Typing Indicators - -*In other words, as a recipient, how do I know when someone is typing?* - -You will receive the typing indicators in the `onTypingStarted()` and the `onTypingEnded()` method of the registered `MessageListener` class. - - - -``` -let listenerId = "UNIQUE_LITENER_ID"; - -CometChat.addMessageListener( - listenerId, - new CometChat.MessageListener({ - onTypingStarted: (typingIndicator) => { - console.log("Typing started :", typingIndicator); - }, - onTypingEnded: (typingIndicator) => { - console.log("Typing ended :", typingIndicator); - }, - }) -); -``` - - - - - -The `TypingIndicator` class consists of the below parameters: - -| Parameter | Information | -| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **sender** | An object of the `User` class holding all the information. related to the sender of the typing indicator. | -| **receiverId** | Unique Id of the receiver. This can be the Id of the group or the user the typing indicator is sent to. | -| **receiverType** | This parameter indicates if the typing indicator is to be sent to a user or a group. The possible values are: 1. `CometChatConstants.RECEIVER_TYPE_USER` 2. `CometChatConstants.RECEIVER_TYPE_GROUP` | -| **metadata** | A JSONObject to provider additional data. | diff --git a/sdk/ionic-legacy/2.0/messaging.mdx b/sdk/ionic-legacy/2.0/messaging.mdx deleted file mode 100644 index 47c602d06..000000000 --- a/sdk/ionic-legacy/2.0/messaging.mdx +++ /dev/null @@ -1,16 +0,0 @@ ---- -title: "Messaging" -sidebarTitle: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -Messaging is one of the core features of CometChat. We've thoughtfully created methods to help you send, receive and fetch message history. - -At the minimum, you must add code for [sending messages](/sdk/ionic-legacy/2.0/messaging-send-message) and [receiving messages](/sdk/ionic-legacy/2.0/messaging-receive-messages) - -Once you've implemented that, you can proceed to more advanced features like [typing indicators](/sdk/ionic-legacy/2.0/messaging-typing-indicators) and [delivery & read receipts](/sdk/ionic-legacy/2.0/messaging-receipts). diff --git a/sdk/ionic-legacy/2.0/overview.mdx b/sdk/ionic-legacy/2.0/overview.mdx deleted file mode 100644 index 5201b347b..000000000 --- a/sdk/ionic-legacy/2.0/overview.mdx +++ /dev/null @@ -1,264 +0,0 @@ ---- -title: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -This guide demonstrates how to add chat to a Cordova/ionic application using CometChat. Before you begin, we strongly recommend you read the [Key Concepts](/sdk/ionic-legacy/2.0/key-concepts) guide. - -#### I want to integrate with my app - -1. [Get your application keys](overview#get-your-application-keys) -2. [Add the CometChat dependency](overview#add-the-cometchat-dependency) -3. [Initialize CometChat](overview#initialize-cometchat) -4. [Register and Login your user](overview#register-and-login-your-user) - -#### I want to explore a sample app (includes UI) - -Open the app folder in your favourite code editor and follow the steps mentioned in the `README.md` file - -[](https://github.com/cometchat/cordova-ionic-chat-app) - -[Cordova Ionic Sample App](https://github.com/cometchat/cordova-ionic-chat-app) - -### Get your Application Keys - -[Signup for CometChat](https://app.cometchat.com) and then: - -1. Create a new app -2. Head over to the **API & Auth Keys** section and note the **Auth Key**, **App ID** & **Region** - -## Add the CometChat Dependency - -Install the package as NPM module: - - - -```js -npm install @cometchat-pro/cordova-ionic-chat@2.4.1 -``` - - - - - - - -v2.4+ onwards, Voice & Video Calling functionality has been moved to a separate library. In case you plan to use the calling feature, please install the Calling dependency (@cometchat-pro/ionic-calls). - -`npm install @cometchat-pro/ionic-calls@2.1.2--save` - -The calling component requires some configuration. Please follow the steps mentioned [here](/sdk/ionic-legacy/2.0/overview#calling-component-configuration). - - - - - -The Calling Component (@cometchat-pro/ionic-calls) is a capacitor plugin so it won't work in a Cordova project. - - - -## Calling Component Configuration - -**Android** - -Goto `./android` folder and open **project-level** build Gradle file and add all repository URLs in the `repositories` block under the `allprojects` section.\*\* \*\* - - - -```gradle -allprojects { - repositories { - maven { - url "https://dl.cloudsmith.io/public/cometchat/cometchat-pro-android/maven/" - } - } -} -``` - - - - - -You also need to update the minimum SDK version to `24`. You can update the minSDKVersion in the `variables.gradle` file located in the `android` folder. - - - -```gradle -minSdkVersion = 24; -``` - - - - - -In the Main activity you need to map Capacitor class add(Calling.class); - - - -```java -package io.ionic.starter; - -import android.os.Bundle; - -import com.cometchat.calling.Calling; //Add this line - -import com.getcapacitor.BridgeActivity; -import com.getcapacitor.Plugin; - -import java.util.ArrayList; - -public class MainActivity extends BridgeActivity { -@Override -public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - this.init(savedInstanceState, new ArrayList>() {{ - add(Calling.class); - }}); - } -} -``` - - - - - -**iOS**: - -Please update the minimum target version in the Podfile. Goto ./ios folder and open the Podfile. In the Podfile update the platform version to `11.0`. - - - -``` -platform :ios, '11.0' -``` - - - - - -Open the `ios/App` folder and run `pod install` this will create an `App.xcworkspace` open this and run the app. - -## Initialize CometChat - -The `init()` method initialises the settings required for CometChat. The `init()` method takes the below parameters: - -1. appId - Your CometChat App ID -2. appSettings - An object of the AppSettings class can be created using the AppSettingsBuilder class. The region field is mandatory and can be set using the `setRegion()` method. - -The `AppSettings` class allows you to configure two settings: - -* Region: The region where you app was created. -* [Presence Subscription](/sdk/ionic-legacy/2.0/user-presence) - -You need to call `init()` before calling any other method from CometChat. We suggest you call the `init()` method on app startup, preferably in the `index.js` file. - - - -```js -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); - } -); -``` - - - - - -Make sure you replace the `APP_ID` with your CometChat **App ID** and `REGION` with your **App Region** in the above code. - -## Register and Login your user - -Once initialization is successful, you will need to create a user. To create users on the fly, you can use the `createUser()` method. This method takes a `User` object and the `Auth Key` as input parameters and returns the created `User` object if the request is successful. - - - -```js -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); - } -); -``` - - - - - -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. - -We recommend you call the CometChat `login()` method once your user logs into your app. The `login()` method needs to be called only once. - - - -```js -var UID = "cometchat-uid-1"; -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 }); - } - ); - } - }, - (error) => { - console.log("Some Error Occured", { error }); - } -); -``` - - - - - -Make sure you replace the `AUTH_KEY` with your CometChat **Auth Key** in the above code. - - -**Sample Users** - -We have set-up 5 users for testing having UIDs: `cometchat-uid-1`, `cometchat-uid-2`, `cometchat-uid-3`, `cometchat-uid-4` and `cometchat-uid-5`. - - - -The `login()` method returns the `User` object containing all the information of the logged-in user. - - - -UID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed. - - diff --git a/sdk/ionic-legacy/2.0/rate-limits.mdx b/sdk/ionic-legacy/2.0/rate-limits.mdx deleted file mode 100644 index 66e804f6a..000000000 --- a/sdk/ionic-legacy/2.0/rate-limits.mdx +++ /dev/null @@ -1,53 +0,0 @@ ---- -title: "Rate Limits" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -### CometChat Pro REST API Rate Limits - - - -The rate limits below are for general applications. Rate limits can be adjusted on a per need basis, depending on your use-case and plan. - - - -1. App Level Rate Limit - request per app per min -2. APIKey Rate Limit - request per APIKey per min -3. User Level Rate Limit - request per login per min - - - -The rate limits will be cumulative i.e. Suppose the rate limit for core operations is 100/min. Then the customer can either login, join group or leave group etc. for total 100/min. - - - -| `Rate Limiting Groups` | `1K` | `10K` | `25K` | `50K` | `100k` | -| ------------------------ | ------- | ------- | ------- | ------- | ------- | -| Per APIKey Rate Limit | 1k req | 1k req | 1k req | 1k req | 1k req | -| Per AuthToken Rate Limit | 100 req | 100 req | 100 req | 100 req | 100 req | -| Create User | 60 req | 60 req | 60 req | 60 req | 60 req | -| Create Group 60 req | 60 req | 60 req | 60 req | 60 req | 60 req | -| Initiate Call | 10 req | 10 req | 10 req | 10 req | 10 req | - -## What happens when rate limit is reached ? - -The request isn't processed and a response is sent containing a 429 response code. Along with the response code there will be couple of headers sent which specifies the time in seconds that you must wait before you can try request again. - -`Retry-After: 15` - -`X-Rate-Limit-Reset: 1625143246` - -## Is there any endpoint that returns rate limit of all resources ? - -No, we don't provide a rate-limit endpoint. - -However, we do provide the following response headers that you can use to confirm the app's current rate limit and monitor the number of requests remaining in the current minute: - -`X-Rate-Limit: 700` - -`X-Rate-Limit-Remaining: 699` diff --git a/sdk/ionic-legacy/2.0/resources-all-real-time-listeners.mdx b/sdk/ionic-legacy/2.0/resources-all-real-time-listeners.mdx deleted file mode 100644 index ca5cde833..000000000 --- a/sdk/ionic-legacy/2.0/resources-all-real-time-listeners.mdx +++ /dev/null @@ -1,191 +0,0 @@ ---- -title: "All Real Time Listeners" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -CometChat provides 4 listeners viz. - -1. [User Listener](/sdk/ionic-legacy/2.0/resources-all-real-time-listeners#user-listener) -2. [Group Listener](/sdk/ionic-legacy/2.0/resources-all-real-time-listeners#group-listener) -3. [Message Listener](/sdk/ionic-legacy/2.0/resources-all-real-time-listeners#message-listener) - -## User Listener - -The `UserListener` class provides you with live events related to users. Below are the callback methods provided by the `UserListener` class. - -| Method | Information | -| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **onUserOnline(User user)** | This method is triggered when a user comes online and is available to chat. The details of the user can be obtained from the user object received as the method parameter. | -| **onUserOffline(User user)** | This method is triggered when a user goes offline. The details of the user can be obtained from the User object received as the parameter. | - -To add the `UserListener`, you need to use the `addUserListener()` method provided by the `CometChat` class. - - - -```js -var listenerID = "UNIQUE_LISTENER_ID"; -CometChat.addUserListener( -listenerID, -new CometChat.UserListener({ - onUserOnline: onlineUser => { - /* when someuser/friend comes online, user will be received here */ - console.log("On User Online:", { onlineUser }); - }, - onUserOffline: offlineUser => { - /* when someuser/friend went offline, user will be received here */ - console.log("On User Offline:", { offlineUser }); - } -}) -); -``` - - - - - -where `UNIQUE_LISTENER_ID` is the unique identifier for the listener. Please make sure that no two listeners are added with the same listener id as this could lead to unexpected behavior resulting in loss of events. - -Once the `UserListener` is not in use, you need to remove the listener using the `removeUserListener()` method which takes the id of the listener to be removed as the parameter. - - - -```js -CometChat.removeUserListener(UNIQUE_LISTENER_ID) -``` - - - - - -## Group Listener - -The `GroupListener` class provides you with all the real-time events related to groups. Below are the callback methods provided by the `GroupListener` class. - -| Method | Information | -| -------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| **onGroupMemberJoined(Action action, User joinedUser, Group joinedGroup)** | This method is triggered when a user joins any group. All the members present in the group will receive this event. | -| **onGroupMemberLeft(Action action, User leftUser, Group leftGroup)** | This method is triggered when a user who was a member of any group leaves the group. All the members of the group receive this event. | -| **onGroupMemberKicked(Action action, User kickedUser, User kickedBy, Group kickedFrom)** | This method is triggered when a user is kicked from a group. All the members including the user receive this event | -| **onGroupMemberBanned(Action action, User bannedUser, User bannedBy, Group bannedFrom)** | This method is triggered when a user is banned from a group. All the members including the user receive this event | -| **onGroupMemberUnbanned(Action action, User unbannedUser, User unbannedBy, Group unbannedFrom)** | This method is triggered when a user is banned from a group. All the members of the group receive this event. | -| **onGroupMemberScopeChanged(Action action, User changedUser, String newScope, String oldScope, Group changedGroup)** | This method is triggered when the scope of any Group Member has been changed. All the members that are a part of that group receive this event | -| **onMemberAddedToGroup(Action action, User userAdded, User addedBy, Group addedTo)** | This method is triggered when a user is added to any group. All the members including the user himself receive this event. | - -To add the `GroupListener`, you need to use the `addGroupListener()` method provided by the `CometChat` class. - - - -```js -CometChat.addGroupListener( -"UNIQUE_LISTENER_ID", -new CometChat.GroupListener({ - onGroupMemberJoined: (message, joinedUser, joinedGroup) => { - console.log("onGroupMemberJoined", { message, joinedUser, joinedGroup }); - }, - onGroupMemberLeft: (message, leftUser, leftGroup) => { - console.log("onGroupMemberLeft", { message, leftUser, leftGroup }); - }, - onGroupMemberKicked: (message, kickedUser, kickedBy, kickedFrom) => { - console.log("onGroupMemberKicked", { message, kickedUser, kickedBy, kickedFrom }); - }, - onGroupMemberBanned: (message, bannedUser, bannedBy, bannedFrom) => { - console.log("onGroupMemberBanned", { message, bannedUser, bannedBy, bannedFrom }); - }, - onGroupMemberUnbanned: (message, unbannedUser, unbannedBy, unbannedFrom) => { - console.log("onGroupMemberUnbanned", { message, unbannedUser, unbannedBy, unbannedFrom }); - }, - onGroupMemberScopeChanged: (message, changedUser, newScope, oldScope, changedGroup) => { - console.log("onGroupMemberScopeChanged", { message, changedUser, newScope, oldScope, changedGroup }); - }, - onMemberAddedToGroup: (message, userAdded, addedby, addedTo) => { - console.log("onMemberAddedToGroup", { message, addedby, userAdded, addedTo }); - }, -}) -); -``` - - - - - -where `UNIQUE_LISTENER_ID` is the unique identifier for the listener. Please make sure that no two listeners are added with the same listener id as this could lead to unexpected behavior resulting in loss of events. - -Once the `GroupListener` is not in use, you need to remove the listener using the `removeGroupListener()` method which takes the id of the listener to be removed as the parameter. - - - -```js -CometChat.removeGroupListener(UNIQUE_LISTENER_ID) -``` - - - - - -## Message Listener - -The `MessageListener` class provides you with live events related to messages. Below are the callback methods provided by the `MessageListener` class. - -| Method | Information | -| ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------- | -| **onTextMessageReceived(TextMessage message)** | This event is triggered when a Text Message is received. | -| **onMediaMessageReceived(MediaMessage message)** | This event is triggered when a Media Message is received. | -| **onCustomMessageReceived(CustomMessage message)** | This event is triggered when a Custom Message is received. | -| **onTypingStarted(TypingIndicator typingIndicator)** | This event is triggered when a user starts typing in a user/group conversation | -| **onTypingEnded(TypingIndicator typingIndicator)** | This event is triggered when a user stops typing in a user/group conversation. | -| **onMessagesDelivered(MessageReceipt messageReceipt)** | This event is triggered when a set of messages are marked as delivered for any particular conversation. | -| **onMessagesRead(MessageReceipt messageReceipt)** | This event is triggered when a set of messages are marked as read for any particular conversation. | -| **onMessageEdited(BaseMessage message)** | This method is triggered when a particular message has been edited in a user/group conversation. | -| **onMessageDeleted(BaseMessage message)** | This event is triggered when a particular message is deleted in a user/group conversation. | - -To add the `MessageListener`, you need to use the `addMessageListener()` method provided by the `CometChat` class. - - - -```js -CometChat.addMessageListener( -"UNIQUE_LISTENER_ID", -new CometChat.MessageListener({ - onTextMessageReceived: textMessage => { - console.log("Text message received successfully", textMessage); - }, - onMediaMessageReceived: mediaMessage => { - console.log("Media message received successfully", mediaMessage); - }, - onCustomMessageReceived: customMessage => { - console.log("Custom message received successfully", customMessage); - }, - onMessagesDelivered: messageReceipt => { - console.log("Message Delivered", messageReceipt); - }, - onMessagesRead: messageReceipt => { - console.log("Message Read", messageReceipt); - }, - onTypingStarted: typingIndicator => { - console.log("Typing Started", typingIndicator); - }, - onTypingEnded: typingIndicator => { - console.log("Typing Ended", typingIndicator); - }, - onMessagesDeleted: message => { - console.log("Message Delted", message); - }, - onMessagesEdited: message => { - console.log("Message Edited", message); - } -}) -); -``` - - - - - -where `UNIQUE_LISTENER_ID` is the unique identifier for the listener. Please make sure that no two listeners are added with the same listener id as this could lead to unexpected behavior resulting in loss of events. - -Once the `MessageListener` is not in use, you need to remove the listener using the `removeMessageListener()` method which takes the id of the listener to be removed as the parameter. diff --git a/sdk/ionic-legacy/2.0/resources-upgrading-from-v1.mdx b/sdk/ionic-legacy/2.0/resources-upgrading-from-v1.mdx deleted file mode 100644 index ab44e35ca..000000000 --- a/sdk/ionic-legacy/2.0/resources-upgrading-from-v1.mdx +++ /dev/null @@ -1,164 +0,0 @@ ---- -title: "Upgrading From V1" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - - - - - -Upgrading from v1.x to v2 is fairly simple. Below are the major changes that are released as a part of CometChat Pro v2: - -## Initialization - -The `CometChat.init()` method now takes an additional parameter. This parameter is an object of the `AppSettings` class. This object can be created by using the `AppSettingsBuilder` class. The `AppSettings` class provides the CometChat SDK with the below 2 details: - -1. **Region of your app**: The region of your app is the code of the region your app is hosted in. Currently, this can only hold one of the below two values: a. **eu** - If your app is hosted in Europe b. **us** - If your app is hosted in the United States of America. -2. [Presence Subscription](/sdk/ionic-legacy/2.0/user-presence) - - - -```js -//v1.x - -var appID = "APP_ID"; -CometChat.init(appID).then( -() => { - console.log("Initialization completed successfully"); -}, error => { - console.log("Initialization failed with error:", error); -} -); - -//v2.x - -var appId = "APP_ID"; -let cometChatSettings = new CometChat.AppSettingsBuilder() - .subscribePresenceForAllUsers() - .setRegion("us") - .build(); -CometChat.init(appId, cometChatSettings).then( -() => { - console.log("Initialization completed successfully"); -}, error => { - console.log("Initialization failed with error:", error); -} -); -``` - - - - - -## Text Message Constructor - -Since the only possible valid value the `messageType` parameter could take in the constructor was `CometChatConstants.MESSAGE_TYPE_TEXT(text)`, we have excluded the `messageType` parameter from the `TextMessage` constructor. - - - -```js -//v1.x - -var textMessage = new CometChat.TextMessage(receiverID, messageText, messageType, receiverType); - -//v2.x - -var textMessage = new CometChat.TextMessage(receiverID, messageText, receiverType); -``` - - - - - -## Mark a Message as Read - -In v1.x, for marking the messages as read, every message had to marked as read individually using the `CometChat.markMessageAsRead()` which took the entire message object as the input parameter. - -Starting v2.0, the method name has been changed to `markAsRead()` which takes the `messageId`, `receiverId`, and `receiverType` as input. This method, will mark all the messages before the provided messageId for the conversation with the specified `receiverId` as read. For more information, please check [here](/sdk/ionic-legacy/2.0/messaging-receipts#mark-messages-as-read). - - - -```js -//v1.x -CometChat.markMessageAsRead(message); - -//v2.x -CometChat.markAsRead(messageId, receiverId, receiverType); -``` - - - - - -## Receive Real Time Delivery & Read Receipts - -In v1.x, Real-time events for messages of a conversation being read or delivered can be obtained in the `onMessageRead()` and the `onMessageDelivered()` methods of the `MessageListener` class since in v1.x single messages would be marked as read. - -Starting v2.x, multiple messages are being read at a time. So the method names are changed a bit. `onMessageRead()` is changed to `onMessagesRead()` and `onMessageDelivered()` is changed to `onMessagesDelivered()`. - - - -```js -//v1.x - -let listenerId = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener( -"listenerId", -new CometChat.MessageListener({ - onMessageDelivered: messageReceipt => { - console.log("MessageDeliverd", { messageReceipt }); - }, - onMessageRead: messageReceipt => { - console.log("MessageRead", { messageReceipt }); - } -}) -); - - -//v2.x - -let listenerId = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener( -"listenerId", -new CometChat.MessageListener({ - onMessagesDelivered: messageReceipt => { - console.log("MessageDeliverd", { messageReceipt }); - }, - onMessagesRead: messageReceipt => { - console.log("MessageRead", { messageReceipt }); - } -}) -); -``` - - - - - -## Retrieve List of Friends - -In v1.x to fetch only friends, you had to enable the Show only friends setting in the CometChat Dashboard. - -Starting v2.x, we have added a method in the UsersRequestBuilder to fetch only friends. This method accepts `boolean` and fetches only friends if it is set to `true` else it fetches all the users. By default, it is set to `false`. For more information, please check [here](/sdk/ionic-legacy/2.0/users-retrieve-users#friends-only). - - - -```js -//v2.x - -let usersRequest = new UsersRequest.UsersRequestBuilder() -.setLimit(limit) -.friendsOnly(true) -.build(); -``` - - - - diff --git a/sdk/ionic-legacy/2.0/resources.mdx b/sdk/ionic-legacy/2.0/resources.mdx deleted file mode 100644 index 144faf6af..000000000 --- a/sdk/ionic-legacy/2.0/resources.mdx +++ /dev/null @@ -1,16 +0,0 @@ ---- -title: "Resources" -sidebarTitle: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -We have a number of resources that will help you while integrating CometChat in your app. - -You can begin with the all [all real-time listeners](/sdk/ionic-legacy/2.0/resources-all-real-time-listeners) guide. - -If you're upgrading from v1, we recommend reading our [upgrading from v1](/sdk/ionic-legacy/2.0/resources-upgrading-from-v1) guide. diff --git a/sdk/ionic-legacy/2.0/setup.mdx b/sdk/ionic-legacy/2.0/setup.mdx deleted file mode 100644 index b4b925b09..000000000 --- a/sdk/ionic-legacy/2.0/setup.mdx +++ /dev/null @@ -1,170 +0,0 @@ ---- -title: "Setup" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Get your Application Keys - -[Signup for CometChat](https://app.cometchat.com) and then: - -1. Create a new app -2. Head over to the **API & Auth Keys** section and note the **Auth Key**, **App ID** & **Region** - -## Add the CometChat Dependency - -Install the package as NPM module: - - - -```js -npm install @cometchat-pro/cordova-ionic-chat@2.4.1 --save -``` - - - - - - - -v2.4+ onwards, Voice & Video Calling functionality has been moved to a separate library. In case you plan to use the calling feature, please install the Calling dependency (@cometchat-pro/ionic-calls). - -`npm install @cometchat-pro/ionic-calls@2.1.2--save` - -The calling component requires some configuration. Please follow the steps mentioned [here](/sdk/ionic-legacy/2.0/setup#calling-component-configuration). - - - - - -The Calling Component (@cometchat-pro/ionic-calls) is a capacitor plugin so it won't work in a Cordova project. - - - -## Calling Component Configuration - -**Android** - -Goto `./android` folder and open **project-level** build Gradle file and add all repository URLs in the `repositories` block under the `allprojects` section. - - - -```gradle -allprojects { -repositories { - maven { - url "https://dl.cloudsmith.io/public/cometchat/cometchat-pro-android/maven/" - } -} -} -``` - - - - - -You also need to update the minimum SDK version to `24`. You can update the minSDKVersion in the `variables.gradle` file located in the `android` folder. - - - -```gradle -minSdkVersion = 24 -``` - - - - - -In the Main activity you need to map Capacitor class add(Calling.class); - - - -```java -package io.ionic.starter; - -import android.os.Bundle; - -import com.cometchat.calling.Calling; //Add this line - -import com.getcapacitor.BridgeActivity; -import com.getcapacitor.Plugin; - -import java.util.ArrayList; - -public class MainActivity extends BridgeActivity { -@Override -public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - this.init(savedInstanceState, new ArrayList>() {{ - add(Calling.class); - }}); -} -} -``` - - - - - -**iOS**: - -Please update the minimum target version in the Podfile. Goto ./ios folder and open the Podfile. In the Podfile update the platform version to `11.0`. - - - -``` -platform :ios, '11.0' -``` - - - - - -Open the `ios/App` folder and run `pod install` this will create an `App.xcworkspace` open this and run the app. - -## Initialize CometChat - -The `init()` method initialises the settings required for CometChat. The `init()` method takes the below parameters: - -1. appId - Your CometChat App ID -2. appSettings - An object of the AppSettings class can be created using the AppSettingsBuilder class. The region field is mandatory and can be set using the `setRegion()` method. - -The `AppSettings` class allows you to configure two settings: - -* Region: The region where you app was created. -* [Presence Subscription](/sdk/ionic-legacy/2.0/user-presence) - -You need to call `init()` before calling any other method from CometChat. We suggest you call the `init()` method on app startup, preferably in the `index.js` file. - - - -```js -let appID = "APP_ID"; -let region = "REGION"; -let cometChatSettings = new CometChat.AppSettingsBuilder() - .subscribePresenceForAllUsers() - .setRegion(region) - .build(); -CometChat.init(appID,cometChatSettings).then( - () => { - console.log("Initialization completed successfully"); - }, error => { - console.log("Initialization failed with error:", error); - } -); -``` - - - - - -Make sure you replace the `APP_ID` with your CometChat **App ID** and `REGION` with your **App Region** in the above code. - -| Parameter | Description | -| ---------- | ----------------------------------- | -| appID | CometChat App ID | -| appSetting | An object of the AppSettings class. | diff --git a/sdk/ionic-legacy/2.0/threaded-messages.mdx b/sdk/ionic-legacy/2.0/threaded-messages.mdx deleted file mode 100644 index a04a6f3b4..000000000 --- a/sdk/ionic-legacy/2.0/threaded-messages.mdx +++ /dev/null @@ -1,174 +0,0 @@ ---- -title: "Threaded Messages" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -Messages that are started from a particular message are called Threaded messages or simply threads. Each Thread is attached to a message which is the Parent message for that thread. - -## Send Message in a Thread - -As mentioned in the [Send a Message](/sdk/ionic-legacy/2.0/messaging-send-message) section. You can either send a message to a User or a Group based on the `receiverType` and the UID/GUID specified for the message. A message can belong to either of the below types: - -1. Text Message -2. Media Message -3. Custom Message. - -Any of the above messages can be sent in a thread. As mentioned, a thread is identified based on the Parent message. So while sending a message the `parentMessageId` must be set for the message to indicate that the message to be sent needs to be a part of the thread with the specified `parentMessageId`. - -This can be achieved using the `setParentMessageId()` method provided by the object of the `TextMessage`, `MediaMessage` and `CustomMessage` class. The id specified in the `setParentMessageId()` method maps the message sent to the particular thread. - -**Example to Send a Text Message in a thread in a user conversation.** - - - -``` -let textMessage = new CometChat.TextMessage( - UID, - "Hello", - CometChat.RECEIVER_TYPE.USER -); -textMessage.setParentMessageId(100); - -CometChat.sendMessage(textMessage).then( - (message) => { - console.log("Message sent successfully", message); - }, - (err) => { - console.log("err", err); - } -); -``` - - - - - -The above snippet shows how a message with the text "Hello" can be sent in the thread with `parentMessageId` 100. - -Similarly, using the `setparentMessageId()` method, Media and Custom Messages can be sent in threads too. - -### Receiving Real-Time Messages - -The procedure to receive real-time messages is exactly the same as mentioned in the [Receive Messages](/sdk/ionic-legacy/2.0/messaging-receive-messages). This can be achieved using the `MessageListener` class provided by the SDK. - -To add a MessageListener, you can use the `addMessageListener()` method of the SDK. The only thing that needs to be checked is if the received message belongs to the active thread. This can be done using the `parentMessageId` field of the message object. - - - -``` -var listenerID = "UNIQUE_LISTENER_ID"; -var activeThreadId = 100; - -CometChat.addMessageListener( - listenerID, - new CometChat.MessageListener({ - onTextMessageReceived: (textMessage) => { - if (textMessage.getParentMessageId() == activeThreadId) { - console.log("Text message received for active thread.", textMessage); - } - }, - onMediaMessageReceived: (mediaMessage) => { - if (mediaMessage.getParentMessageId() == activeThreadId) { - console.log("Media message received for active thread.", textMessage); - } - }, - onCustomMessageReceived: (customMessage) => { - if (customMessage.getParentMessageId() == activeThreadId) { - console.log("Custom message received for active thread.", textMessage); - } - }, - }) -); -``` - - - - - -### Fetch all the messages for any particular thread. - -You can fetch all the messages belonging to a particular thread by using the `MessagesRequest` class. In order to get an object of the `MessagesRequest` class, you need to use the `MessagesRequestBuilder` class. and use the `setParentMessageId()` method of the `MessagesRequestBuilder` to inform the SDK that you only need the messages belonging to the thread with the specified parentMessageId. - -Once you have the object of the `MessagesRequest` class, you need to call the `fetchPrevious()` method to get the latest messages in the thread. In one integration, a maximum of 100 messages can be fetched. If you wish to fetch the next set of messages, you need to call the `fetchPrevious()` method again on the same object. - - - -``` -let limit = 30; -let parentMessageId = 1; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setLimit(limit) - .setParentMessageId(parentMessageId) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - console.log("Messages for thread fetched successfully", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -## Avoid Threaded Messages in User/Group Conversations - -While fetching messages for normal user/group conversations using the `MessagesRequest`, the threaded messages by default will be a part of the list of messages received. In order to exclude the threaded messages from the list of user/group messages, you need to use the `hideReplies()` method of the `MessagesRequestBuilder` class. This method takes a boolean argument which when set to true excludes the messages belonging to threads from the list of messages. - - - -```js -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .hideReplies(true) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - console.log("Messages for thread fetched successfully", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```js -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hideReplies(true) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - console.log("Messages for thread fetched successfully", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -The above snippet will return messages between the logged in user and `cometchat-uid-1` excluding all the threaded messages belonging to the same conversation. diff --git a/sdk/ionic-legacy/2.0/user-presence.mdx b/sdk/ionic-legacy/2.0/user-presence.mdx deleted file mode 100644 index 732aef8ee..000000000 --- a/sdk/ionic-legacy/2.0/user-presence.mdx +++ /dev/null @@ -1,83 +0,0 @@ ---- -title: "User Presence" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -User Presence helps us understand if a user is available to chat or not. - -## Real-time Presence - -*In other words, as a logged-in user, how do I know if a user is online or offline?* - -Based on the settings provided in the AppSettings class while initializing the SDK using the `init()` method, the logged-in user will receive the presence for the other users in the app. - -In the `AppSettings` class, you can set the type of Presence you wish to receive for that particular session of the app. - -For presence subscription, the AppSettingsBuilder provides 3 methods : - -* `subscribePresenceForAllUsers()` - This will inform the logged-in user when any user in the app comes online or goes offline. -* `subscribePresenceForRoles(Array roles)` - This will inform the logged-in user, only when the users with the specified roles come online or go offline. -* `subscribePresenceForFriends()` - This will inform the logged-in user, only when either of his friends come online or go offline. - -If none of the above methods are used, no presence will be sent to the logged-in user. - -You need to register the `UserListener` using the `addUserListener()` method where ever you wish to receive these events in. - - - -``` -let listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.addUserListener( - listenerID, - new CometChat.UserListener({ - onUserOnline: (onlineUser) => { - console.log("On User Online:", { onlineUser }); - }, - onUserOffline: (offlineUser) => { - console.log("On User Offline:", { offlineUser }); - }, - }) -); -``` - - - - - -| Parameter | Description | -| ------------ | --------------------------------------------- | -| `listenerID` | An ID that uniquely identifies that listener. | - -You will receive an object of the `User` class in the listener methods. - -We recommend you remove the listener once the activity or view is not in use. We suggest adding this method when not in use. - - - -``` -let listenerID = "UNIQUE_LISTENER_ID"; -CometChat.removeUserListener(listenerID); -``` - - - - - -## User List Presence - -*In other words, as a logged-in user, when I retrieve the user list, how do I know if a user is online/offline?* - -When you fetch the list of users, in the [User](/sdk/ionic-legacy/2.0/users-user-management#user-class) object, you will receive 2 fields - -1. `status` - This will hold either of the two values : - -* online - This indicates that the user is currently online and available to chat. -* offline - This indicates that the user is currently offline and is not available to chat. - -2. `lastActiveAt` - in case the user is offline, this field holds the timestamp of the time when the user was last online. This can be used to display the Last seen of the user if need be. diff --git a/sdk/ionic-legacy/2.0/users-block-users.mdx b/sdk/ionic-legacy/2.0/users-block-users.mdx deleted file mode 100644 index 7a1028c45..000000000 --- a/sdk/ionic-legacy/2.0/users-block-users.mdx +++ /dev/null @@ -1,151 +0,0 @@ ---- -title: "Block Users" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Block Users - -*In other words, as a logged-in user, how do I block a user from sending me messages?* - -You can block users using the `blockUsers()` method. Once any user is blocked, all the communication to and from the respective user will be completely blocked. You can block multiple users in a single operation. The `blockUsers()` method takes a `Array` as a parameter which holds the list of `UID's` to be blocked. - - - -``` -var usersList = ["UID1", "UID2", "UID3"]; -CometChat.blockUsers(usersList).then( - (list) => { - console.log("users list blocked", { list }); - }, - (error) => { - console.log("Blocking user fails with error", error); - } -); -``` - - - - - -It returns a Array which contains `UID's` as the keys and "success" or "fail" as the value based on if the block operation for the `UID` was successful or not. - -## Unblock Users - -*In other words, as a logged-in user, how do I unblock a user I previously blocked?* - -You can unblock the already blocked users using the `unblockUsers()` method. You can unblock multiple users in a single operation. The `unblockUsers()` method takes a `Array` as a parameter which holds the list of `UID's` to be unblocked. - - - -``` -var usersList = ["UID1", "UID2", "UID3"]; - -CometChat.unblockUsers(usersList).then( - (list) => { - console.log("users list unblocked", { list }); - }, - (error) => { - console.log("unblocking user fails with error", error); - } -); -``` - - - - - -It returns a Array which contains `UID's` as the keys and `success` or `fail` as the value based on if the unblock operation for the `UID` was successful or not. - -## Get List of Blocked Users - -*In other words, as a logged-in user, how do I get a list of all users I've blocked?* - -In order to fetch the list of blocked users, you can use the `BlockedUsersRequest` class. To use this class i.e to create an object of the `BlockedUsersRequest class`, you need to use the `BlockedUsersRequestBuilder` class. The `BlockedUsersRequestBuilder` class allows you to set the parameters based on which the blocked users are to be fetched. - -The `BlockedUsersRequestBuilder` class allows you to set the below parameters: - -### Set Limit - -This method sets the limit i.e. the number of blocked users that should be fetched in a single iteration. - - - -```js -let limit = 30; -let blockedUsersRequest = new BlockedUsersRequest.BlockedUsersRequestBuilder() - .setLimit(limit) - .build(); -``` - - - - - -### Set Search Keyword - -This method allows you to set the search string based on which the blocked users are to be fetched. - - - -```js -let limit = 30; -let searchKeyword = "super"; -let blockedUsersRequest = new BlockedUsersRequest.BlockedUsersRequestBuilder() - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - - -### Set Direction - -* CometChat.BlockedUsersRequest.DIRECTION.BLOCKED\_BY\_ME - This will ensure that the list of blocked users only contains the users blocked by the logged in user. -* CometChat.BlockedUsersRequest.DIRECTION.HAS\_BLOCKED\_ME - This will ensure that the list of blocked users only contains the users that have blocked the logged in user. -* CometChat.BlockedUsersRequest.DIRECTION.BOTH - This will make sure the list of users includes both the above cases. This is the default value for the direction variable if it is not set. - - - -```js -let limit = 30; -let blockedUsersRequest = new BlockedUsersRequest.BlockedUsersRequestBuilder() - .setLimit(limit) - .setDirection(CometChat.BlockedUsersRequest.DIRECTION.BLOCKED_BY_ME) - .build(); -``` - - - - - -Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the `BlockedUsersRequest` class. - -Once you have the object of the `BlockedUsersRequest` class, you need to call the `fetchNext()` method. Calling this method will return a list of `User` objects containing n number of blocked users where N is the limit set in the builder class. - - - -```js -var limit = 30; -var blockedUsersRequest = new CometChat.BlockedUsersRequestBuilder() - .setLimit(limit) - .build(); -blockedUsersRequest.fetchNext().then( - (userList) => { - console.log("Blocked user list received:", userList); - }, - (error) => { - console.log("Blocked user list fetching failed with error:", error); - } -); -``` - - - - diff --git a/sdk/ionic-legacy/2.0/users-retrieve-users.mdx b/sdk/ionic-legacy/2.0/users-retrieve-users.mdx deleted file mode 100644 index 81a2f2e12..000000000 --- a/sdk/ionic-legacy/2.0/users-retrieve-users.mdx +++ /dev/null @@ -1,260 +0,0 @@ ---- -title: "Retrieve Users" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Retrieve Logged In User Details - -You can get the details of the logged-in user using the `getLoggedInUser()` method. This method can also be used to check if the user is logged in or not. If the method returns `Promise` with reject callback, it indicates that the user is not logged in and you need to log the user into CometChat SDK. - - - -``` -var user = CometChat.getLoggedinUser().then( - (user) => { - console.log("user details:", { user }); - }, - (error) => { - console.log("error getting details:", { error }); - } -); -``` - - - - - -This method will return a `User` object containing all the information related to the logged-in user. - -## Retrieve List of Users - -In order to fetch the list of users, you can use the `UsersRequest` class. To use this class i.e to create an object of the `UsersRequest` class, you need to use the `UsersRequestBuilder` class. The `UsersRequestBuilder` class allows you to set the parameters based on which the users are to be fetched. - -The `UsersRequestBuilder` class allows you to set the below parameters: - -### Set Limit - -This method sets the limit i.e. the number of users that should be fetched in a single iteration. - - - -``` -let limit = 30; -let usersRequest = new CometChat.UsersRequestBuilder().setLimit(limit).build(); -``` - - - - - -### Set Search Keyword - -This method allows you to set the search string based on which the users are to be fetched. - - - -``` -let limit = 30; -let searchKeyword = "super"; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - - -### Set Status - -The status based on which the users are to be fetched. The status parameter can contain one of the below two values: - -* CometChat.USER\_STATUS.ONLINE - will return the list of only online users. -* CometChat.USER\_STATUS.OFFLINE - will return the list of only offline users. - -If this parameter is not set, will return all the available users. - - - -``` -let limit = 30; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setStatus(CometChat.USER_STATUS.ONLINE) - .build(); -``` - - - - - -### Hide Blocked Users - -This method is used to determine if the blocked users should be returned as a part of the user list. If set to true, the user list will not contain the users blocked by the logged in user. - - - -``` -let limit = 30; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .hideBlockedUsers(true) - .build(); -``` - - - - - -### Set Roles - -This method allows you to fetch the users based on multiple roles. - - - -``` -let limit = 30; -let roles = ["default", "dev"]; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setRoles(roles) - .build(); -``` - - - - - -### Friends Only - -This property when set to true will return only the friends of the logged-in user. - - - -``` -let limit = 30; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .friendsOnly(true) - .build(); -``` - - - - - -### Set Tags - -This method accepts a list of tags based on which the list of users is to be fetched. The list fetched will only contain the users that have been tagged with the specified tags. - - - -``` -let limit = 30; -let tags = ["tag1", "tag2"]; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setTags(tags) - .build(); -``` - - - - - -### With Tags - -This property when set to true will fetch tags data along with the list of users. - - - -``` -let limit = 30; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .withTags(true) - .build(); -``` - - - - - -### Set UIDs - -This method accepts a list of UIDs based on which the list of users is fetched. A maximum of `25` users can be fetched. - - - -``` -let limit = 30; -let UIDs = ["cometchat-uid-1", "cometchat-uid-2"]; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setUIDs(UIDs) - .build(); -``` - - - - - -Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the UsersRequest class. - -Once you have the object of the UsersRequest class, you need to call the fetchNext() method. Calling this method will return a list of User objects containing n number of users where n is the limit set in the builder class. - - - -``` -var limit = 30; -var usersRequest = new CometChat.UsersRequestBuilder().setLimit(limit).build(); - -usersRequest.fetchNext().then( - (userList) => { - console.log("User list received:", userList); - }, - (error) => { - console.log("User list fetching failed with error:", error); - } -); -``` - - - - - -## Retrieve Particular User Details - -To get the information of a user, you can use the `getUser()` method. - - - -``` -let UID = "UID"; -CometChat.getUser(UID).then( - (user) => { - console.log("User details fetched for user:", user); - }, - (error) => { - console.log("User details fetching failed with error:", error); - } -); -``` - - - - - -The `getUser()` method takes the following parameters: - -| Parameter | Description | -| --------- | ---------------------------------------------------------- | -| UID | The UID of the user for whom the details are to be fetched | - -It returns the `User` object containing the details of the user. diff --git a/sdk/ionic-legacy/2.0/users-user-management.mdx b/sdk/ionic-legacy/2.0/users-user-management.mdx deleted file mode 100644 index ebb9ee1de..000000000 --- a/sdk/ionic-legacy/2.0/users-user-management.mdx +++ /dev/null @@ -1,142 +0,0 @@ ---- -title: "User Management" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -When a user logs into your app, you need to programmatically login the user into CometChat. But before you log in the user to CometChat, you need to create the user. - -Summing up- - -**When a user registers in your app** - -1. You add the user details in your database -2. You create a user in CometChat - -**When a user logs into your app** - -1. You log in the user to your app -2. You [log in the user to CometChat](/sdk/ionic-legacy/2.0/authentication) (programmatically) - -## Creating a user - -Ideally, user creation should take place at your backend. You can refer to our Rest API to learn more about [creating a user](https://api-explorer.cometchat.com/reference/creates-user) and use the appropriate code sample based on your backend language. - -However, if you wish to create users on the fly, you can use the `createUser()` method. This method takes a `User` object and the `Auth Key` as input parameters and returns the created `User` object if the request is successful. - - - -```js -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); - } -); -``` - - - - - - - -UID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed. - - - -## Updating a user - -Updating a user similar to creating a user should ideally be achieved at your backend using the Restful APIs. For more information, you can check the [update a user](https://api-explorer.cometchat.com/reference/update-user) apis section. However, this can be achieved on the fly as well as using the `updateUser()` method. This method takes a `User` object and the `Auth Key` as inputs and returns the updated `User` object on the successful execution of the request. - - - -```js -let authKey = "AUTH_KEY"; -let uid = "user1"; -let name = "Kevin Fernandez"; - -var user = new CometChat.User(uid); - -user.setName(name); - -CometChat.updateUser(user, authKey).then( - (user) => { - console.log("user updated", user); - }, - (error) => { - console.log("error", error); - } -); -``` - - - - - -Please make sure the `User` object provided to the `updateUser()` method has the `UID` of the user to be updated set. - -## Updating logged-in user - -Updating a logged-in user is similar to updating a user. The only difference being this method does not require an AuthKey. This method takes a `User` object as input and returns the updated `User` object on the successful execution of the request. - - - -```js -let uid = "user1"; -let name = "Kevin Fernandez"; - -var user = new CometChat.User(uid); - -user.setName(name); - -CometChat.updateCurrentUserDetails(user).then( - (user) => { - console.log("user updated", user); - }, - (error) => { - console.log("error", error); - } -); -``` - - - - - -By using the `updateCurrentUserDetails()` method one can only update the logged-in user irrespective of the UID passed. Also, it is not possible to update the role of a logged-in user. - -## Deleting a user - -Deleting a user can only be achieved via the Restful APIs. For more information please check the [delete a user](https://api-explorer.cometchat.com/reference/delete-user) section. - -## User Class - -| Field | Editable | Information | -| ------------- | --------------------------------------------------- | -------------------------------------------------------------------- | -| uid | specified on user creation. Not editable after that | Unique identifier of the user | -| name | Yes | Display name of the user | -| avatar | Yes | URL to profile picture of the user | -| link | Yes | URL to profile page | -| role | Yes | User role of the user for role based access control | -| metadata | Yes | Additional information about the user as JSON | -| status | No | Status of the user. Could be either online/offline | -| statusMessage | Yes | Any custom status message that needs to be set for a user | -| lastActiveAt | No | The unix timestamp of the time the user was last active. | -| hasBlockedMe | No | A boolean that determines if the user has blocked the logged in user | -| blockedByMe | No | A boolean that determines if the logged in user has blocked the user | -| tags | Yes | A list of tags to identify specific users | diff --git a/sdk/ionic-legacy/2.0/users.mdx b/sdk/ionic-legacy/2.0/users.mdx deleted file mode 100644 index 29ba5517c..000000000 --- a/sdk/ionic-legacy/2.0/users.mdx +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: "Users" -sidebarTitle: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -The primary aim for our user's functionality is to allow you to quickly retrieve and add users to CometChat. - -You can begin with [user management](/sdk/ionic-legacy/2.0/users-user-management) to sync your users to CometChat. Once that is done, you can [retrieve users](/sdk/ionic-legacy/2.0/users-retrieve-users) and display them in your app. diff --git a/sdk/ionic-legacy/2.0/webhooks.mdx b/sdk/ionic-legacy/2.0/webhooks.mdx deleted file mode 100644 index 474750e38..000000000 --- a/sdk/ionic-legacy/2.0/webhooks.mdx +++ /dev/null @@ -1,70 +0,0 @@ ---- -title: "Webhooks" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -CometChat can send webhook events that notify your application any time an event happens on your account. - -## Setting up webhooks - -### Create a webhook endpoint - -Webhook data is sent as JSON in the POST request body. Creating a webhook endpoint on your server is no different from creating any page on your website. With PHP, you might create a new .php file on your server; with a Ruby framework like Sinatra, you would add a new route with the desired URL. - -### Test the endpoint locally - -Once you’ve added an endpoint to your server, start an instance locally and use a tool like [ngrok](https://ngrok.com) to make your endpoint available for receiving events. - -Start ngrok in a command prompt with the same port number that you have configured for your server (e.g., ./ngrok http 8000). You should see information about your tunnel session such as status, expiration, and version. Take note of the Forwarding addresses (e.g., [https://xxxxxxxx.ngrok.io](https://xxxxxxxx.ngrok.io) -> localhost:8000) as this is required for the following step. - -### Configure webhook settings - -With your endpoint created, you need to tell CometChat about where to send events to. In the Dashboard's Webhooks section, click **Create Webhook** to reveal a form to add a new webhook for receiving events. You can enter any URL as the destination for events. However, this should be a dedicated page on your server that is set up to receive webhook events. - -Once you've created the webhook, click **View/Update** to add a trigger. We support two types of triggers- - -| Trigger | Description | -| --------------- | ----------------------------------------------------------- | -| after\_message | The endpoint will be triggered after a message is sent. | -| before\_message | The endpoint will be triggered when a message is in-flight. | - -The `after_message` trigger is fairly straightforward. CometChat will call your endpoint once a message has been sent. - -The `before_message` trigger is useful when you want to add metadata to a message before it reaches the recipient. The data you return will be automatically added to the message metadata: - - - -```json -{ -"@injected": { - "webhooks": { - "webhook-id": { - // JSON Object Response From Endpoint - } - } -} -} -``` - - - - - -You can also decide to drop a message by returning the following JSON object- - - - -```json -{ -"action": "do_not_propagate" -} -``` - - - - diff --git a/sdk/ionic-legacy/3.0/advanced-connection-listener.mdx b/sdk/ionic-legacy/3.0/advanced-connection-listener.mdx deleted file mode 100644 index ccd8cb3af..000000000 --- a/sdk/ionic-legacy/3.0/advanced-connection-listener.mdx +++ /dev/null @@ -1,99 +0,0 @@ ---- -title: "Connection Status" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -CometChat SDK provides you with a mechanism to get real-time status of the connection to CometChat web-socket servers. - -Connection Status provides you with the below 3 methods to get the status of the connection to CometChat web-socket servers: - -| Delegate Method | Information | -| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | -| connecting | This method is triggered when CometChat SDK is trying to establish a connection to the web-socket server. | -| connected | This method is called when CometChat SDK has successfully established a connection and now is connected. | -| disconnected | This method is called when the CometChat SDK gets disconnected due to any issue while maintaining the connection like network fluctuations, etc. | - -Once the connection is broken, the disconnected callback is triggered, the SDK automatically tries to establish the connection again, thus going into the connecting state and triggering the `connecting` method. Once the attempt to connect is successful, the `connected` method is triggered thus letting the developer know that the connection is established and is active. - -To receive real-time connection status, you need to register `ConnectionListener` wherever you wish to receive the real-time status. You can use the `addConnectionListener()` method to do so. - - - -```js -var listenerID = "UNIQUE_LISTENER_ID"; -CometChat.addConnectionListener( - listenerID, - new CometChat.ConnectionListener({ - onConnected: () => { - console.log("ConnectionListener => On Connected"); - }, - inConnecting: () => { - console.log("ConnectionListener => In connecting"); - }, - onDisconnected: () => { - console.log("ConnectionListener => On Disconnected"); - } - }) -); -``` - - - - -```ts -let listenerID: string = "UNIQUE_LISTENER_ID"; -CometChat.addConnectionListener( - listenerID, - new CometChat.ConnectionListener({ - onConnected: () => { - console.log("ConnectionListener => On Connected"); - }, - inConnecting: () => { - console.log("ConnectionListener => In connecting"); - }, - onDisconnected: () => { - console.log("ConnectionListener => On Disconnected"); - } - }) -); -``` - - - - - - - -We recommend you to add the Connection Listener in your method on app startup, preferably in the index.js file. Once you have successfully initialized CometChat. - - - -You can also get the current connection status by using `getConnectionStatus` property provided by CometChat SDK - - - -```js -var connectionStatus = CometChat.getConnectionStatus(); -``` - - - - -```ts -var connectionStatus: string = CometChat.getConnectionStatus(); -``` - - - - - -The `CoimetChat.getConnectionStatus` method will return either of the below 3 values: - -1. connecting -2. connected -3. disconnected diff --git a/sdk/ionic-legacy/3.0/advanced-managing-web-socket-connections-manually.mdx b/sdk/ionic-legacy/3.0/advanced-managing-web-socket-connections-manually.mdx deleted file mode 100644 index f70efa86f..000000000 --- a/sdk/ionic-legacy/3.0/advanced-managing-web-socket-connections-manually.mdx +++ /dev/null @@ -1,102 +0,0 @@ ---- -title: "Managing Web Socket Connections Manually" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Default SDK behaviour on login - -When the login method of the SDK is called, the SDK performs the below operations: - -1. Logs the user into the SDK -2. Saves the details of the logged in user locally. -3. Creates a web-socket connection for the logged in user. - -This makes sure that the logged in user starts receiving real-time messages sent to him or any groups that he is a part of as soon as he logs in. - -When the app is reopened, and the init() method is called, the web-socket connection to the server is established automatically. - -This is the default behaviour of the CometChat SDKs. However, if you wish to take control of the web-socket connection i.e if you wish to connect and disconnect to the web-socket server manually, you can refer to the Managing Web-socket Connection section. - -## Managing the Web-socket connections manually - -The CometChat SDK also allows you to modify the above default behaviour of the SDK and take the control of the web-socket connection into your own hands. In order to achieve this, you need to follow the below steps: - -1. While calling the init() function on the app startup, you need to inform the SDK that you will be managing the web socket connect. You can do so by using the `autoEstablishSocketConnection()` method provided by the `AppSettingsBuilder` class. This method takes a boolean value as an input. If set to `true` , the SDK will manage the web-socket connection internally based on the default behaviour mentioned above. If set to `false` , the web socket connection can will not be managed by the SDK and you will have to handle it manually. You can refer to the below code snippet for the same: - - - -```js -let appID = "APP_ID"; -let region = "APP_REGION"; -let appSetting = new CometChat.AppSettingsBuilder() - .subscribePresenceForAllUsers() - .setRegion(region) - .autoEstablishSocketConnection(false) - .build(); -CometChat.init(appID, appSetting).then( - () => { - console.log("Initialization completed successfully"); - }, error => { - console.log("Initialization failed with error:", error); - } -); -``` - - - - -```ts -let appID: string = "APP_ID"; -let region: string = "APP_REGION"; -let appSetting: CometChat.AppSettings = new CometChat.AppSettingsBuilder() - .subscribePresenceForAllUsers() - .setRegion(region) - .autoEstablishSocketConnection(false) - .build(); -CometChat.init(appID, appSetting).then( - (isInitialized: boolean) => { - console.log("Initialization completed successfully"); - }, (error: CometChat.CometChatException) => { - console.log("Initialization failed with error:", error); - } -); -``` - - - - - -You can manage the connection to the web-socket server using the `connect()` and `disconnect()` methods provided by the SDK. - -1. Connect to the web-socket server - -You need to use the `connect()` method provided by the `CometChat` class to establish the connection to the web-socket server. Please make sure that the user is logged in to the SDK before calling this method. You can use the CometChat.getLoggedInUser() method to check this. Once the connection is established, you will start receiving all the real-time events for the logged in user. - - - -``` -CometChat.connect(); -``` - - - - - -2. Disconnect from the web-socket server - -You can use the `disconnect()` method provided by the `CometChat` class to break the established connection. Once the connection is broken, you will stop receiving all the real-time events for the logged in user. - - - -``` -CometChat.disconnect(); -``` - - - - diff --git a/sdk/ionic-legacy/3.0/advanced.mdx b/sdk/ionic-legacy/3.0/advanced.mdx deleted file mode 100644 index 07e7ab601..000000000 --- a/sdk/ionic-legacy/3.0/advanced.mdx +++ /dev/null @@ -1,12 +0,0 @@ ---- -title: "Advanced" -sidebarTitle: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -This section helps you to know about the Connection Listeners. diff --git a/sdk/ionic-legacy/3.0/authentication-login-listeners.mdx b/sdk/ionic-legacy/3.0/authentication-login-listeners.mdx deleted file mode 100644 index 71f9aa8da..000000000 --- a/sdk/ionic-legacy/3.0/authentication-login-listeners.mdx +++ /dev/null @@ -1,92 +0,0 @@ ---- -title: "Login Listeners" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -The CometChat SDK provides you with real-time updates for the `login` and `logout` events. This can be achieved using the `LoginListener` class provided. LoginListener consists of 4 events that can be triggered. These are as follows: - -| Callback Method | Information | -| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| loginSuccess(user) | Informs you that the login was successful and provides you with a user object containing the data for the user that logged in. | -| loginFailure(event) | Informs you about the failure while logging in the user and provides you with the reason for the failure wrapped in an object of the `CometChatException` class. | -| logoutSuccess() | Informs you about the user being logged out successfully. | -| logoutFailure(event) | Informs you about the failure while logging out the user. The reason for the failure can be obtained from the object of the `CometChatException` class. | - -To add the `LoginListener`, you need to use the `addLoginListener()` method provided by the SDK which takes a unique identifier for the listener and of the the `LoginListener` class itself. - - - -```js -let listenerID = "UNIQUE_LISTENER_ID"; -CometChat.addLoginListener( - listenerID, - new CometChat.LoginListener({ - loginSuccess: (e) => { - console.log("LoginListener :: loginSuccess", e); - }, - loginFailure: (e) => { - console.log("LoginListener :: loginFailure", e); - }, - logoutSuccess: () => { - console.log("LoginListener :: logoutSuccess"); - }, - logoutFailure: (e) => { - console.log("LoginListener :: logoutFailure", e); - } - }) -); -``` - - - - -```ts -var listenerID: string = "UNIQUE_LISTENER_ID"; -CometChat.addLoginListener( - listenerID, - new CometChat.LoginListener({ - loginSuccess: (user: CometChat.User) => { - console.log("LoginListener :: loginSuccess", user); - }, - loginFailure: (error: CometChat.CometChatException) => { - console.log("LoginListener :: loginFailure", error); - }, - logoutSuccess: () => { - console.log("LoginListener :: logoutSuccess"); - }, - logoutFailure: (error: CometChat.CometChatException) => { - console.log("LoginListener :: logoutFailure", error); - } - }) -); -``` - - - - - -In order to stop receiving events related to login and logout you need to use the `removeLoginListener()` method provided by the SDK and pass the ID of the listener that needs to be removed. - - - -```js -let listenerID = "UNIQUE_LISTENER_ID"; -CometChat.removeLoginListener(listenerID); -``` - - - - -```ts -var listenerID: string = "UNIQUE_LISTENER_ID"; -CometChat.removeLoginListener(listenerID); -``` - - - - diff --git a/sdk/ionic-legacy/3.0/authentication.mdx b/sdk/ionic-legacy/3.0/authentication.mdx deleted file mode 100644 index e213d9b0b..000000000 --- a/sdk/ionic-legacy/3.0/authentication.mdx +++ /dev/null @@ -1,208 +0,0 @@ ---- -title: "Authentication" -sidebarTitle: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Create User - -Before you login the user, you must add the user to CometChat. - -1. **For proof of concept/MVPs**: Create the user using the [CometChat Dashboard](https://app.cometchat.com). -2. **For production apps**: Use the CometChat [Create User API](https://api-explorer.cometchat.com/reference/creates-user) to create the user when your user signs up in your app. - - -**Sample Users** - -We have setup 5 users for testing having UIDs: `cometchat-uid-1`, `cometchat-uid-2`, `cometchat-uid-3`, `cometchat-uid-4` and `cometchat-uid-5`. - - - -Once initialization is successful, you will need to log the user into CometChat using the `login()` method. - -We recommend you call the CometChat `login` method once your user logs into your app. The `login()` method needs to be called only once. - - - -The CometChat SDK maintains the session of the logged in user within the SDK. Thus you do not need to call the login method for every session. You can use the CometChat.getLoggedinUser() method to check if there is any existing session in the SDK. This method should return the details of the logged-in user. If this method returns null, it implies there is no session present within the SDK and you need to log the user into ComeChat. - - - -## Login using Auth Key - -This simple authentication procedure is useful when you are in development or if you do not require additional security. - - - -```js -var UID = "UID"; -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 }); - } - ); - } - }, - (error) => { - console.log("Something went wrong", error); - } -); -``` - - - - -```ts -var UID: string = "cometchat-uid-1", - authKey: string = "AUTH_KEY"; - -CometChat.getLoggedinUser().then( - (user: CometChat.User) => { - if (!user) { - CometChat.login(UID, authKey).then( - (user: CometChat.User) => { - console.log("Login Successful:", { user }); - }, - (error: CometChat.CometChatException) => { - console.log("Login failed with exception:", { error }); - } - ); - } - }, - (error: CometChat.CometChatException) => { - console.log("Some Error Occured", { error }); - } -); -``` - - - - - -| Parameters | Description | -| ---------- | ------------------------------------------------ | -| UID | The UID of the user that you would like to login | -| authKey | CometChat Auth Key | - -After the user logs in, their information is returned in the `User` object on `Promise` resolved. - - - -Be sure to use the **Auth Key** and not the **Rest API Key**. This ensures that even if a malicious user reverse engineers your client code, they will only be able to log in to CometChat and not call any other APIs. - - - -## Login using Auth Token - -This advanced authentication procedure does not use the Auth Key directly in your client code and thus ensuring that your Auth Key is not leaked even if the client code is reverse engineered. - -1. [Create a User](https://api-explorer.cometchat.com/reference/creates-user) via the CometChat API when the user signs up in your app. -2. [Create an Auth Token](https://api-explorer.cometchat.com/reference/create-authtoken) via the CometChat API for the new user and save the token in your database. -3. Load the Auth Token in your client and pass it to the `login()` method. - - - -```js -var authToken = "AUTH_TOKEN"; - -CometChat.getLoggedinUser().then( - (user) => { - if (!user) { - CometChat.login(authToken).then( - (user) => { - console.log("Login Successful:", { user }); - }, - (error) => { - console.log("Login failed with exception:", { error }); - } - ); - } - }, - (error) => { - console.log("Something went wrong", error); - } -); -``` - - - - -```ts -var authToken: string = "AUTH_TOKEN"; - -CometChat.getLoggedinUser().then( - (user: CometChat.User) => { - if (!user) { - CometChat.login(authToken).then( - (user: CometChat.User) => { - console.log("Login Successful:", { user }); - }, - (error: CometChat.CometChatException) => { - console.log("Login failed with exception:", { error }); - } - ); - } - }, - (error: CometChat.CometChatException) => { - console.log("Some Error Occured", { error }); - } -); -``` - - - - - -| Parameter | Description | -| --------- | ---------------------------------------------- | -| authToken | Auth Token of the user you would like to login | - -After the user logs in, their information is returned in the `User` object on the `Promise` resolved. - -## Logout - -You can use the `logout()` method to log out the user from CometChat. We suggest you call this method once your user has been successfully logged out from your app. - - - -```js -CometChat.logout().then( - () => { - console.log("Logout completed successfully"); - }, - (error) => { - console.log("Logout failed with exception:", { error }); - } -); -``` - - - - -```ts -CometChat.logout().then( - (loggedOut: Object) => { - console.log("Logout completed successfully"); - }, - (error: CometChat.CometChatException) => { - console.log("Logout failed with exception:", { error }); - } -); -``` - - - - diff --git a/sdk/ionic-legacy/3.0/bots.mdx b/sdk/ionic-legacy/3.0/bots.mdx deleted file mode 100644 index 34017b16c..000000000 --- a/sdk/ionic-legacy/3.0/bots.mdx +++ /dev/null @@ -1,25 +0,0 @@ ---- -title: "Bots" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -Bots are special users, in CometChat, who can send and receive messages autonomously. Users can text bots privately in one-on-one conversations as well as in groups. When a bot receives a message, either in a one-on-one conversation or in a group conversation, CometChat forwards the message to a Callback URL that you specify. Once you receive this message, you can send a reply using our API. - -## The flow - -### Create a user - -CometChat requires you to connect every bot to a user. This has one major advantage- at any time, you can log in as that bot user and send out personalized replies. So before you create a bot, you must first create a new user. - -### Create the bot - -Once you've created a user, you can create a new bot. The actual implementation of the bot is entirely up to you. You simply need to specify a `Callback URL` and CometChat will automatically start forwarding all messages that fit the criteria to the URL. - -### Reply to a message - -When you receive a message from CometChat, you can process it and provide a response using our [Send Bot Message](/reference/messages/send-bot-message) Rest API. diff --git a/sdk/ionic-legacy/3.0/calling-default-calling.mdx b/sdk/ionic-legacy/3.0/calling-default-calling.mdx deleted file mode 100644 index 62526a8bf..000000000 --- a/sdk/ionic-legacy/3.0/calling-default-calling.mdx +++ /dev/null @@ -1,516 +0,0 @@ ---- -title: "Default Calling" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -This section will provide information on how a complete calling workflow can be set up using CometChat. We've built the complete workflow to help your users make calls, receive calls as well as accept/reject calls. - -Let us assume Alex to be the call initiator and Bob is the receiver. - -1. Alex initiates the call to Bob using the **initiateCall()** method. - -2. Bob now has two choices: - - 1. Accept the call from Alex using the **acceptCall()** method. - 2. Reject the call from Alex using the **rejectCall()** method passing the status as `rejected`. - -3. In the meantime, Alex has the option to cancel the call he initiated to Bob using the **rejectCall()** method passing the status as `cancelled`. - -4. If Bob accepts the call from Alex, both Alex and Bob need to call the **startCall()** method. Alex in the **onOutgoingCallAccepted()** method of the `CallListener` and Bob in the success obtained from the `**acceptCall()**` method and both will be connected to each other. - -## Initiate Call - -The `initiateCall()` method sends a call request to a user or a group. - - - -``` -var receiverID = "UID"; -var callType = CometChat.CALL_TYPE.VIDEO; -var receiverType = CometChat.RECEIVER_TYPE.USER; - -var call = new CometChat.Call(receiverID, callType, receiverType); - -CometChat.initiateCall(call).then( - outGoingCall => { - console.log("Call initiated successfully:", outGoingCall); - // perform action on success. Like show your calling screen. - }, - error => { - console.log("Call initialization failed with exception:", error); - } -); -``` - - - - -``` -var receiverID = "GUID"; -var callType = CometChat.CALL_TYPE.VIDEO; -var receiverType = CometChat.RECEIVER_TYPE.GROUP; - -var call = new CometChat.Call(receiverID, callType, receiverType); - -CometChat.initiateCall(call).then( - outGoingCall => { - console.log("Call initiated successfully:", outGoingCall); - // perform action on success. Like show your calling screen. - }, - error => { - console.log("Call initialization failed with exception:", error); - } -); -``` - - - - -``` -var receiverID: string = "UID"; -var callType: string = CometChat.CALL_TYPE.VIDEO; -var receiverType: string = CometChat.RECEIVER_TYPE.USER; - -var call: CometChat.Call = new CometChat.Call(receiverID, callType, receiverType); - -CometChat.initiateCall(call).then( - (outGoingCall: CometChat.Call) => { - console.log("Call initiated successfully:", outGoingCall); - }, (error: CometChat.CometChatException) => { - console.log("Call initialization failed with exception:", error); - } -); -``` - - - - -``` -var receiverID: string = "GUID"; -var callType: string = CometChat.CALL_TYPE.VIDEO; -var receiverType: string = CometChat.RECEIVER_TYPE.GROUP; - -var call: CometChat.Call = new CometChat.Call(receiverID, callType, receiverType); - -CometChat.initiateCall(call).then( - (outGoingCall: CometChat.Call) => { - console.log("Call initiated successfully:", outGoingCall); - }, (error: CometChat.CometChatException) => { - console.log("Call initialization failed with exception:", error); - } -); -``` - - - - - -This method takes an object of the `Call` class. The constructor for `Call` class takes the following parameters: - -| Parameter | Description | -| -------------- | -------------------------------------------------------------------------------------------- | -| `receiverID` | The `UID` or `GUID` of the recipient | -| `receiverType` | The type of the receiver. 1.`CometChat.RECEIVER_TYPE.USER` 2.`CometChat.RECEIVER_TYPE.GROUP` | -| `callType` | The type of call. 1.`CometChat.CALL_TYPE.AUDIO` 2.`CometChat.CALL_TYPE.VIDEO` | - -On successful initialization, a `Call` object is returned with the details of the call including a unique session ID for the call. - -## Receive Calls - -Wherever you wish to receive the call events in, you need to register the `CallListener` listener using the `addCallListener()` method. - - - -```js -var listnerID = "UNIQUE_LISTENER_ID"; -CometChat.addCallListener( - listnerID, - new CometChat.CallListener({ - onIncomingCallReceived: (call) => { - console.log("Incoming call:", call); - // Handle incoming call - }, - onOutgoingCallAccepted: (call) => { - console.log("Outgoing call accepted:", call); - // Outgoing Call Accepted - }, - onOutgoingCallRejected: (call) => { - console.log("Outgoing call rejected:", call); - // Outgoing Call Rejected - }, - onIncomingCallCancelled: (call) => { - console.log("Incoming call calcelled:", call); - } - }) -); -``` - - - - -```ts -var listnerID: string = "UNIQUE_LISTENER_ID"; -CometChat.addCallListener( - listnerID, - new CometChat.CallListener({ - onIncomingCallReceived: (call: CometChat.Call) => { - console.log("Incoming call:", call); - }, - onOutgoingCallAccepted: (call: CometChat.Call) => { - console.log("Outgoing call accepted:", call); - }, - onOutgoingCallRejected: (call: CometChat.Call) => { - console.log("Outgoing call rejected:", call); - }, - onIncomingCallCancelled: (call: CometChat.Call) => { - console.log("Incoming call calcelled:", call); - } - }) -); -``` - - - - - -| Parametrer | Description | -| ------------ | ---------------------------------------------------------------------------------------------- | -| `listenerID` | An ID that uniquely identifies that listener. We recommend using the activity or fragment name | - -We recommend you remove the listener once the activity or fragment is not in use. - - - -```js -var listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.removeCallListener(listenerID); -``` - - - - -```ts -var listenerID: string = "UNIQUE_LISTENER_ID"; - -CometChat.removeCallListener(listenerID); -``` - - - - - -As mentioned in the [Overview](/sdk/ionic-legacy/3.0/calling-default-calling) section, Once the call is initiated, there are three options that can be possible: - -1. The receiver of the call accepts the call. -2. The receiver of the call rejects the call. -3. The initiator of the call cancels the call. - -Please find below how these three scenarios can be implemented: - -### Accept the Incoming Call - -Once you have received an incoming call from a user or in any group, to accept the call using the `acceptCall()` method. - - - -```js -var sessionID = "SESSION_ID"; - -CometChat.acceptCall(sessionID).then( - call => { - console.log("Call accepted successfully:", call); - // start the call using the startCall() method - }, - error => { - console.log("Call acceptance failed with error", error); - // handle exception - } -); -``` - - - - -```ts -var sessionID: string = "SESSION_ID"; - -CometChat.acceptCall(sessionID).then( - (call: CometChat.Call) => { - console.log("Call accepted successfully:", call); - }, (error: CometChat.CometChatException) => { - console.log("Call acceptance failed with error", error); - } -); -``` - - - - - -| Parameter | Description | -| ----------- | ---------------------------------------------------- | -| `sessionID` | The unique session ID available in the `Call` object | - -### Reject the Incoming Call - -To reject the incoming call once it is received using the `rejectCall()` method. - - - -```js -var sessionID = "SESSION_ID"; -var status = CometChat.CALL_STATUS.REJECTED; - -CometChat.rejectCall(sessionID, status).then( - call => { - console.log("Call rejected successfully", call); - }, - error => { - console.log("Call rejection failed with error:", error); - } -); -``` - - - - -```ts -var sessionID: string = "SESSION_ID"; -var status: string = CometChat.CALL_STATUS.REJECTED; - -CometChat.rejectCall(sessionID, status).then( - (call: CometChat.Call) => { - console.log("Call rejected successfully", call); - }, (error: CometChat.CometChatException) => { - console.log("Call rejection failed with error:", error); - } -); -``` - - - - - -| Parameter | Description | -| ----------- | ---------------------------------------------------- | -| `sessionID` | The unique session ID available in the `Call` object | -| `status` | Reason for rejection of the call | - -Here the status needs to be set as `CometChat.CALL_STATUS.REJECTED` as the call is being rejected by the receiver of the call. - -### Cancel the Outgoing Call - -In the case where the initiator wishes to cancel the call, use the same above `rejectCall()` method and just pass the status to the `rejectCall()` method as `CometChat.CALL_STATUS.CANCELLED` - -## Start a Call - -Once the call request is sent and the receiver has accepted the call, both the initiator and the receiver need to call the `startCall()` method. - -You need to call this method for two scenarios: - -1. After you accept an incoming call i.e. in the `onSuccess()` callback of the `acceptCall()` method. -2. After the recipient accepts an outgoing call i.e. in the `onOutgoingCallAccepted()` callback of the `CallListener` listener. - - - -```js -/** - * You can get the call Object from the success of acceptCall() or from the onOutgoingCallAccepted() callback of the CallListener. - */ -let sessionID = "SESSION_ID"; -let audioOnly = false; -let deafaultLayout = true; -let callListener: CometChat.OngoingCallListener = new CometChat.OngoingCallListener({ - onUserJoined: (user: CometChat.User) => { - console.log("user joined:", user); - }, - onUserLeft: (user: CometChat.User) => { - console.log("user left:", user); - }, - onUserListUpdated: (userList: CometChat.User[]) => { - console.log("user list:", userList); - }, - onCallEnded: (call: CometChat.Call) => { - console.log("Call ended:", call); - }, - onError: (error: CometChat.CometChatException) => { - console.log("Error :", error); - }, - onAudioModesUpdated: (audioModes: CometChat.AudioMode[]) => { - console.log("audio modes:", audioModes); - }, - onCallSwitchedToVideo: (sessionId, callSwitchInitiatedBy, callSwitchAcceptedBy) => { - console.log("call switched to video:", {sessionId, callSwitchInitiatedBy, callSwitchAcceptedBy}); - }, - onUserMuted: (userMuted, userMutedBy) => { - console.log("user muted:", {userMuted, userMutedBy}); - } -}); -var callSettings = new CometChat.CallSettingsBuilder() - .setSessionID(sessionId) - .enableDefaultLayout(deafaultLayout) - .setIsAudioOnlyCall(audioOnly) - .setCallEventListener(callListener) - .build(); -CometChat.startCall(callSettings); -``` - - - - -```ts -let sessionID: string = "SESSION_ID"; -let audioOnly: boolean = false; -let defaultLayout: boolean = true; -let callListener: CometChat.OngoingCallListener = new CometChat.OngoingCallListener({ - onUserJoined: (user: CometChat.User) => { - console.log("user joined:", user); - }, - onUserLeft: (user: CometChat.User) => { - console.log("user left:", user); - }, - onUserListUpdated: (userList: CometChat.User[]) => { - console.log("user list:", userList); - }, - onCallEnded: (call: CometChat.Call) => { - console.log("Call ended:", call); - }, - onError: (error: CometChat.CometChatException) => { - console.log("Error :", error); - }, - onAudioModesUpdated: (audioModes: CometChat.AudioMode[]) => { - console.log("audio modes:", audioModes); - } -}); - -let callSettings: CometChat.CallSettings = new CometChat.CallSettingsBuilder() - .enableDefaultLayout(defaultLayout) - .setSessionID(sessionID) - .setIsAudioOnlyCall(audioOnly) - .setCallEventListener(callListener) - .build(); - -CometChat.startCall(callSettings); -``` - - - - - -| Parameter | Description | -| --------------------- | -------------------------------------------------------------------------- | -| `callSettings` | Object of CallSettings class. | -| `OngoingCallListener` | CometChat.OngoingCallListener where the real-time events will be received. | - -The `OngoingCallListener` listener provides you with the below callback methods: - -| Callback Method | Description | -| ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | -| `onUserJoined(User user)` | This method is called when any other user joins the call. The user details can be obtained from the `User` object provided. | -| `onUserLeft(User user)` | This method is called when a user leaves the call. The details of the user can be obtained from the provided `User` object. | -| `onCallEnded()` | This method is called when the call is successfully ended. The call details can be obtained from the `Call` object provided. | -| `onUserListUpdated(userList)` | This method is triggered every time a participant joins or leaves the call providing the list of users active in the call. | -| `onAudioModesUpdated(audioModes)` | This callback is triggered if any new audio output source is available or becomes unavailable. | -| `onCallSwitchedToVideo(sessionId, callSwitchInitiatedBy, callSwitchAcceptedBy)` | This callback is triggered when an audio call is converted into a video call. | -| `onUserMuted(userMuted, userMutedBy)` | This callback is triggered when a user is muted in the call. | - -## Settings - -The `CallSettings` class is the most important class when it comes to the implementation of the Calling feature. This is the class that allows you to customize the overall calling experience. The properties for the call/conference can be set using the `CallSettingsBuilder` class. This will eventually give you an object of the `CallSettings` class which you can pass to the `startCall()` method to start the call. - -The **mandatory** parameters that are required to be present for any call/conference to work are: - -1. sessionId - The unique session Id for the call/conference session. - -The options available for customization of calls are: - -| Setting | Description | -| ---------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `enableDefaultLayout(defaultLayout: boolean)` | If set to `true` enables the default layout for handling the call operations. If set to `false` it hides the button layout and just displays the Call View. **Default value = true** | -| `showEndCallButton(showEndCallButton: boolean)` | If set to `true` it displays the EndCallButton in Button Layout. if set to `false` it hides the EndCallButton in Button Layout. **Default value = true** | -| `showPauseVideoButton(showPauseVideoButton: boolean)` | If set to `true` it displays the PauseVideoButton in Button Layout. if set to `false` it hides the PauseVideoButton in Button Layout. **Default value = true** | -| `showMuteAudioButton(showMuteAudioButton: boolean)` | If set to `true` it displays the MuteAudioButton in Button Layout. if set to `false` it hides the MuteAudioButton in Button Layout. **Default value = true** | -| `showSwitchCameraButton(showSwitchCameraButton: boolean)` | If set to `true` it displays the SwitchCameraButton in Button Layout. if set to `false` it hides the SwitchCameraButton in Button Layout. **Default value = true** | -| `showAudioModeButton(showAudioModeButton: boolean)` | If set to `true` it displays the AudioModeButton in Button Layout. if set to `false` it hides the AudioModeButton in Button Layout. **Default value = true** | -| `setIsAudioOnlyCall(audioOnly: boolean)` | If set to true, the call will be strictly an audio call. If ser to false, the call will be an audio-video call. **Default value = false** | -| `setMode(mode: string)` | CometChat provides 3 options for the calling UI. 1. CometChat.CALL\_MODE.DEFAULT 2. CometChat.CALL\_MODE.SPOTLIGHT 3. CometChat.CALL\_MODE.SINGLE **Default value = CometChat.CALL\_MODE.DEFAULT** | -| `startWithAudioMuted(audioMuted: boolean)` | This ensures the call is started with the audio muted if set to true. **Default value = false** | -| `startWithVideoMuted(videoMuted: boolean)` | This ensures the call is started with the video paused if set to true. **Default value = false** | -| `setDefaultAudioMode(audioMode: string)` | This method can be used if you wish to start the call with a specific audio mode. The available options are 1. CometChat.AUDIO\_MODE.SPEAKER = "SPEAKER" 2. CometChat.AUDIO\_MODE.EARPIECE = "EARPIECE" 3. CometChat.AUDIO\_MODE.BLUETOOTH = "BLUETOOTH" 4. CometChat.AUDIO\_MODE.HEADPHONES = "HEADPHONES" | -| `showSwitchToVideoCallButton(switchCall: boolean)` | This method shows/hides the switch to video call button. If set to true it will display the switch to video call button. If set to false it will hide the switch to video call button. **Default value = true** | -| `setAvatarMode(avatarMode: string)` | This method sets the mode of avatar. The avatar mode can be `circle`, `square` or `fullscreen`. **Default value = circle** | -| `setMainVideoContainerSetting(containerSettings: MainVideoContainerSetting)` | This method can be used to customize the main video container. You can read more about this [here](/sdk/ionic-legacy/3.0/video-view-customisation). | -| `enableVideoTileClick(enableVideoTileClick: boolean)` | This method can be used to enable/disable video tile click functionality in **Spotlight** mode. **Default value = true** | -| `enableVideoTileDrag(enableVideoTileDrag: boolean)` | This method can be used to enable/disable video tile drag functionality in **Spotlight** mode. **Default value = true** | - -## Active Call - -CometChat provides a method to get the details of the call that is currently active. The `CometChat.getActiveCall()` will return an object of the `Call` class containing the details of the ongoing call. If there is no ongoing call this method will return null. - - - -```js -let activeCall = CometChat.getActiveCall(); -``` - - - - -```ts -let activeCall: CometChat.Call = CometChat.getActiveCall(); -``` - - - - - - - -The `getActiveCall()` method will only return the details of the active call for the ongoing session in which the call has been started. If the app is restarted, the data will be lost. - - - -## Call Participant Count - -In order to get the number of participants in any call, you can use the `getCallParticipantCount()` method. This method takes the session id for the call and returns the number of participants that are active in the call. - - - -```js -let sessionId = "CALL_SESSION_ID"; -let callType = "DEFAULT"; - -CometChat.getCallParticipantCount(sessionId, callType).then( - count => { - console.log("Participants count =", count); - }, error => { - console.log("Some error occurred =", error); - } -); -``` - - - - -```ts -let sessionId: string = "CALL_SESSION_ID"; -let callType: string = "DEFAULT"; - -CometChat.getCallParticipantCount(sessionId, callType).then( - (count: number) => { - console.log("Participants count =", count); - }, (error: CometChat.CometChatException) => { - console.log("Some error occurred =", error); - } -); -``` - - - - diff --git a/sdk/ionic-legacy/3.0/calling-direct-calling.mdx b/sdk/ionic-legacy/3.0/calling-direct-calling.mdx deleted file mode 100644 index b0b4358e0..000000000 --- a/sdk/ionic-legacy/3.0/calling-direct-calling.mdx +++ /dev/null @@ -1,196 +0,0 @@ ---- -title: "Direct Calling" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -This section will guide you to start the call/conference directly with the session id of your choice. The session id is the most important parameter as all the users joining the same session id will be connected to the same call/conference. - -## Implementation - -The most important class that will be used in the implementation is the `CallSettings` class. This class allows you to set the various parameters for the call/conference. In order to set the various parameters of the `CallSettings` class, you need to use the `CallSettingsBuilder` class. Below are the various options available with the `CallSettings` class. - -The mandatory parameter is the sessionId for the call/conference. You can use the setSessionId() method of the `CallSettingsBuilder` to set the session Id of the call. - -A basic example of how to start a direct call: - - - -```js -let sessionID = "SESSION_ID"; -let audioOnly = false; -let defaultLayout = true; -let callListener: CometChat.OngoingCallListener = new CometChat.OngoingCallListener({ - onUserJoined: (user: CometChat.User) => { - console.log("user joined:", user); - }, - onUserLeft: (user: CometChat.User) => { - console.log("user left:", user); - }, - onUserListUpdated: (userList: CometChat.User[]) => { - console.log("user list:", userList); - }, - onCallEnded: (call: CometChat.Call) => { - console.log("Call ended:", call); - }, - onError: (error: CometChat.CometChatException) => { - console.log("Error :", error); - }, - onAudioModesUpdated: (audioModes: CometChat.AudioMode[]) => { - console.log("audio modes:", audioModes); - }, - onCallSwitchedToVideo: (sessionId, callSwitchInitiatedBy, callSwitchAcceptedBy) => { - console.log("call switched to video:", {sessionId, callSwitchInitiatedBy, callSwitchAcceptedBy}); - }, - onUserMuted: (userMuted, userMutedBy) => { - console.log("user muted:", {userMuted, userMutedBy}); - } -}); - -let callSettings = new CometChat.CallSettingsBuilder() - .enableDefaultLayout(defaultLayout) - .setSessionID(sessionID) - .setIsAudioOnlyCall(audioOnly) - .setCallEventListener(callListener) - .build(); - -CometChat.startCall(callSettings); -``` - - - - -```ts -let sessionID: string = "SESSION_ID"; -let audioOnly: boolean = false; -let defaultLayout: boolean = true; -let callListener: CometChat.OngoingCallListener = new CometChat.OngoingCallListener({ - onUserJoined: (user: CometChat.User) => { - console.log("user joined:", user); - }, - onUserLeft: (user: CometChat.User) => { - console.log("user left:", user); - }, - onUserListUpdated: (userList: CometChat.User[]) => { - console.log("user list:", userList); - }, - onCallEnded: (call: CometChat.Call) => { - console.log("Call ended:", call); - }, - onError: (error: CometChat.CometChatException) => { - console.log("Error :", error); - }, - onAudioModesUpdated: (audioModes: CometChat.AudioMode[]) => { - console.log("audio modes:", audioModes); - } -}); - -let callSettings: CometChat.CallSettings = new CometChat.CallSettingsBuilder() - .enableDefaultLayout(defaultLayout) - .setSessionID(sessionID) - .setIsAudioOnlyCall(audioOnly) - .setCallEventListener(callListener) - .build(); - -CometChat.startCall(callSettings); -``` - - - - - -The `setAudioOnlyCall()` method allows you to set if the call is supposed to be an audio call or an audio-video call. If set to true, the call will be an audio-only call else when set to false the call will be an audio-video call. The default is false, so if not set, the call will be an audio-video call. - -| Parameter | Description | -| -------------- | ----------------------------- | -| `callSettings` | Object of CallSettings class. | - -The `OngoingCallListener` listener provides you with the below callback methods: - -| Callback Method | Description | -| ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | -| `onUserJoined(User user)` | This method is called when any other user joins the call. The user details can be obtained from the `User` object provided. | -| `onUserLeft(User user)` | This method is called when a user leaves the call. The details of the user can be obtained from the provided `User` object. | -| `onCallEnded()` | This method is called when the call is successfully ended. | -| `onUserListUpdated(userList)` | This method is triggered every time a participant joins or leaves the call providing the list of users active in the call. | -| `onAudioModesUpdated(audioModes)` | This callback is triggered if any new audio output source is available or becomes unavailable. | -| `onCallSwitchedToVideo(sessionId, callSwitchInitiatedBy, callSwitchAcceptedBy)` | This callback is triggered when an audio call is converted into a video call. | -| `onUserMuted(userMuted, userMutedBy)` | This callback is triggered when a user is muted in the call. | - -## Settings - -The `CallSettings` class is the most important class when it comes to the implementation of the Calling feature. This is the class that allows you to customize the overall calling experience. The properties for the call/conference can be set using the `CallSettingsBuilder` class. This will eventually give you and object of the `CallSettings` class which you can pass to the `startCall()` method to start the call. - -The **mandatory** parameters that are required to be present for any call/conference to work are: - -1. sessionId - The unique session Id for the call/conference session. - -The options available for customization of calls are: - -| Setting | Description | -| ---------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `enableDefaultLayout(defaultLayout: boolean)` | If set to `true` enables the default layout for handling the call operations. If set to `false` it hides the button layout and just displays the Call View. **Default value = true** | -| `showEndCallButton(showEndCallButton: boolean)` | If set to `true` it displays the EndCallButton in Button Layout. if set to `false` it hides the EndCallButton in Button Layout. **Default value = true** | -| `showPauseVideoButton(showPauseVideoButton: boolean)` | If set to `true` it displays the PauseVideoButton in Button Layout. if set to `false` it hides the PauseVideoButton in Button Layout. **Default value = true** | -| `showMuteAudioButton(showMuteAudioButton: boolean)` | If set to `true` it displays the MuteAudioButton in Button Layout. if set to `false` it hides the MuteAudioButton in Button Layout. **Default value = true** | -| `showSwitchCameraButton(showSwitchCameraButton: boolean)` | If set to `true` it displays the SwitchCameraButton in Button Layout. if set to `false` it hides the SwitchCameraButton in Button Layout. **Default value = true** | -| `showAudioModeButton(showAudioModeButton: boolean)` | If set to `true` it displays the AudioModeButton in Button Layout. if set to `false` it hides the AudioModeButton in Button Layout. **Default value = true** | -| `setIsAudioOnlyCall(audioOnly: boolean)` | If set to true, the call will be strictly an audio call. If ser to false, the call will be an audio-video call. **Default value = false** | -| `setMode(mode: string)` | CometChat provides 3 options for the calling UI. 1. CometChat.CALL\_MODE.DEFAULT 2. CometChat.CALL\_MODE.SPOTLIGHT 3. CometChat.CALL\_MODE.SINGLE **Default value = CometChat.CALL\_MODE.DEFAULT** | -| `startWithAudioMuted(audioMuted: boolean)` | This ensures the call is started with the audio muted if set to true. **Default value = false** | -| `startWithVideoMuted(videoMuted: boolean)` | This ensures the call is started with the video paused if set to true. **Default value = false** | -| `setDefaultAudioMode(audioMode: string)` | This method can be used if you wish to start the call with a specific audio mode. The available options are 1. CometChat.AUDIO\_MODE.SPEAKER = "SPEAKER" 2. CometChat.AUDIO\_MODE.EARPIECE = "EARPIECE" 3. CometChat.AUDIO\_MODE.BLUETOOTH = "BLUETOOTH" 4. CometChat.AUDIO\_MODE.HEADPHONES = "HEADPHONES" | -| `showSwitchToVideoCallButton(switchCall: boolean)` | This method shows/hides the switch to video call button. If set to true it will display the switch to video call button. If set to false it will hide the switch to video call button. **Default value = true** | -| `setAvatarMode(avatarMode: string)` | This method sets the mode of avatar. The avatar mode can be `circle`, `square` or `fullscreen`. **Default value = circle** | -| `setMainVideoContainerSetting(containerSettings: MainVideoContainerSetting)` | This method can be used to customize the main video container. You can read more about this [here](/sdk/ionic-legacy/3.0/video-view-customisation). | -| `enableVideoTileClick(enableVideoTileClick: boolean)` | This method can be used to enable/disable video tile click functionality in **Spotlight** mode. **Default value = true** | -| `enableVideoTileDrag(enableVideoTileDrag: boolean)` | This method can be used to enable/disable video tile drag functionality in **Spotlight** mode. **Default value = true** | - - - -The `CometChat.getActiveCall()` method in case of Direct Calling will return null and all the details related to the call session will have to be saved and maintained at your end. - - - -## Call Participant Count - -In order to get the number of participants in any call, you can use the `getCallParticipantCount()` method. This method takes the session id for the call and returns the number or participants that are active in the call. - - - -```js -let sessionId = "CALL_SESSION_ID"; -let callType = "DIRECT"; - -CometChat.getCallParticipantCount(sessionId, callType).then( - count => { - console.log("Participants count =", count); - }, error => { - console.log("Some error occurred =", error); - } -); -``` - - - - -```ts -let sessionId: string = "CALL_SESSION_ID"; -let callType: string = "DIRECT"; - -CometChat.getCallParticipantCount(sessionId, callType).then( - (count: number) => { - console.log("Participants count =", count); - }, (error: CometChat.CometChatException) => { - console.log("Some error occurred =", error); - } -); -``` - - - - diff --git a/sdk/ionic-legacy/3.0/calling-recording.mdx b/sdk/ionic-legacy/3.0/calling-recording.mdx deleted file mode 100644 index 224ef92d3..000000000 --- a/sdk/ionic-legacy/3.0/calling-recording.mdx +++ /dev/null @@ -1,111 +0,0 @@ ---- -title: "Recording (Beta)" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -This section will guide you to implement call recording feature for the voice and video calls. - -## Implementation - -Once you have decided to implement [Default Calling](/sdk/ionic-legacy/3.0/calling-default-calling) or [Direct Calling](/sdk/ionic-legacy/3.0/calling-direct-calling) and followed the steps to implement them. Just few additional listeners and methods will help you quickly implement call recording in your app. - -You need to make changes in the CometChat.startCall method and add the required listeners for recording. Please make sure your callSettings is configured accordingly for [Default Calling](/sdk/ionic-legacy/3.0/calling-default-calling) or [Direct Calling](/sdk/ionic-legacy/3.0/calling-direct-calling). - -A basic example of how to make changes to implement recording for a direct call/ a default call: - - - -```js -// Add listeners onRecordingStarted and onRecordingStopped to the startCall method -let sessionId = "SESSION_ID"; -let audioOnly = false; -let defaultLayout = true; -let showRecordingButton = true; - -let callSettings = new CometChat.CallSettingsBuilder() - .enableDefaultLayout(defaultLayout) - .showRecordingButton(showRecordingButton) - .setSessionID(sessionId) - .setIsAudioOnlyCall(audioOnly) - .build(); - -CometChat.startCall( - callSettings, - document.getElementById("callScreen"), - new CometChat.OngoingCallListener({ - onRecordingStarted: recordingStartedBy => { - // This event will work in JS SDK v3.0.8 & later. - console.log("Listener => onRecordingStarted:", recordingStartedBy); - }, - onRecordingStopped: recordingStoppedBy => { - // This event will work in JS SDK v3.0.8 & later. - console.log("Listener => onRecordingStopped:", recordingStoppedBy); - }, - }) -); -``` - - - - -```ts -// Add listeners onRecordingStarted and onRecordingStopped to the startCall method. -let sessionId: string = "SESSION_ID"; -let audioOnly: boolean = false; -let defaultLayout: boolean = true; -let showRecordingButton: boolean = true; - -let callSettings: CometChat.CallSettings = new CometChat.CallSettingsBuilder() - .enableDefaultLayout(defaultLayout) - .showRecordingButton(showRecordingButton) - .setSessionID(sessionId) - .setIsAudioOnlyCall(audioOnly) - .build(); - -CometChat.startCall( - callSettings, - document.getElementById("callScreen"), - new CometChat.OngoingCallListener({ - onRecordingStarted: (recordingStartedBy: CometChat.User) => { - // This event will work in JS SDK v3.0.8 & later. - console.log("Listener => onRecordingStarted:", recordingStartedBy); - }, - onRecordingStopped: (recordingStoppedBy: CometChat.User) => { - // This event will work in JS SDK v3.0.8 & later. - console.log("Listener => onRecordingStopped:", recordingStoppedBy); - }, - }) -); -``` - - - - - -## Settings for call recording - -The `CallSettings` class allows you to customise the overall calling experience. The properties for the call/conference can be set using the `CallSettingsBuilder` class. This will eventually give you and object of the `CallSettings` class which you can pass to the `startCall()` method to start the call. - -The **mandatory** parameters that are required to be present for any call/conference to work are: - -1. sessionId - The unique session Id for the call/conference session. - -The options available for recording of calls are: - -| Setting | Description | -| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `showRecordingButton(showRecordingButton: boolean)` | If set to `true` it displays the Recording button in the button Layout.
if set to `false` it hides the Recording button in the button Layout.
**Default value = false** | -| `startRecordingOnCallStart(startRecordingOnCallStart: boolean)` | If set to `true` call recording will start as soon as the call is started.
if set to `false` call recording will not start as soon as the call is started.
**Default value = false** | - -## Downloading Recording - -Currently, the call recordings are available on the [CometChat Dashboard](https://app.cometchat.com) under the Calls Section. You can refer to the below screenshot. - - - - diff --git a/sdk/ionic-legacy/3.0/calling-v3.mdx b/sdk/ionic-legacy/3.0/calling-v3.mdx deleted file mode 100644 index a87d0f3b3..000000000 --- a/sdk/ionic-legacy/3.0/calling-v3.mdx +++ /dev/null @@ -1,33 +0,0 @@ ---- -title: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -Calling is a core feature of CometChat. Calling allows users to connect over voice/video calls. - -## Prerequisites - -1. CometChat Core SDK installed. -2. Performed the steps mentioned in the [Setup](/sdk/ionic-legacy/3.0/setup#calling-component-configuration) guide - -**CometChat allows two mechanisms for calling:** - -1. **Direct Calling** -2. **Default Calling** - - - - - -## Direct Calling - -Direct Calling allows you to start the call/conference sessions directly with the session Id of your choice. All the users joining the same session Id are connected to the same call/conference. For more information on Direct Calling, please visit the [Direct Calling docs](/sdk/ionic-legacy/3.0/calling-direct-calling). - -## Default Calling - -The second approach that CometChat allows is to implement the entire calling flow where one user initiates a call/conference and other user/users who want to be a part of the call accept/reject the call. All the users that accept the call are connected to the same session. For more information on Default Calling, please visit the [Default Calling docs](/sdk/ionic-legacy/3.0/calling-default-calling). diff --git a/sdk/ionic-legacy/3.0/calling.mdx b/sdk/ionic-legacy/3.0/calling.mdx deleted file mode 100644 index 796294c57..000000000 --- a/sdk/ionic-legacy/3.0/calling.mdx +++ /dev/null @@ -1,46 +0,0 @@ ---- -title: "Calling" -sidebarTitle: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -Calling is a core feature of CometChat. Calling allows users to connect over voice/video calls. - -## Prerequisites - -1. CometChat Core SDK installed. -2. Performed the steps mentioned in the [Setup](/sdk/ionic-legacy/3.0/setup#calling-component-configuration) guide - - - -v2.4+ onwards, Voice & Video Calling functionality has been moved to a separate library. Please add the following dependency to your package.json file in case you plan on using the Voice and Video Calling feature. - -For capacitor v2 apps, `dependencies: {> "@cometchat-pro/ionic-calls": "2.1.2"> }` - -For capacitor v3 apps, `dependencies: { "@cometchat-pro/ionic-calls": "2.3.0" }` - -And run `npm install` to install the package. - - - -**CometChat allows two mechanisms for calling:** - -1. **Direct Calling** -2. **Default Calling** - - - - - -## Direct Calling - -Direct Calling allows you to start the call/conference sessions directly with the session Id of your choice. All the users joining the same session Id are connected to the same call/conference. For more information on Direct Calling, please visit the [Direct Calling docs](/sdk/ionic-legacy/3.0/calling-direct-calling). - -## Default Calling - -The second approach that CometChat allows is to implement the entire calling flow where one user initiates a call/conference and other user/users who want to be a part of the call accept/reject the call. All the users that accept the call are connected to the same session. For more information on Default Calling, please visit the [Default Calling docs](/sdk/ionic-legacy/3.0/calling-default-calling). diff --git a/sdk/ionic-legacy/3.0/groups-add-members-to-group.mdx b/sdk/ionic-legacy/3.0/groups-add-members-to-group.mdx deleted file mode 100644 index 3fabab835..000000000 --- a/sdk/ionic-legacy/3.0/groups-add-members-to-group.mdx +++ /dev/null @@ -1,122 +0,0 @@ ---- -title: "Add Members To A Group" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Add Members to Group - -You can add members to the group using the `addMembersToGroup()` method. This method takes the below parameters: - -1. `GUID` - GUID of the group the members are to be added to. -2. `Array members` - This is a list of `GroupMember` objects. In order to add members, you need to create an object of the `GroupMember` class. The UID and the scope of the `GroupMember` are mandatory. -3. `Array bannedMembers` - This is the list of `UID's` that need to be banned from the Group. This can be set to `null` if there are no members to be banned. - - - -```js -let GUID = "GUID"; -let UID = "UID"; -let membersList = [ - new CometChat.GroupMember(UID, CometChat.GROUP_MEMBER_SCOPE.PARTICIPANT) -]; - -CometChat.addMembersToGroup(GUID, membersList, []).then( - response => { - console.log("response", response); - }, error => { - console.log("Something went wrong", error); - } -); -``` - - - - -```ts -let GUID: string = "GUID"; -let UID: string = "UID"; -let membersList: CometChat.GroupMember[] = [ - new CometChat.GroupMember(UID, CometChat.GROUP_MEMBER_SCOPE.PARTICIPANT) -]; - -CometChat.addMembersToGroup(GUID, membersList, []).then( - (response: Object) => { - console.log("response", response); - }, (error: CometChat.CometChatException) => { - console.log("Something went wrong", error); - } -); -``` - - - - - -It will return a Array which will contain the `UID` of the users and the value will either be `success` or an error message describing why the operation to add the user to the group. - -## Real-Time Group Member Added Events - -*In other words, as a member of a group, how do I know when someone is added to the group when my app is running?* - - - -When a group member is added by another member, this event is triggered. When a user joins a group on their own, the joined event is triggered. - - - -To receive real-time events whenever a new member is added to a group, you need to implement the `onMemberAddedToGroup()` methods of the `GroupListener` class. - -`onMemberAddedToGroup()` - This method is triggered when any user is added to the group so that the logged in user is informed of the other members added to the group. - - - -```js -var listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.addGroupListener( - listenerID, - new CometChat.GroupListener({ - onMemberAddedToGroup: (message, userAdded, userAddedBy, userAddedIn) => { - console.log("User joined", {message, userAdded, userAddedBy, userAddedIn}); - } - }) -); -``` - - - - -```ts -var listenerID: string = "UNIQUE_LISTENER_ID"; - -CometChat.addGroupListener( - listenerID, - new CometChat.GroupListener({ - onMemberAddedToGroup: (message: CometChat.Action, userAdded: CometChat.User, userAddedBy: CometChat.User, userAddedIn: CometChat.Group) => { - console.log("User joined", { message, userAdded, userAddedBy, userAddedIn }); - } - }) -); -``` - - - - - -## Member Added to Group event in Message History - -*In other words, as a member of a group, how do I know when someone is added to the group when my app is not running?* - -When you retrieve the list of previous messages if a member has been added to any group that the logged-in user is a member of, the list of messages will contain an `Action` message. An `Action` message is a sub-class of `BaseMessage` class. - -For the group member added event, in the `Action` object received, the following fields can help you get the relevant information- - -1. `action` - `added` -2. `actionOn` - User object containing the details of the user who was added to the group -3. `actionBy` - User object containing the details of the user who added the member to the group -4. `actionFor` - Group object containing the details of the group to which the member was added diff --git a/sdk/ionic-legacy/3.0/groups-change-member-scope.mdx b/sdk/ionic-legacy/3.0/groups-change-member-scope.mdx deleted file mode 100644 index 22d2d0e49..000000000 --- a/sdk/ionic-legacy/3.0/groups-change-member-scope.mdx +++ /dev/null @@ -1,115 +0,0 @@ ---- -title: "Change Member Scope" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Change Scope of a Group Member - -In order to change the scope of a group member, you can use the `changeGroupMemberScope()`. - - - -```js -var GUID = "GUID"; -var UID = "UID"; -var scope = CometChat.GROUP_MEMBER_SCOPE.ADMIN; - -CometChat.updateGroupMemberScope(GUID, UID, scope).then( - response => { - console.log("Group member scopped changed", response); - }, error => { - console.log("Group member scopped changed failed", error); - } -); -``` - - - - -```ts -let GUID: string = "GUID"; -let UID: string = "UID"; - -CometChat.updateGroupMemberScope(GUID, UID, CometChat.GroupMemberScope.Admin).then( - (response: boolean) => { - console.log("Group member scopped changed", response); - }, (error: CometChat.CometChatException) => { - console.log("Group member scopped changed failed", error); - } -); -``` - - - - - -This method takes the below parameters: - -| Parameter | Description | -| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `UID` | The UID of the member whose scope you would like to change | -| `GUID` | The GUID of the group for which the member's scope needs to be changed | -| `scope` | The updated scope of the member. This can be either of the 3 values: 1.`CometChatConstants.SCOPE_ADMIN` (admin) 2.`CometChatConstants.SCOPE_MODERATOR` (moderator) 3.`CometChatConstants.SCOPE_PARTICIPANT` (participant) | - -The default scope of any member is `participant`. Only the **Admin** of the group can change the scope of any participant in the group. - -## Real-Time Group Member Scope Changed Events - -*In other words, as a member of a group, how do I know when someone's scope is changed when my app is running?* - -In order to receive real-time events for the change member scope event, you will need to override the `onGroupMemberScopeChanged()` method of the `GroupListener` class - - - -```js -let listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.addGroupListener( - listenerID, - new CometChat.GroupListener({ - onGroupMemberScopeChanged: (message, changedUser, newScope, oldScope, changedGroup) => { - console.log("User joined", {message, changedUser, newScope, oldScope, changedGroup}); - } - }) -); -``` - - - - -```ts -let listenerID: string = "UNIQUE_LISTENER_ID"; - -CometChat.addGroupListener( - listenerID, - new CometChat.GroupListener({ - onGroupMemberScopeChanged: (message: CometChat.Action, changedUser: CometChat.User, newScope: string, oldScope: string, changedGroup: CometChat.Group) => { - console.log("User joined", { message, changedUser, newScope, oldScope, changedGroup }); - } - }) -); -``` - - - - - -## Missed Group Member Scope Changed Events - -*In other words, as a member of a group, how do I know when someone's scope is changed when my app is not running?* - -When you retrieve the list of previous messages if a member's scope has been changed for any group that the logged-in user is a member of, the list of messages will contain an `Action` message. An `Action` message is a sub-class of `BaseMessage` class. - -For the group member scope changed event, in the `Action` object received, the following fields can help you get the relevant information- - -1. `action` - `scopeChanged` -2. `actionOn` - User object containing the details of the user whose scope has been changed -3. `actionBy` - User object containing the details of the user who changed the scope of the member -4. `actionFor` - Group object containing the details of the group in which the member scope was changed -5. `oldScope` - The original scope of the member -6. `newScope` - The updated scope of the member diff --git a/sdk/ionic-legacy/3.0/groups-create-group.mdx b/sdk/ionic-legacy/3.0/groups-create-group.mdx deleted file mode 100644 index 164f80719..000000000 --- a/sdk/ionic-legacy/3.0/groups-create-group.mdx +++ /dev/null @@ -1,177 +0,0 @@ ---- -title: "Create A Group" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Create a Group - -*In other words, as a logged-in user, how do I create a public, private or password-protected group?* - -You can create a group using `createGroup()` method. This method takes a `Group` object as input. - -To create an object of `Group` class, you can use either of the below two constructors: - -1. `new Group(String GUID, String name, String groupType, String password)` -2. `new Group(String GUID, String name, String groupType, String password, String icon, String description)` - -The `groupType` needs to be either of the below 3 values: - -1.`CometChatConstants.GROUP_TYPE_PUBLIC` (public) - -2.`CometChatConstants.GROUP_TYPE_PASSWORD` (password) - -3.`CometChatConstants.GROUP_TYPE_PRIVATE` (private) - - - -```js -var GUID = "GUID"; -var groupName = "Hello Group!"; -var groupType = CometChat.GROUP_TYPE.PUBLIC; -var password = ""; - -var group = new CometChat.Group(GUID, groupName, groupType, password); - -CometChat.createGroup(group).then( - group => { - console.log("Group created successfully:", group); - }, error => { - console.log("Group creation failed with exception:", error); - } -); -``` - - - - -```ts -var GUID: string = "GUID"; -var groupName: string = "Hello Group!"; -var groupType: string = CometChat.GROUP_TYPE.PUBLIC; -var password: string = ""; - -var group: CometChat.Group = new CometChat.Group(GUID, groupName, groupType, password); - -CometChat.createGroup(group).then( - (group: CometChat.Group) => { - console.log("Group created successfully:", group); - }, (error: CometChat.CometChatException) => { - console.log("Group creation failed with exception:", error); - } -); -``` - - - - - -The createGroup() method takes the following parameters: - -| Parameter | Description | -| --------- | ---------------------------- | -| `group` | An instance of `Group` class | - -After successful creation of the group, you will receive an instance of `Group` class which contains all the information about the particular group. - - - -GUID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed. - - - -## Add members while creating a group - -You can create a group and add members at the same time using the `createGroupWithMembers()` method. This method takes the `Group` Object, Array of `Group Member` Object to be added & Array of `UIDs` to be banned. - -To create an object of `Group` class, you can use either of the below two constructors: - -1. `new Group(String GUID, String name, String groupType, String password)` -2. `new Group(String GUID, String name, String groupType, String password, String icon, String description)` - -The `groupType` needs to be either of the below 3 values: - -1. `CometChat.GROUP_TYPE.PUBLIC` -2. `CometChat.GROUP_TYPE.PASSWORD` -3. `CometChat.GROUP_TYPE.PRIVATE` - -To create an object of `Group Member` class, you can use the below constructor: - -* new CometChat.GroupMember(String UID, String scope) - - - -```js -let GUID = "cometchat-guid-11"; -let UID = "cometchat-uid-1"; -let groupName = "Hello Group!"; -let groupType = CometChat.GROUP_TYPE.PUBLIC; - -let group = new CometChat.Group(GUID, groupName, groupType); -let members = [ - new CometChat.GroupMember(UID, CometChat.GROUP_MEMBER_SCOPE.PARTICIPANT) -]; -let banMembers = ["cometchat-uid-2"]; - -CometChat.createGroupWithMembers(group, members, banMembers).then( - response => { - console.log("Group created successfully", response); - }, error => { - console.log("Some error occured while creating group", error) - } -); -``` - - - - -```ts -let GUID: string = "cometchat-guid-11"; -let UID: string = "cometchat-uid-1"; -let groupName: string = "Hello Group!"; -let groupType: string = CometChat.GROUP_TYPE.PUBLIC; - -let group: CometChat.Group = new CometChat.Group(GUID, groupName, groupType); -let members: Array = [ - new CometChat.GroupMember(UID, CometChat.GROUP_MEMBER_SCOPE.PARTICIPANT) -]; -let banMembers: Array = ["cometchat-uid-2"]; - -CometChat.createGroupWithMembers(group, members, banMembers).then( - (response: Object) => { - console.log("Group created successfully", response); - }, (error: CometChat.CometChatException) => { - console.log("Some error occured while creating group", error) - } -); -``` - - - - - -This method returns an Object which has two keys: `group` & `members` . The group key has the Group Object which contains all the information of the group which is created. The members key has the `UID` of the users and the value will either be `success` or an `error` message describing why the operation to add/ban the user failed. - -## Group Class - -| Field | Editable | Information | -| ------------ | --------------------------------------------------------------- | ------------------------------------------------------------------------- | -| guid | Needs to be specified at group creation. Cannot be edited later | A unique identifier for a group | -| name | Yes | Name of the group | -| type | No | Type of the group: Can be 1. Public 2. Password 3. Private | -| password | No | Password for the group in case the group is of type password. | -| icon | Yes | An URL to group icon | -| description | Yes | Description about the group | -| owner | Yes | UID of the owner of the group. | -| metadata | Yes | Additional data for the group as JSON | -| createdAt | No | The unix timestamp of the time the group was created | -| updatedAt | No | The unix timestamp of the time the group was last updated | -| hasJoined | No | A boolean to determine if the logged in user is a member of the group. | -| joinedAt | No | The unix timestamp of the time the logged in user joined the group. | -| scope | Yes | Scope of the logged in user. Can be: 1. Admin 2. Moderator 3. Participant | -| membersCount | No | The number of members in the groups | -| tags | Yes | A list of tags to identify specific groups. | diff --git a/sdk/ionic-legacy/3.0/groups-delete-group.mdx b/sdk/ionic-legacy/3.0/groups-delete-group.mdx deleted file mode 100644 index 32a907bed..000000000 --- a/sdk/ionic-legacy/3.0/groups-delete-group.mdx +++ /dev/null @@ -1,52 +0,0 @@ ---- -title: "Delete A Group" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Delete a Group - -To delete a group you need to use the `deleteGroup()` method. The user must be an `Admin` of the group they are trying to delete. - - - -```js -var GUID = "GUID"; - -CometChat.deleteGroup(GUID).then( - response => { - console.log("Groups deleted successfully:", response); - }, error => { - console.log("Group delete failed with exception:", error); - } -); -``` - - - - -```ts -var GUID: string = "GUID"; - -CometChat.deleteGroup(GUID).then( - (response: boolean) => { - console.log("Group deleted successfully:", response); - }, (error: CometChat.CometChatException) => { - console.log("Group delete failed with exception:", error); - } -); -``` - - - - - -The `deleteGroup()` method takes the following parameters: - -| Parameter | Description | -| --------- | ---------------------------------------------- | -| `GUID` | The GUID of the group you would like to delete | diff --git a/sdk/ionic-legacy/3.0/groups-join-group.mdx b/sdk/ionic-legacy/3.0/groups-join-group.mdx deleted file mode 100644 index fdd6efff1..000000000 --- a/sdk/ionic-legacy/3.0/groups-join-group.mdx +++ /dev/null @@ -1,111 +0,0 @@ ---- -title: "Join A Group" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Join a Group - -In order to start participating in group conversations, you will have to join a group. You can do so using the `joinGroup()` method. - - - -```js -var GUID = "GUID"; -var password = ""; -var groupType = CometChat.GROUP_TYPE.PUBLIC; - -CometChat.joinGroup(GUID, groupType, password).then( - group => { - console.log("Group joined successfully:", group); - }, error => { - console.log("Group joining failed with exception:", error); - } -); -``` - - - - -```ts -var GUID: string = "GUID"; - -CometChat.joinGroup(GUID, CometChat.GroupType.Public).then( - (group: CometChat.Group) => { - console.log("Group joined successfully:", group); - }, (error: CometChat.CometChatException) => { - console.log("Group joining failed with exception:", error); - } -); -``` - - - - - -The `joinGroup()` method takes the below parameters - -| Parameter | Description | -| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `GUID` | The GUID of the group you would like to join. | -| `groupType` | Type of the group. CometChat provides 3 types of groups viz. a. CometChatConstants.GROUP\_TYPE\_PUBLIC (public) b. CometChatConstants.GROUP\_TYPE\_\_\_PASSWORD (password) c. CometChatConstants.GROUP\_TYPE\_PRIVATE (private) | -| `password` | Password is mandatory in case of a password protected group. | - -Once you have joined a group successfully, you can send and receive messages in that group. - -CometChat keeps a track of the groups joined and you do not need to join the group every time you want to communicate in the group. - -You can identify if a group is joined using the `hasJoined` parameter in the `Group` object. - -## Real-time Group Member Joined Events - -*In other words, as a member of a group, how do I know if someone joins the group when my app is running?* - -If a user joins any group, the members of the group receive a real-time event in the `onGroupMemberJoined()` method of the `GroupListener` class. - - - -```js -CometChat.addGroupListener( - "UNIQUE_LISTNER_ID", - new CometChat.GroupListener({ - onGroupMemberJoined: (message, joinedUser, joinedGroup) => { - console.log("User joined", { message, joinedUser, joinedGroup }); - } - }) -); -``` - - - - -```ts -CometChat.addGroupListener( - "UNIQUE_LISTNER_ID", - new CometChat.GroupListener({ - onGroupMemberJoined: (message: CometChat.Action, joinedUser: CometChat.User, joinedGroup: CometChat.Group) => { - console.log("User joined", { message, joinedUser, joinedGroup }); - } - }) -); -``` - - - - - -## Missed Group Member Joined Events - -*In other words, as a member of a group, how do I know if someone joins the group when my app is not running?* - -When you retrieve the list of previous messages if a member has joined any group that the logged-in user is a member of, the list of messages will contain an `Action` message. An `Action` message is a sub-class of `BaseMessage` class. - -For the group member joined event, in the `Action` object received, the following fields can help you get the relevant information- - -1. `action` - `joined` -2. `actionBy` - User object containing the details of the user who joined the group -3. `actionFor`- Group object containing the details of the group the user has joined diff --git a/sdk/ionic-legacy/3.0/groups-kick-ban-members.mdx b/sdk/ionic-legacy/3.0/groups-kick-ban-members.mdx deleted file mode 100644 index 80c07ddc9..000000000 --- a/sdk/ionic-legacy/3.0/groups-kick-ban-members.mdx +++ /dev/null @@ -1,361 +0,0 @@ ---- -title: "Ban/Kick Member From A Group" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -There are certain actions that can be performed on the group members: - -1. Kick a member from the group -2. Ban a member from the group -3. Unban a member from the group -4. Update the scope of the member of the group - -All the above actions can only be performed by the **Admin** or the **Moderator** of the group. - -## Kick a Group Member - -The Admin or Moderator of a group can kick a member out of the group using the `kickGroupMember()` method. - - - -```js -var GUID = "GUID"; -var UID = "UID"; - -CometChat.kickGroupMember(GUID, UID).then( - response => { - console.log("Group member kicked successfully", response); - }, error => { - console.log("Group member kicking failed with error", error); - } -); -``` - - - - -```ts -yarn add @cometchat-pro/ionic-calls@latestlet GUID: string = "GUID"; -let UID: string = "UID"; - -CometChat.kickGroupMember(GUID, UID).then( - (response: Object) => { - console.log("Group member kicked successfully", response); - }, (error: CometChat.CometChatException) => { - console.log("Group member kicking failed with error", error); - } -); -``` - - - - - -The `kickGroupMember()` takes following parameters - -| Parameter | Description | -| --------- | ----------------------------------------------------- | -| `UID` | The UID of the user to be kicked. | -| `GUID` | The GUID of the group from which user is to be kicked | - -The kicked user will be no longer part of the group and can not perform any actions in the group, but the kicked user can rejoin the group. - -## Ban a Group Member - -The Admin or Moderator of the group can ban a member from the group using the `banGroupMember()` method. - - - -```js -var GUID = "GUID"; -var UID = "UID"; - -CometChat.banGroupMember(GUID, UID).then( - response => { - console.log("Group member banned successfully", response); - }, error => { - console.log("Group member banning failed with error", error); - } -); -``` - - - - -```ts -let GUID: string = "GUID"; -let UID: string = "UID"; - -CometChat.banGroupMember(GUID, UID).then( - (response: Object) => { - console.log("Group member banned successfully", response); - }, (error: CometChat.CometChatException) => { - console.log("Group member banning failed with error", error); - } -); -``` - - - - - -The `banGroupMember()` method takes the following parameters: - -| Parameter | Description | -| --------- | ------------------------------------------------------ | -| `UID` | The UID of the user to be banned. | -| `GUID` | The GUID of the group from which user is to be banned. | - -The banned user will be no longer part of the group and can not perform any actions in the group. A banned user cannot rejoin the same group without being unbanned. - -## Unban a Banned Group Member from a Group - -Only Admin or Moderators of the group can unban a previously banned member from the group using the `unbanGroupMember()` method. - - - -```js -var GUID = "GUID"; -var UID = "UID"; - -CometChat.unbanGroupMember(GUID, UID).then( - response => { - console.log("Group member unbanned successfully", response); - }, error => { - console.log("Group member unbanning failed with error", error); - } -); -``` - - - - -```ts -let GUID: string = "GUID"; -let UID: string = "UID"; - -CometChat.unbanGroupMember(GUID, UID).then( - (response: Object) => { - console.log("Group member unbanned successfully", response); - }, (error: CometChat.CometChatException) => { - console.log("Group member unbanning failed with error", error); - } -); -``` - - - - - -The `unbanGroupMember()` method takes the following parameters - -| Parameter | Description | -| --------- | ---------------------------------------------------- | -| `UID` | The UID of the user to be unbanned. | -| `GUID` | The UID of the group from which user is to be banned | - -The unbanned user can now rejoin the group. - -## Get List of Banned Members for a Group - -In order to fetch the list of banned groups members for a group, you can use the `BannedGroupMembersRequest` class. To use this class i.e to create an object of the BannedGroupMembersRequest class, you need to use the `BannedGroupMembersRequestBuilder` class. The `BannedGroupMembersRequestBuilder` class allows you to set the parameters based on which the banned group members are to be fetched. - -The `BannedGroupMembersRequestBuilder` class allows you to set the below parameters: - -The `GUID` of the group for which the banned members are to be fetched must be specified in the constructor of the `GroupMembersRequestBuilder` class. - -### Set Limit - -This method sets the limit i.e. the number of banned members that should be fetched in a single iteration. - - - -```js -let GUID = "GUID"; -let limit = 30; -let bannedGroupMembersRequest = new CometChat.BannedMembersRequestBuilder(GUID) - .setLimit(limit) - .build(); -``` - - - - -```ts -let GUID: string = "GUID"; -let limit: number = 30; -let bannedGroupMembersRequest: CometChat.BannedMembersRequest = new CometChat.BannedMembersRequestBuilder(GUID) - .setLimit(limit) - .build(); -``` - - - - - -### Set Search Keyword - -This method allows you to set the search string based on which the banned group members are to be fetched. - - - -```js -let GUID = "GUID"; -let limit = 30; -let searchKeyword = "super"; -let bannedGroupMembersRequest = new CometChat.BannedMembersRequestBuilder(GUID) - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - -```ts -let GUID: string = "GUID"; -let limit: number = 30; -let searchKeyword: string = "super"; -let bannedGroupMembersRequest: CometChat.BannedMembersRequest = new CometChat.BannedMembersRequestBuilder(GUID) - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - - -Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the `BannedGroupMembersRequest` class. - -Once you have the object of the `BannedGroupMembersRequest` class, you need to call the `fetchNext()` method. Calling this method will return a list of `GroupMember` objects containing n number of banned members where n is the limit set in the builder class. - - - -```js -let GUID = "GUID"; -let limit = 30; -let bannedMembersRequest = new CometChat.BannedMembersRequestBuilder(GUID) - .setLimit(limit) - .build(); - -bannedMembersRequest.fetchNext().then( - bannedMembers => { - console.log("Banned Group Member list fetched successfully:", bannedMembers); - }, error => { - console.log("Banned Group Member list fetching failed with exception:", error); - } -); -``` - - - - -```ts -let GUID: string = "GUID"; -let limit: number = 30; -let bannedGroupMembersRequest: CometChat.BannedMembersRequest = new CometChat.BannedMembersRequestBuilder(GUID) - .setLimit(limit) - .build(); - -bannedGroupMembersRequest.fetchNext().then( - (bannedMembers: CometChat.GroupMember[]) => { - console.log("Banned Group Member list fetched successfully:", bannedMembers); - }, (error: CometChat.CometChatException) => { - console.log("Banned Group Member list fetching failed with exception:", error); - } -); -``` - - - - - -## Real-Time Group Member Kicked/Banned Events - -*In other words, as a member of a group, how do I know when someone is banned/kicked when my app is running?* - -In order to get real-time events for the kick/ban/unban group members you need to override the following methods of the `GroupListener` class. - -1. `onGroupMemberKicked()` - triggered when any group member has been kicked. -2. `onGroupMemberBanned()` - triggered when any group member has been banned. -3. `onGroupMemberUnbanned()` - triggered when any group member has been unbanned. - - - -```js -let listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.addGroupListener( - listenerID, - new CometChat.GroupListener({ - onGroupMemberKicked: (message, kickedUser, kickedBy, kickedFrom) => { - console.log("User kicked", { message, kickedUser, kickedBy, kickedFrom }); - }, - onGroupMemberBanned: (message, bannedUser, bannedBy, bannedFrom) => { - console.log("User banned", { message, bannedUser, bannedBy, bannedFrom }); - }, - onGroupMemberUnbanned: (message, unbannedUser, unbannedBy,unbannedFrom) => { - console.log("User unbanned", {message, unbannedUser, unbannedBy, unbannedFrom}); - } - }) -); -``` - - - - -```ts -let listenerID: string = "UNIQUE_LISTENER_ID"; - -CometChat.addGroupListener( - listenerID, - new CometChat.GroupListener({ - onGroupMemberKicked: (message: CometChat.Action, kickedUser: CometChat.User, kickedBy: CometChat.User, kickedFrom: CometChat.Group) => { - console.log("User kicked", { message, kickedUser, kickedBy, kickedFrom }); - }, - onGroupMemberBanned: (message: CometChat.Action, bannedUser: CometChat.User, bannedBy: CometChat.User, bannedFrom: CometChat.Group) => { - console.log("User banned", { message, bannedUser, bannedBy, bannedFrom }); - }, - onGroupMemberUnbanned: (message: CometChat.Action, unbannedUser: CometChat.User, unbannedBy: CometChat.User, unbannedFrom: CometChat.Group) => { - console.log("User unbanned", { message, unbannedUser, unbannedBy, unbannedFrom }); - } - }) -); -``` - - - - - -## Missed Group Member Kicked/Banned Events - -*In other words, as a member of a group, how do I know when someone is banned/kicked when my app is not running?* - -When you retrieve the list of previous messages if a member has been kicked/banned/unbanned from any group that the logged-in user is a member of, the list of messages will contain an `Action` message. An `Action` message is a sub-class of `BaseMessage` class. - -For group member kicked event, the details can be obtained using the below fields of the `Action` class- - -1. `action` - `kicked` -2. `actionBy` - User object containing the details of the user who has kicked the member -3. `actionOn` - User object containing the details of the member that has been kicked -4. `actionFor` - Group object containing the details of the Group from which the member was kicked - -For group member banned event, the details can be obtained using the below fields of the `Action` class- - -1. `action` - `banned` -2. `actionBy` - User object containing the details of the user who has banned the member -3. `actionOn` - User object containing the details of the member that has been banned -4. `actionFor` - Group object containing the details of the Group from which the member was banned - -For group member unbanned event, the details can be obtained using the below fields of the `Action` class- - -1. `action` - `unbanned` -2. `actionBy` - User object containing the details of the user who has unbanned the member -3. `actionOn` - User object containing the details of the member that has been unbanned -4. `actionFor` - Group object containing the details of the Group from which the member was unbanned diff --git a/sdk/ionic-legacy/3.0/groups-leave-group.mdx b/sdk/ionic-legacy/3.0/groups-leave-group.mdx deleted file mode 100644 index eb5c975eb..000000000 --- a/sdk/ionic-legacy/3.0/groups-leave-group.mdx +++ /dev/null @@ -1,101 +0,0 @@ ---- -title: "Leave A Group" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Leave a Group - -In order to stop receiving updates and messages for any particular joined group, you will have to leave the group using the `leaveGroup()` method. - - - -```js -var GUID = "GUID"; // guid of the group to join - -CometChat.leaveGroup(GUID).then( - hasLeft => { - console.log("Group left successfully:", hasLeft); - }, error => { - console.log("Group leaving failed with exception:", error); - } -); -``` - - - - -```ts -var GUID: string = "GUID"; - -CometChat.leaveGroup(GUID).then( - (hasLeft: boolean) => { - console.log("Group left successfully:", hasLeft); - }, (error: CometChat.CometChatException) => { - console.log("Group leaving failed with exception:", error); - } -); -``` - - - - - -| Parameter | Description | -| --------- | -------------------------------------------- | -| `GUID` | The UID of the group you would like to leave | - -Once a group is left, the user will no longer receive any updates or messages pertaining to the group. - -## Real-time Group Member Left Events - -*In other words, as a member of a group, how do I know if someone has left it?* - -If a user leaves any group, The members of the group receive a real-time event in the `onGroupMemberLeft()` method of the `GroupListener` class. - - - -```js -CometChat.addGroupListener( - "UNIQUE_LISTENER_ID", - new CometChat.GroupListener({ - onGroupMemberLeft: (message, leavingUser, group) => { - console.log("User left", { message, leavingUser, group }); - } - }) -); -``` - - - - -```ts -CometChat.addGroupListener( - "UNIQUE_LISTENER_ID", - new CometChat.GroupListener({ - onGroupMemberLeft: (message: CometChat.Action, leavingUser: CometChat.User, group: CometChat.Group) => { - console.log("User left", { message, leavingUser, group }); - } - }) -); -``` - - - - - -## Missed Group Member Left Events - -*In other words, as a member of a group, how do I know if someone has left it when my app is not running?* - -When you retrieve the list of previous messages if a member has left any group that the logged-in user is a member of, the list of messages will contain an `Action` message. An `Action` message is a sub-class of `BaseMessage` class. - -For the group member left event, in the `Action` object received, the following fields can help you get the relevant information- - -1. `action` - `left` -2. `actionBy` - User object containing the details of the user who left the group -3. `actionFor` - Group object containing the details of the group the user has left diff --git a/sdk/ionic-legacy/3.0/groups-retrieve-group-members.mdx b/sdk/ionic-legacy/3.0/groups-retrieve-group-members.mdx deleted file mode 100644 index c737fa21b..000000000 --- a/sdk/ionic-legacy/3.0/groups-retrieve-group-members.mdx +++ /dev/null @@ -1,158 +0,0 @@ ---- -title: "Retrieve Group Members" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Retrieve the List of Group Members - -In order to fetch the list of groups members for a group, you can use the `GroupMembersRequest` class. To use this class i.e to create an object of the GroupMembersRequest class, you need to use the `GroupMembersRequestBuilder` class. The `GroupMembersRequestBuilder` class allows you to set the parameters based on which the groups are to be fetched. - -The `GroupMembersRequestBuilder` class allows you to set the below parameters: - -The GUID of the group for which the members are to be fetched must be specified in the constructor of the `GroupMembersRequestBuilder` class. - -### Set Limit - -This method sets the limit i.e. the number of members that should be fetched in a single iteration. - - - -```js -let GUID = "GUID"; -let limit = 30; -let groupMembersRequest = new CometChat.GroupMembersRequestBuilder(GUID) - .setLimit(limit) - .build(); -``` - - - - -```ts -let GUID: string = "GUID"; -let limit: number = 30; -let groupMembersRequest: CometChat.GroupMembersRequest = - new CometChat.GroupMembersRequestBuilder(GUID).setLimit(limit).build(); -``` - - - - - -### Set Search Keyword - -This method allows you to set the search string based on which the group members are to be fetched. - - - -```js -let GUID = "GUID"; -let limit = 30; -let searchKeyword = "super"; -let groupMembersRequest = new CometChat.GroupMembersRequestBuilder(GUID) - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - -```ts -let GUID: string = "GUID"; -let limit: number = 30; -let searchKeyword: string = "super"; -let groupMembersRequest: CometChat.GroupMembersRequest = - new CometChat.GroupMembersRequestBuilder(GUID) - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - - -### Set Scopes - -This method allows you to fetch group members based on multiple scopes. - - - -```js -let GUID = "GUID"; -let limit = 30; -let scopes = ["admin", "moderator"]; -let groupMembersRequest = new CometChat.GroupMembersRequestBuilder(GUID) - .setLimit(limit) - .setScopes(scopes) - .build(); -``` - - - - -```ts -let GUID: string = "GUID"; -let limit: number = 30; -let scopes: Array = ["admin", "moderator"]; -let groupMembersRequest: CometChat.GroupMembersRequest = - new CometChat.GroupMembersRequestBuilder(GUID) - .setLimit(limit) - .setScopes(scopes) - .build(); -``` - - - - - -Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the `GroupMembersRequest` class. - -Once you have the object of the `GroupMembersRequest` class, you need to call the `fetchNext()` method. Calling this method will return a list of `GroupMember` objects containing n number of members where n is the limit set in the builder class. - - - -```js -let GUID = "GUID"; -let limit = 30; -lett groupMemberRequest = new CometChat.GroupMembersRequestBuilder(GUID) - .setLimit(limit) - .build(); - -groupMemberRequest.fetchNext().then( - groupMembers => { - console.log("Group Member list fetched successfully:", groupMembers); - }, error => { - console.log("Group Member list fetching failed with exception:", error); - } -); -``` - - - - -```ts -let GUID: string = "GUID"; -let limit: number = 30; -let groupMembersRequest: CometChat.GroupMembersRequest = - new CometChat.GroupMembersRequestBuilder(GUID).setLimit(limit).build(); - -groupMembersRequest.fetchNext().then( - (groupMembers: CometChat.GroupMember[]) => { - console.log("Group Member list fetched successfully:", groupMembers); - }, - (error: CometChat.CometChatException) => { - console.log("Group Member list fetching failed with exception:", error); - } -); -``` - - - - diff --git a/sdk/ionic-legacy/3.0/groups-retrieve-groups.mdx b/sdk/ionic-legacy/3.0/groups-retrieve-groups.mdx deleted file mode 100644 index 7475c3cd3..000000000 --- a/sdk/ionic-legacy/3.0/groups-retrieve-groups.mdx +++ /dev/null @@ -1,289 +0,0 @@ ---- -title: "Retrieve Groups" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Retrieve List of Groups - -*In other words, as a logged-in user, how do I retrieve the list of groups I've joined and groups that are available?* - -In order to fetch the list of groups, you can use the `GroupsRequest` class. To use this class i.e to create an object of the `GroupsRequest` class, you need to use the `GroupsRequestBuilder` class. The `GroupsRequestBuilder` class allows you to set the parameters based on which the groups are to be fetched. - -The `GroupsRequestBuilder` class allows you to set the below parameters: - -### Set Limit - -This method sets the limit i.e. the number of groups that should be fetched in a single iteration. - - - -```js -let limit = 30; -let groupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .build(); -``` - - - - -```ts -let limit: number = 30; -let groupsRequest: CometChat.GroupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .build(); -``` - - - - - -### Set Search Keyword - -This method allows you to set the search string based on which the groups are to be fetched. - - - -```js -let limit = 30; -let searchKeyword = "group"; -let groupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - -```ts -let limit: number = 30; -let searchKeyword: string = "group"; -let groupsRequest: CometChat.GroupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - - -### Joined Only - -This method when used, will ask the SDK to only return the groups that the user has joined or is a part of. - - - -```js -let limit = 30; -let groupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .joinedOnly(true) - .build(); -``` - - - - -```ts -let limit: number = 30; -let groupsRequest: CometChat.GroupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .joinedOnly(true) - .build(); -``` - - - - - -### Set Tags - -This method accepts a list of tags based on which the list of groups is to be fetched. The list fetched will only contain the groups that have been tagged with the specified tags. - - - -```js -let limit = 30; -let tags = ["tag1", "tag2"]; -let groupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .setTags(tags) - .build(); -``` - - - - -```ts -let limit: number = 30; -let tags: Array = ["tag1", "tag2"]; -let groupsRequest: CometChat.GroupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .setTags(tags) - .build(); -``` - - - - - -### With Tags - -This property when set to true will fetch tags data along with the list of groups. - - - -```js -let limit = 30; -let groupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .withTags(true) - .build(); -``` - - - - -```ts -let limit: number = 30; -let groupsRequest: CometChat.GroupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .withTags(true) - .build(); -``` - - - - - -Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the `GroupsRequest` class. - -Once you have the object of the `GroupsRequest` class, you need to call the `fetchNext()` method. Calling this method will return a list of `Group` objects containing n number of groups where n is the limit set in the builder class. - -The list of groups fetched will only have the public and password type groups. The private groups will only be available if the user is a member of the group. - - - -```js -let limit = 30; -let groupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .build(); - -groupsRequest.fetchNext().then( - groupList => { - console.log("Groups list fetched successfully", groupList); - }, error => { - console.log("Groups list fetching failed with error", error); - } -); -``` - - - - -```ts -let limit: number = 30; -let groupsRequest: CometChat.GroupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .build(); - -groupsRequest.fetchNext().then( - (groupList: CometChat.Group[]) => { - console.log("Groups list fetched successfully", groupList); - }, (error: CometChat.CometChatException) => { - console.log("Groups list fetching failed with error", error); - } -); -``` - - - - - -## Retrieve Particular Group Details - -*In other words, as a logged-in user, how do I retrieve information for a specific group?* - -To get the information of a group, you can use the `getGroup()` method. - - - -```js -var GUID = "GUID"; -CometChat.getGroup(GUID).then( - group => { - console.log("Group details fetched successfully:", group); - }, error => { - console.log("Group details fetching failed with exception:", error); - } -); -``` - - - - -```ts -var GUID: string = "GUID"; -CometChat.getGroup(GUID).then( - (group: CometChat.Group) => { - console.log("Group details fetched successfully:", group); - }, (error: CometChat.CometChatException) => { - console.log("Group details fetching failed with exception:", error); - } -); -``` - - - - - -| Parameter | Description | -| --------- | ------------------------------------------------------------ | -| `GUID` | The GUID of the group for whom the details are to be fetched | - -It returns `Group` object containing the details of the group. - -## Get online group member count - -To get the total count of online users in particular groups, you can use the `getOnlineGroupMemberCount()` method. - - - -```js -let guids = ["cometchat-guid-1"]; -CometChat.getOnlineGroupMemberCount(guids).then( - groupMemberCount => { - console.log("Total online user for specified groups:", groupMemberCount); - }, error => { - console.log("Online group member count fetching failed with error:", error); - } -); -``` - - - - -```ts -let guids: String[] = ["cometchat-guid-1"]; -CometChat.getOnlineGroupMemberCount(guids).then( - (groupMemberCount: number) => { - console.log("Total online user for specified groups:", groupMemberCount); - }, (error: CometChat.CometChatException) => { - console.log("Online group member count fetching failed with error:", error); - } -); -``` - - - - - -This method returns a JSON Object with the GUID as the key and the online member count for that group as the value. diff --git a/sdk/ionic-legacy/3.0/groups-transfer-group-ownership.mdx b/sdk/ionic-legacy/3.0/groups-transfer-group-ownership.mdx deleted file mode 100644 index 5cc8c9def..000000000 --- a/sdk/ionic-legacy/3.0/groups-transfer-group-ownership.mdx +++ /dev/null @@ -1,48 +0,0 @@ ---- -title: "Transfer Group Ownership" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -*In other words, as a logged-in user, how do I transfer the ownership of any group if I am the owner of the group?* - -In order to transfer the ownership of any group, the first condition is that you must be the owner of the group. In case you are the owner of the group, you can use the `transferGroupOwnership()` method provided by the `CometChat` class. - -This will be helpful as the owner is not allowed to leave the group. In case, you as the owner would like to leave the group, you will have to use this method and transfer your ownership first to any other member of the group and only then you will be allowed to leave the group. - - - -```js -let GUID = "GUID"; -let UID = "UID"; -CometChat.transferGroupOwnership(GUID, UID).then( - () => { - console.log("Successfully transferred ownership of the group."); - }, error => { - console.log("Could not transfer ownership of the group: ", error); - } -) -``` - - - - -```ts -let GUID: string = "GUID"; -let UID: string = "UID"; -CometChat.transferGroupOwnership(GUID, UID).then( - (ownershipTransferred: string) => { - console.log("Successfully transferred ownership of the group."); - }, error => { - console.log("Could not transfer ownership of the group: ", error); - } -); -``` - - - - diff --git a/sdk/ionic-legacy/3.0/groups-update-group.mdx b/sdk/ionic-legacy/3.0/groups-update-group.mdx deleted file mode 100644 index 9e09aca27..000000000 --- a/sdk/ionic-legacy/3.0/groups-update-group.mdx +++ /dev/null @@ -1,65 +0,0 @@ ---- -title: "Update A Group" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Update Group - -*In other words, as a group owner, how can I update the group details?* - -You can update the existing details of the group using the `updateGroup()` method. - - - -```js -var GUID = "GUID"; -var groupName = "Hello Group"; -var groupType = CometChat.GROUP_TYPE.PUBLIC; -var group = new CometChat.Group(GUID, groupName, groupType); - -CometChat.updateGroup(group).then( - group => { - console.log("Groups details updated successfully:", group); - }, error => { - console.log("Group details update failed with exception:", error); - } -); -``` - - - - -```ts -var GUID: string = "GUID"; -var groupName: string = "Hello Group!"; -var groupType: string = CometChat.GROUP_TYPE.PUBLIC; - -var group: CometChat.Group = new CometChat.Group(GUID, groupName, groupType); - -CometChat.updateGroup(group).then( - (group: CometChat.Group) => { - console.log("Group details updated successfully:", group); - }, (error: CometChat.CometChatException) => { - console.log("Group details update failed with exception:", error); - } -); -``` - - - - - -This method takes an instance of the `Group` class as a parameter which should contain the data that you wish to update. - -| Parameter | Description | -| --------- | ---------------------------- | -| `group` | an instance of class `Group` | - -After a successful update of the group, you will receive an instance of `Group` class containing update information of the group. - -For more information on the `Group` class, please check [here](/sdk/ionic-legacy/3.0/groups-create-group#group-class). diff --git a/sdk/ionic-legacy/3.0/groups.mdx b/sdk/ionic-legacy/3.0/groups.mdx deleted file mode 100644 index 8a5496978..000000000 --- a/sdk/ionic-legacy/3.0/groups.mdx +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: "Groups" -sidebarTitle: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -Groups help your users to converse together in a single space. You can have three types of groups- private, public and password protected. - -Each group includes three kinds of users- owner, moderator, member. diff --git a/sdk/ionic-legacy/3.0/key-concepts.mdx b/sdk/ionic-legacy/3.0/key-concepts.mdx deleted file mode 100644 index f4d5cbde3..000000000 --- a/sdk/ionic-legacy/3.0/key-concepts.mdx +++ /dev/null @@ -1,129 +0,0 @@ ---- -title: "Key Concepts" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -### CometChat Dashboard - -The CometChat Dashboard enables you to create new apps (projects) and manage your existing apps. - - -**How many apps to create?** - -Ideally, you should create two apps- one for development and one for production. And you should use a single app irrespective of the number of platforms. - -Do not create separate apps for every platform if you do, your users on different platforms will not be able to communicate with each other! - - - -* For every app, a unique App ID is generated. This App ID will be required when integrating CometChat within your app. -* Along with the App ID, you will need to create an Auth Key (from the Dashboard) which can be used for user authentication. - -### Auth & Rest API Keys - -You can generate two types of keys from the dashboard. - -| Type | Privileges | Recommended Use | -| ------------ | ---------------------------------------------------------------- | --------------------------------------------- | -| Auth Key | The Auth Key can be used to create & login users. | In your client side code (during development) | -| Rest API Key | The Rest API Key can be used to perform any CometChat operation. | In your server side code | - -### Users - -A user is anyone who uses CometChat. - -### UID - -* Each user is uniquely identified using UID. -* The UID is typically the primary ID of the user from your database. - - - -UID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed. - - - -### Auth Token - -* A single user can have multiple auth tokens. The auth tokens should be per user per device. -* It should be generated by API call ideally, via server to server call. The auth token should then be given to CometChat for login. -* An Auth Token can only be deleted via dashboard or using REST API. - -### Authentication - -To allow a user to use CometChat, the user must log in to CometChat. - -**CometChat does not handle user management.** You must handle user registration and login at your end. Once the user is logged into your app/site, you can log in the user to CometChat **programmatically**. So the user does not ever directly login to CometChat. - -**CometChat does not handle friends management.** If you want to associate friends with your users, you must handle friends management in your app. Once two users are friends (i.e. they have accepted each other as friends), then you can associate them as friends in CometChat. - -### Typical Workflow - -| Your App | Your Server | CometChat | -| ----------------------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ | -| User registers in your app | You store the user information in your database (e.g. ID, name, email, phone, location etc. in `users` table) | You add the user to CometChat (only ID & name) using the Rest API | -| User logs in to your app | You verify the credentials, login the user and retrieve the user ID | You log in the user to CometChat using the same user ID programmatically | -| User sends a friend request | You display the request to the potential friend | No action required | -| User accepts a friend request | You display the users as friends | You add both the users as friends using the Rest API | - -### User Roles - -A role is a category for a group of similar users. For example, you may want to group your premium users using the role "Premium". You then use this to filter users or enable/disable features by writing conditional code. - -### User List - -* The User List can be used to build the **Contacts** or **Who's Online** view in your app. -* The list of users can be different based on the logged-in user. - -### Groups - -A group can be used for multiple users to communicate with each other on a particular topic/interest. - -### GUID - -* Each group is uniquely identified using GUID. -* The GUID is typically the primary ID of the group from your database. If you do not store group information in your database, you can generate a random string for use as GUID. - - - -GUID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed. - - - -### Types - -CometChat supports three different types of groups: - -| Type | Visibility | Participation | -| -------- | ---------------------------- | ------------------------------------------------- | -| Public | All users | Any user can choose to join | -| Password | All users | Any user with a valid password can choose to join | -| Private | Only users part of the group | Invited users will be auto-joined | - -### Members - -Once a participant joins a group, they become a member of the group. Members are part of the group indefinitely i.e. they will keep receiving messages, calls & notifications. To stop, the participant must either be kicked, banned or intentionally leave the group. - -CometChat supports three different types of member scopes in a group: - -| Member | Default | Privileges | -| ----------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Admin | Group creator is assigned Admin scope | - Change scope of Group Members to admin, moderator or participant.
- Can add members to a group.
- Kick & Ban Participants/Moderators/Admins
- Send & Receive Messages & Calls
- Update group
- Delete group | -| Moderator | - | - Change scope of moderator or participant.
- Update group
- Kick & Ban Participants
- Send & Receive Messages & Calls | -| Participant | Any other user is assigned Participant scope | - Send & Receive Messages & Calls | - -### Messaging - -Any message in CometChat can belong to either one of the below categories - -| Category | Description | -| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| message | Any message belonging to the category `message` can belong to either one of the below types:
1. text
2. image
3. video
4. audio
5. file | -| custom | Custom messages are an option available for developers to send custom data across to users/groups. To send any additional data that does not fit in the default categories and types provided by CometChat, you can use the custom messages. | -| action | Action messages are system-generated messages. These can belong to either of the below types:
1. groupMember - when the action is performed on a group member
2. message - when the action is performed on a message | -| call | These are call-related messages. These can belong to either one of the two types:
1. audio
2. video | diff --git a/sdk/ionic-legacy/3.0/message-structure-and-hierarchy.mdx b/sdk/ionic-legacy/3.0/message-structure-and-hierarchy.mdx deleted file mode 100644 index 6c0a7034d..000000000 --- a/sdk/ionic-legacy/3.0/message-structure-and-hierarchy.mdx +++ /dev/null @@ -1,75 +0,0 @@ ---- -title: "Message Structure And Hierarchy" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -The below diagram helps you better understand the various message categories and types that a CometChat message can belong to. - - - - - -As you can see in the above diagram, every message belongs to a particular category. A message can belong to either one of the 4 categories - -1. Message -2. Custom -3. Action -4. Call - -Each category can be further be classified into types. - -\#Message A message belonging to the category `message` can be classified into either 1 of the below types: - -1. text - A plain text message -2. image- An image message -3. video- A video message -4. audio- An audio message -5. file- A file message - -## Custom - -In the case of messages that belong to the `custom` category, there are no predefined types. Custom messages can be used by developers to send messages that do not fit in the default category and types provided by CometChat. For messages with the category `custom`, the developers can set their own type to uniquely identify the custom message. A very good example of a custom message would be the sharing of location co-ordinates. In this case, the developer can decide to use the custom message with type set to `location`. - -## Action - -Action messages are system-generated messages. Messages belonging to the `action` category can further be classified into one of the below types: - -1. groupMember - action performed on a group member. -2. message - action performed on a message. - -Action messages hold another property called `action` which actually determine the action that has been performed For the type `groupMember` the action can be either one of the below: - -1. joined - when a group member joins a group -2. left - when a group member leaves a group -3. kicked - when a group member is kicked from the group -4. banned - when a group member is banned from the group -5. unbanned - when a group member is unbanned from the group -6. added - when a user is added to the group -7. scopeChanged - When the scope of a group member is changed. - -For the type `message`, the action can be either one of the below: - -1. edited - when a message is edited. -2. deleted - when a message is deleted. - -## Call - -Messages with the category `call` are Calling related messages. These can belong to either one of the 2 types - -1. audio -2. video - -The call messages have a property called status that helps you figure out the status of the call. The status can be either one of the below values: - -1. initiated - when a is initiated to a user/group -2. ongoing - when the receiver of the call has accepted the call -3. canceled - when the call has been canceled by the initiator of the call -4. rejected - when the call has been rejected by the receiver of the call -5. unanswered - when the call was not answered by the receiver. -6. busy - when the receiver of the call was busy on another call. -7. ended - when the call was successfully completed and ended by either the initiator or receiver. diff --git a/sdk/ionic-legacy/3.0/messaging-additional-message-filtering.mdx b/sdk/ionic-legacy/3.0/messaging-additional-message-filtering.mdx deleted file mode 100644 index c5193de8c..000000000 --- a/sdk/ionic-legacy/3.0/messaging-additional-message-filtering.mdx +++ /dev/null @@ -1,1003 +0,0 @@ ---- -title: "Additional Message Filtering" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -The `MessagesRequest` class as you must be familiar with helps you to fetch messages based on the various parameters provided to it. This document will help you understand better the various options that are available using the `MessagesRequest` class. - -The `MessagesRequest` class is designed using the `Builder design pattern`. In order to obtain an object of the `MessagesRequest` class, you will have to make use of the `MessagesRequestBuilder` class in the `MessagesRequest` class. - -The `MessagesRequestBuilder` class allows you to set various parameters to the `MessagesRequest` class based on which the messages are fetched. - -Steps to generate an object of the MessagesRequest class: - -1. Create an object of the `MessagesRequestBuilder` class. -2. Set all the parameters you wish to set. -3. Call the `build()` method of the `MessagesRequestBuilder` class to get an object of the `MessagesRequest` class. - -Once you have an object of the `MessagesRequest` class, you can call either the `fetchNext()` method or the `fetchPrevious()` method using the object. - -1. fetchNext() - Calling this method will return the messages after the specified parameters. -2. fetchPrevious() - Calling this method will give you messages before the specified parameters. - -Since messages are obtained in a paginated manner, a maximum of 100 messages can be pulled in a single iteration. Calling the `fetchPrevious()`/`fetchNext()` method on the same `MessagesRequest` object will get you the next set of messages. - -Now that you are clear how to use the `MessagesRequest` class, below are the various options available: - -## Number of messages fetched - -*In other words, how do I set the number of messages fetched in a single iteration* - -To achieve this, you can use the `setLimit()` method. This method takes an integer value as the input and informs the SDK to fetch the specified number of messages in one iteration. The maximum number of messages that can be fetched in one go is 100. - - - -```js -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setLimit(50) - .build(); -``` - - - - -```ts -let messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder().setLimit(50).build(); -``` - - - - - -## Messages for a user conversation - -\_In other words, how do I fetch messages between me and any user \_ - -This can be achieved using the `setUID()` method. This method takes the UID of the user with whom the conversation is to be fetched. When a valid UID is passed, the SDK will return all the messages that are a part of the conversation between the logged-in user and the UID that has been specified. - - - -```js -let UID = "UID"; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(50) - .build(); -``` - - - - -```ts -let UID: string = "UID", - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder().setUID(UID).setLimit(50).build(); -``` - - - - - -## Messages for a group conversation - -*In other words, how do I fetch messages for any group conversation* - -You can achieve this using the `setGUID()` method. This method takes the GUID of a group for which the conversations are to be fetched. Passing a valid GUID to this method will return all the messages that are a part of the group conversation. Please note that the logged-in user must be a member of the group to fetch the messages for that group. - - - -```js -let GUID = "GUID"; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(50) - .build(); -``` - - - - -```ts -let GUID: string = "GUID", - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder().setGUID(GUID).setLimit(50).build(); -``` - - - - - - - -If none of the above two methods `setUID()` and `setGUID()` is used, an empty array will be returned.> All the parameters discussed below should be used along with the setUID() or setGUID() methods. - - - -## Messages before/after a message - -\_In other words, how do I fetch messages before or after a particular message \_ - -This can be achieved using the `setMessageId()` method. This method takes the message-id as input and provides messages only after/before the message-id based on if the fetchNext() or fetchPrevious() method is triggered. - - - -```js -let UID = "UID"; -let messageId = 1; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setMessageId(messageId) - .setLimit(limit) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let messageId = 1; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setMessageId(messageId) - .setLimit(limit) - .build(); -``` - - - - -```ts -let UID: string = "UID", - messageId: number = 1, - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setMessageId(messageId) - .setLimit(limit) - .build(); -``` - - - - -```ts -let GUID: string = "GUID", - messageId: number = 1, - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setMessageId(messageId) - .setLimit(limit) - .build(); -``` - - - - - -This method can be used along with `setUID()` or `setGUID()` methods to fetch messages after/before any specific message-id for a particular user/group conversation. - -## Messages before/after a given time - -\_In other words, how do I fetch messages before or after a particular date or time \_ - -You can easily achieve this using the `setTimestamp()` method. This method takes the Unix timestamp as input and provides messages only after/before the timestamp based on if fetchNext() or fetchPrevious() method is triggered. - - - -```js -let UID = "UID"; -let timestamp = 1602221371; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setTimestamp(timestamp) - .setLimit(limit) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let timestamp = 1602221371; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setTimestamp(timestamp) - .setLimit(limit) - .build(); -``` - - - - -```ts -let UID: string = "UID", - timestamp: number = 1602221371, - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setTimestamp(timestamp) - .setLimit(limit) - .build(); -``` - - - - -```ts -let GUID: string = "GUID", - timestamp: number = 1602221371, - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setTimestamp(timestamp) - .setLimit(limit) - .build(); -``` - - - - - -This method can be used along with `setUID()` or `setGUID()` methods to fetch messages after/before any specific date or time for a particular user/group conversation. - -## Unread messages - -\_In other words, how do I fetch unread messages \_ - -This can easily be achieved using setting the unread flag to true. For this, you need to use the `setUnread()` method. This method takes a boolean value as input. If the value is set to true, the SDK will return just the unread messages. - - - -```js -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setUnread(true) - .setLimit(limit) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setUnread(true) - .setLimit(limit) - .build(); -``` - - - - -```ts -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setUnread(true) - .setLimit(limit) - .build(); -``` - - - - -```ts -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setUnread(true) - .setLimit(limit) - .build(); -``` - - - - - -This method along with `setGUID()` or `setUID()` can be used to fetch unread messages for a particular group or user conversation respectively. - -## Exclude messages from blocked users - -\_In other words, how do I fetch messages excluding the messages from the users I have blocked \_ - -This can be easily achieved using the `hideMessagesFromBlockedUsers()` method. This method accepts a boolean value which determines if the messages from users blocked by the logged-in user need to be a part if the fetched messages. If the value is set to true, the messages will be hidden and won't be a part of the messages fetched. The default value is false i.e if this method is not used, the messages from blocked users will be included in the fetched messages. - - - -```js -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .hideMessagesFromBlockedUsers(true) - .setLimit(limit) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .hideMessagesFromBlockedUsers(true) - .setLimit(limit) - .build(); -``` - - - - -```ts -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .hideMessagesFromBlockedUsers(true) - .setLimit(limit) - .build(); -``` - - - - -```ts -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .hideMessagesFromBlockedUsers(true) - .setLimit(limit) - .build(); -``` - - - - - -This method can be used to hide the messages by users blocked by logged in user in groups that both the members are a part of. - -## Updated and received messages - -\_In other words, how do I fetch messages that have been received or updated after a particular date or time \_ - -This method accepts a Unix timestamp value and will return all the messages that have been updated and the ones that have been sent/received after the specified time. The messages updated could mean the messages that have been marked as read/delivered or if the messages are edited or deleted. - - - -```js -let UID = "UID"; -let limit = 30; -let timestamp = 1602221371; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setUpdatedAfter(timestamp) - .setLimit(limit) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let limit = 30; -let timestamp = 1602221371; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setUpdatedAfter(timestamp) - .setLimit(limit) - .build(); -``` - - - - -```ts -let UID: string = "UID", - limit: number = 30, - timestamp: string = "1602221371", - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setUpdatedAfter(timestamp) - .setLimit(limit) - .build(); -``` - - - - -```ts -let GUID: string = "GUID", - limit: number = 30, - timestamp: string = "1602221371", - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setUpdatedAfter(timestamp) - .setLimit(limit) - .build(); -``` - - - - - -This can be useful in finding the messages that have been received or updated after a certain time. Can prove very useful if you are saving the messages locally and would like to know the messages that have been updated or received after the last message available in your local databases. - -## Updated messages only - -\_In other words, how do I fetch messages that have been updated after a particular date or time \_ - -This can be achieved easily by setting the updatesOnly parameter to true. To do so, you can use the updatesOnly() method. This method takes a boolean input and can be used with the `setUpdatedAfter()` method to get jus the updated messages and not the messages sent/received after the specified time. This method cannot be used independently and always needs to be used with the `setUpdatedAfter()` method. - - - -```js -let UID = "UID"; -let limit = 30; -let timestamp = 1602221371; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setUpdatedAfter(timestamp) - .updatesOnly(true) - .setLimit(limit) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let limit = 30; -let timestamp = 1602221371; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setUpdatedAfter(timestamp) - .updatesOnly(true) - .setLimit(limit) - .build(); -``` - - - - -```ts -let UID: string = "UID", - limit: number = 30, - timestamp: string = "1602221371", - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setUpdatedAfter(timestamp) - .updatesOnly(true) - .setLimit(limit) - .build(); -``` - - - - -```ts -let GUID: string = "GUID", - limit: number = 30, - timestamp: string = "1602221371", - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setUpdatedAfter(timestamp) - .updatesOnly(true) - .setLimit(limit) - .build(); -``` - - - - - -Messages for multiple categories - -*In other words, how do I fetch messages belonging to multiple categories* - -We recommend before trying this, you refer to the [Message structure and hierarchy guide](/sdk/ionic-legacy/3.0/message-structure-and-hierarchy) to get familiar with the various categories of messages. - -For this, you will have to use the `setCategories()` method. This method accepts a list of categories. This tells the SDK to fetch messages only belonging to these categories. - - - -```js -let UID = "UID"; -let limit = 30; -let categories = ["message", "custom"]; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setCategories(categories) - .setLimit(limit) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let limit = 30; -let categories = ["message", "custom"]; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setCategories(categories) - .setLimit(limit) - .build(); -``` - - - - -```ts -let UID: string = "UID", - limit: number = 30, - categories: Array = ["message", "custom"], - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setCategories(categories) - .setLimit(limit) - .build(); -``` - - - - -```ts -let GUID: string = "GUID", - limit: number = 30, - categories: Array = ["message", "custom"], - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setCategories(categories) - .setLimit(limit) - .build(); -``` - - - - - -The above snippet will help you get only the messages belonging to the `message` and `custom` category. This can also be used to disable certain categories of messages like `call` and `action`. This along with `setGUID()` and `setUID()` can help display only the messages you wish to display avoiding the other category of messages. - -## Messages for multiple types - -\_In other words, how do I fetch messages belonging to multiple types \_ - -We recommend before trying this, you refer to the [Message structure & hierarchy guide](/sdk/ionic-legacy/3.0/message-structure-and-hierarchy) to get familiar with the various types of messages. - -This can be easily achieved using the `setTypes()` method. This method accepts a list of types. This tells the SDK to fetch messages only belonging to these types. - - - -```js -let UID = "UID"; -let limit = 30; -let categories = ["message"]; -let types = ["image", "video", "audio", "file"]; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setCategories(categories) - .setTypes(types) - .setLimit(limit) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let limit = 30; -let categories = ["message"]; -let types = ["image", "video", "audio", "file"]; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setCategories(categories) - .setTypes(types) - .setLimit(limit) - .build(); -``` - - - - -```ts -let UID: string = "UID", - limit: number = 30, - categories: Array = ["message", "custom"], - types: Array = ["image", "video", "audio", "file"], - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setCategories(categories) - .setTypes(types) - .setLimit(limit) - .build(); -``` - - - - -```ts -let GUID: string = "GUID", - limit: number = 30, - categories: Array = ["message", "custom"], - types: Array = ["image", "video", "audio", "file"], - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setCategories(categories) - .setTypes(types) - .setLimit(limit) - .build(); -``` - - - - - -Using the above code snippet, you can fetch all the media messages. This along with setUID() or setGUID() can be used to fetch media messages for any particular conversation. This can be useful in many other scenarios as well. - -## Messages for a specific thread - -\_In other words, how do I fetch messages that are a part of a thread and not directly a user/group conversations \_ - -This can be done using the `setParentMessageId()` method. This method needs to be used when you have implemented threaded conversations in your app. This method will return the messages only belonging to the thread with the specified parent Id. - - - -```js -let UID = "UID"; -let messageId = 1; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .setParentMessageId(messageId) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let messageId = 1; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .setParentMessageId(messageId) - .build(); -``` - - - - -```ts -let UID: string = "UID", - limit: number = 30, - messageId: number = 1, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .setParentMessageId(messageId) - .build(); -``` - - - - -```ts -let GUID: string = "GUID", - limit: number = 30, - messageId: number = 1, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .setParentMessageId(messageId) - .build(); -``` - - - - - -The above code snippet returns the messages that belong to the thread with parent id 100. - -## Hide threaded messages in user/group conversations - -\_In other words, how do I exclude threaded messages from the normal user/group conversations \_ - -In order to do this, you can use the `hideReplies()` method. This method is also related to threaded conversations. This method takes boolean as input. This boolean when set to true will make sure that the messages that belong to threads are not fetched. If set to false, which is also the default value, the messages belong to the threads will also be fetched along with other messages. - - - -```js -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .hideReplies(true) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hideReplies(true) - .build(); -``` - - - - -```ts -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .hideReplies(true) - .build(); -``` - - - - -```ts -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hideReplies(true) - .build(); -``` - - - - - -## Hide deleted messages in user/group conversations - -\_In other words, how do I exclude deleted messages a user/group conversations \_ - -In order to do this, you can use the `hideDeletedMessages()` method. This method takes boolean as input. This boolean when set to true will make sure that the deleted messages are not fetched. If set to false, which is also the default value, the deleted messages will also be fetched along with other messages. - - - -```js -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .hideDeletedMessages(true) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hideDeletedMessages(true) - .build(); -``` - - - - -```ts -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .hideDeletedMessages(true) - .build(); -``` - - - - -```ts -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hideDeletedMessages(true) - .build(); -``` - - - - - -## Messages by tags - -*In other words, how do I fetch messages by tags* - -In order to do this, you can use the `setTags()` method. This method accepts a list of tags. This tells the SDK to fetch messages only belonging to these tags. - - - -```js -let UID = "UID"; -let limit = 30; -let tags = ["starredMessage"]; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .setTags(tags) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let limit = 30; -let tags = ["starredMessage"]; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .setTags(tags) - .build(); -``` - - - - -```ts -let UID: string = "UID", - limit: number = 30, - tags: Array = ["starredMessage"], - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .setTags(tags) - .build(); -``` - - - - -```ts -let GUID: string = "GUID", - limit: number = 30, - tags: Array = ["starredMessage"], - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .setTags(tags) - .build(); -``` - - - - - -## Messages with tags - -*In other words, how do I fetch messages with the tags information* - -In order to do this, you can use the `withTags()` method. This method accepts boolean as input. When set to `true` , the SDK will fetch messages along with the tags. When set to `false` , the SDK will not fetch tags associated with messages. The default value for this parameter is `false` . - - - -```js -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .withTags(true) - .build(); -``` - - - - -```js -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .withTags(tags) - .build(); -``` - - - - -```ts -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(UID) - .setLimit(limit) - .withTags(true) - .build(); -``` - - - - -```ts -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .withTags(true) - .build(); -``` - - - - diff --git a/sdk/ionic-legacy/3.0/messaging-delete-conversation.mdx b/sdk/ionic-legacy/3.0/messaging-delete-conversation.mdx deleted file mode 100644 index b103cec9f..000000000 --- a/sdk/ionic-legacy/3.0/messaging-delete-conversation.mdx +++ /dev/null @@ -1,89 +0,0 @@ ---- -title: "Delete A Conversation" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -In case you want to delete a conversation, you can use the `deleteConversation()` method. - -This method takes two parameters. The unique id (UID/GUID) of the conversation to be deleted & the type (user/group) of conversation to be deleted. - - - -```js -let UID = "UID"; -let type = "user"; -CometChat.deleteConversation(UID, type).then( - (deletedConversation) => { - console.log(deletedConversation); - }, - (error) => { - console.log("error while deleting a conversation", error); - } -); -``` - - - - -```js -let GUID = "GUID"; -let type = "group"; -CometChat.deleteConversation(GUID, type).then( - (deletedConversation) => { - console.log(deletedConversation); - }, - (error) => { - console.log("error while deleting a conversation", error); - } -); -``` - - - - -```ts -let UID: string = "UID"; -let type: string = "user"; -CometChat.deleteConversation(UID, type).then( - (deletedConversation: string) => { - console.log(deletedConversation); - }, - (error: CometChat.CometChatException) => { - console.log("error while deleting a conversation", error); - } -); -``` - - - - -```ts -let GUID: string = "GUID"; -let type: string = "group"; -CometChat.deleteConversation(GUID, type).then( - (deletedConversation: string) => { - console.log(deletedConversation); - }, - (error: CometChat.CometChatException) => { - console.log("error while deleting a conversation", error); - } -); -``` - - - - - -This method deletes the conversation only for the logged-in user. To delete a conversation for all the users of the conversation, please refer to our REST API documentation [here](https://api-explorer.cometchat.com/reference/chat-apis). - -The `deleteConversation()` method takes the following parameters: - -| Parameter | Description | Required | -| ---------------- | --------------------------------------------------------------------------------- | -------- | -| conversationWith | `UID` of the user or `GUID` of the group whose conversation you want to delete. | YES | -| conversationType | The type of conversation you want to delete . It can be either `user` or `group`. | YES | diff --git a/sdk/ionic-legacy/3.0/messaging-delete-message.mdx b/sdk/ionic-legacy/3.0/messaging-delete-message.mdx deleted file mode 100644 index e915a8883..000000000 --- a/sdk/ionic-legacy/3.0/messaging-delete-message.mdx +++ /dev/null @@ -1,124 +0,0 @@ ---- -title: "Delete A Message" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -While [deleting a message](/sdk/ionic-legacy/3.0/messaging-delete-message#delete-a-message) is straightforward, receiving events for deleted messages with CometChat has two parts: - -1. Adding a listener to receive [real-time message deletes](/sdk/ionic-legacy/3.0/messaging-delete-message#real-time-message-delete-events) when your app is running. -2. Calling a method to retrieve [missed message deletes](/sdk/ionic-legacy/3.0/messaging-delete-message#missed-message-delete-events) when your app was not running. - -## Delete a Message - -*In other words, as a sender, how do I delete a message?* - -In case you have to delete a message, you can use the `deleteMessage()` method. This method takes the message ID of the message to be deleted. - - - -```js -let messageId = "ID_OF_THE_MESSAGE_YOU_WANT_TO_DELETE"; - -CometChat.deleteMessage(messageId).then( - message => { - console.log("Message deleted", message); - }, error => { - console.log("Message delete failed with error:", error); - } -); -``` - - - - -```ts -let messageId: number = 1; - -CometChat.deleteMessage(messageId).then( - (message: CometChat.BaseMessage) => { - console.log("Message deleted", message); - }, (error: CometChat.CometChatException) => { - console.log("Message delete failed with error:", error); - } -); -``` - - - - - -Once the message is deleted, In the `onSuccess()` callback, you get an object of the `BaseMessage` class, with the `deletedAt` field set with the timestamp of the time the message was deleted. Also, the `deletedBy` field is set. These two fields can be used to identify if the message is deleted while iterating through a list of messages. - -By default, CometChat allows certain roles to delete a message. - -| User Role | Conversation Type | Deletion Capabilities | -| --------------- | ----------------------- | ------------------------------ | -| Message Sender | One-on-One Conversation | Messages they have sent. | -| Message Sender | Group Conversation | Messages they have sent. | -| Group Admin | Group Conversation | All the messages in the group. | -| Group Moderator | Group Conversation | All the messages in the group. | - -## Real-time Message Delete Events - -*In other words, as a recipient, how do I know when someone deletes a message when my app is running?* - -In order to receive real-time events for a message being deleted, you need to override the `onMessageDeleted()` method of the `MessageListener` class. - - - -```js -var listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener( - listenerID, - new CometChat.MessageListener({ - onMessageDeleted: message => { - console.log("Deleted Message", message); - } - }) -); -``` - - - - -```ts -let listenerID: string = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener( - listenerID, - new CometChat.MessageListener({ - onMessageDeleted: (message: CometChat.BaseMessage) => { - console.log("Deleted Message", message); - } - }) -); -``` - - - - - -## Missed Message Delete Events - -*In other words, as a recipient, how do I know if someone deleted a message when my app was not running?* - -When you retrieve the list of previous messages, for the messages that were deleted, the `deletedAt` and the `deletedBy` fields will be set. Also, for example, of the total number of messages for a conversation are 100, and the message with message ID 50 was deleted. Now the message with id 50 will have the `deletedAt` and the `deletedBy` fields set whenever it is pulled from the history. Also, the 101st message will be and Action message informing you that the message with id 50 has been deleted. - -For the message deleted event, in the `Action` object received, the following fields can help you get the relevant information- - -1. `action` - `deleted` -2. `actionOn` - Updated message object which was deleted. -3. `actionBy` - User object containing the details of the user who has deleted the message. -4. `actionFor` - User/group object having the details of the receiver to which the message was sent. - - - -In order to edit or delete a message you need to be either the sender of the message or the admin/moderator of the group in which the message was sent. - - diff --git a/sdk/ionic-legacy/3.0/messaging-edit-message.mdx b/sdk/ionic-legacy/3.0/messaging-edit-message.mdx deleted file mode 100644 index 907a59a79..000000000 --- a/sdk/ionic-legacy/3.0/messaging-edit-message.mdx +++ /dev/null @@ -1,181 +0,0 @@ ---- -title: "Edit A Message" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -While [editing a message](/sdk/ionic-legacy/3.0/messaging-edit-message#edit-a-message) is straightforward, receiving events for edited messages with CometChat has two parts: - -1. Adding a listener to receive [real-time message edits](/sdk/ionic-legacy/3.0/messaging-edit-message#real-time-message-edit-events) when your app is running -2. Calling a method to retrieve [missed message edits](/sdk/ionic-legacy/3.0/messaging-edit-message#missed-message-edit-events) when your app was not running - -## Edit a Message - -*In other words, as a sender, how do I edit a message?* - -In order to edit a message, you can use the `editMessage()` method. This method takes an object of the `BaseMessage` class. At the moment, you are only allowed to edit `TextMessage` and `CustomMessage`. Thus, the `BaseMessage` object must either be a Text or a Custom Message. - -### Add/Update Tags - -While editing a message, you can update the tags associated with the Message. You can use the `setTags()` method to do so. The tags added while editing a message will replace the tags set when the message was sent. - - - -``` -let tags = ["pinnedMessage"]; - -textMessage.setTags(tags); -``` - - - - -``` -let tags = ["pinnedMessage"]; - -customMessage.setTags(tags); -``` - - - - -``` -let tags: Array = ["pinnedMessage"]; - -textMessage.setTags(tags); -``` - - - - -``` -let tags: Array = ["pinnedMessage"]; - -customMessage.setTags(tags); -``` - - - - - -Once the message object is ready, you can use the `editMessage()` method and pass the message object to it. - - - -```js -let receiverID = "RECEIVER_UID"; -let messageText = "Hello world!"; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let messageId = "MESSAGE_ID_OF_THE_MESSAGE_TO_BE_EDITED"; -let textMessage = new CometChat.TextMessage(receiverID, messageText, receiverType); - -textMessage.setId(messageId); - -CometChat.editMessage(textMessage).then( - message => { - console.log("Message Edited", message); - }, error => { - console.log("Message editing failed with error:", error); - } -); -``` - - - - -```ts -let receiverID: string = "RECEIVER_UID"; -let messageText: string = "Hello world!"; -let receiverType: string = CometChat.RECEIVER_TYPE.USER; -let messageId: number = 1; -let textMessage: CometChat.TextMessage = new CometChat.TextMessage(receiverID, messageText, receiverType); - -textMessage.setId(messageId); - -CometChat.editMessage(textMessage).then( - (message: CometChat.TextMessage) => { - console.log("Message Edited", message); - }, (error: CometChat.CometChatException) => { - console.log("Message editing failed with error:", error); - } -); -``` - - - - - -The object of the edited message will be returned in the `onSuccess()` callback method of the listener. The message object will contain the `editedAt` field set with the timestamp of the time the message was edited. This will help you identify if the message was edited while iterating through the list of messages. The `editedBy` field is also set to the UID of the user who edited the message. - -By default, CometChat allows certain roles to edit a message. - -| User Role | Conversation Type | Edit Capabilities | -| --------------- | ----------------------- | -------------------------- | -| Message Sender | One-on-One Conversation | Messages they have sent. | -| Message Sender | Group Conversation | Messages they have sent. | -| Group Owner | Group Conversation | All messages in the group. | -| Group Moderator | Group Conversation | All messages in the group. | - -## Real-time Message Edit Events - -*In other words, as a recipient, how do I know when someone has edited their message when my app is running?* - -In order to receive real-time events for message being edited, you need to override the `onMessageEdited()` method of the `MessageListener` class. - - - -```js -let listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener( - listenerID, - new CometChat.MessageListener({ - onMessageEdited: message => { - console.log("Edited Message", message); - } - }) -); -``` - - - - -```ts -let listenerID: string = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener( - listenerID, - new CometChat.MessageListener({ - onMessageEdited: (message: CometChat.BaseMessage) => { - console.log("Edited Message", message); - } - }) -); -``` - - - - - -## Missed Message Edit Events - -*In other words, as a recipient, how do I know when someone edited their message when my app was not running?* - -When you retrieve the list of previous messages, for the message that was edited, the `editedAt` and the `editedBy` fields will be set. Also, for example, of the total number of messages for a conversation are 100, and the message with message ID 50 was edited. Now the message with id 50 will have the `editedAt` and the `editedBy` fields set whenever it is pulled from the history. Also, the 101st message will be and \[Action] message informing you that the message with id 50 has been edited. - -For the message edited event, in the `Action` object received, the following fields can help you get the relevant information- - -1. `action` - `edited` -2. `actionOn` - Updated message object with the edited details. -3. `actionBy` - User object containing the details of the user who has edited the message. -4. `actionFor` - User/group object having the details of the receiver to which the message was sent. - - - -In order to edit a message, you need to be either the sender of the message or the admin/moderator of the group in which the message was sent. - - diff --git a/sdk/ionic-legacy/3.0/messaging-receipts.mdx b/sdk/ionic-legacy/3.0/messaging-receipts.mdx deleted file mode 100644 index 600125290..000000000 --- a/sdk/ionic-legacy/3.0/messaging-receipts.mdx +++ /dev/null @@ -1,488 +0,0 @@ ---- -title: "Delivery & Read Receipts" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Mark Messages as Delivered - -*In other words, as a recipient, how do I inform the sender that I've received a message?* - -You can mark the messages for a particular conversation as read using the `markAsDelivered()` method. This method takes the below parameters as input: - -| Parameter | Information | -| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `messageId` | The ID of the message above which all the messages for a particular conversation are to be marked as read. | -| `receiverId` | In case of one to one conversation message's sender `UID` will be the receipt's receiver Id. In case of group conversation message's receiver Id will be the receipt's receiver Id. | -| `receiverType` | Type of the receiver. Could be either of the two values( user or group). | -| `senderId` | The `UID` of the sender of the message. | - -Messages for both User conversation and Groups can be marked as read using this method. - -Ideally, you would like to mark all the messages as delivered for any conversation when the user opens the chat window for that conversation. This includes two scenarios: - -1. **When the list of messages for the conversation is fetched**: In this case you need to obtain the last message in the list of messages and pass the message Id of that message to the markAsDelivered() method. -2. **When the user is on the chat window and a real-time message is received:** In this case you need to obtain the message Id of the message and pass it to the markAsDelivered() method. - - - -```js -var messageId = "MESSAGE_ID"; -var receiverId = "MESSAGE_SENDER_UID"; -var receiverType = "user"; -var senderId = "MESSAGE_SENDER_UID"; -CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId); -``` - - - - -```js -var messageId = "MESSAGE_ID"; -var receiverId = "MESSAGE_RECEIVER_GUID"; -var receiverType = "group"; -var senderId = "MESSAGE_SENDER_UID"; -CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId); -``` - - - - -```ts -var messageId: string = "MESSAGE_ID"; -var receiverId: string = "MESSAGE_SENDER_UID"; -var receiverType: string = "user"; -var senderId: string = "MESSAGE_SENDER_UID"; -CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId); -``` - - - - -```ts -var messageId: string = "MESSAGE_ID"; -var receiverId: string = "MESSAGE_RECEIVER_GUID"; -var receiverType: string = "group"; -var senderId: string = "MESSAGE_SENDER_UID"; -CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId); -``` - - - - - -This method will mark all the messages before the messageId specified, for the conversation with receiverId and receiverType(user/group) as delivered. - -In case you would like to be notified of an error if the receipts fail to go through you can use `.then(successCallback, failureCallback)` of the `markAsDelivered` method. - - - -```js -CometChat.markAsDelivered(message.getId(), message.getSender().getUid(), 'user', message.getSender().getUid()).then( - () => { - console.log("mark as delivered success."); - }, error => { - console.log("An error occurred when marking the message as delivered.", error); - } -); -``` - - - - -```js -CometChat.markAsDelivered(message.getId(), message.getReceiverUid(), 'group', message.getSender().getUid()).then( - () => { - console.log("mark as delivered success."); - }, error => { - console.log("An error occurred when marking the message as delivered.", error); - } -); -``` - - - - -```ts -var messageId: string = "MESSAGE_ID"; -var receiverId: string = "MESSAGE_SENDER_UID"; -var receiverType: string = "user"; -var senderId: string = "MESSAGE_SENDER_UID"; -CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId).then( - () => { - console.log("mark as delivered success."); - }, (error: CometChat.CometChatException) => { - console.log("An error occurred when marking the message as delivered.", error); - } -); -``` - - - - -```ts -var messageId: string = "MESSAGE_ID"; -var receiverId: string = "MESSAGE_RECEIVER_GUID"; -var receiverType: string = "group"; -var senderId: string = "MESSAGE_SENDER_UID"; -CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId).then( - () => { - console.log("mark as delivered success."); - }, (error: CometChat.CometChatException) => { - console.log("An error occurred when marking the message as delivered.", error); - } -); -``` - - - - - -Another option the CometChat SDK provides is to pass the entire message object to the markAsDelivered() method. - - - -```js -CometChat.markAsDelivered(message); -``` - - - - -```ts -let message: CometChat.BaseMessage; -CometChat.markAsDelivered(message); -``` - - - - - -In case you would like to be notified of an error if the receipts fail to go through you can use `.then(successCallback, failureCallback)` of the `markAsDelivered` method. - - - -```js -CometChat.markAsDelivered(message).then( - () => { - console.log("mark as delivered success."); - }, error => { - console.log("An error occurred when marking the message as delivered.", error); - } -); -``` - - - - -```ts -let message: CometChat.BaseMessage; -CometChat.markAsDelivered(message).then( - () => { - console.log("mark as delivered success."); - }, (error: CometChat.CometChatException) => { - console.log("An error occurred when marking the message as delivered.", error); - } -); -``` - - - - - -## Mark Messages as Read - -*In other words, as a recipient, how do I inform the sender I've read a message?* - -You can mark the messages for a particular conversation as read using the `markAsRead()` method. This method takes the below parameters as input: - -| Parameter | Information | -| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `messageId` | The ID of the message above which all the messages for a particular conversation are to be marked as read. | -| `receiverId` | In case of one to one conversation message's sender `UID` will be the receipt's receiver Id. In case of group conversation message's receiver Id will be the receipt's receiver Id | -| `receiverType` | Type of the receiver. Could be either of the two values( user or group) | -| `senderId` | The `UID` of the sender of the message. | - -Messages for both User conversation and Groups can be marked as read using this method. - -Ideally, you would like to mark all the messages as read for any conversation when the user opens the chat window for that conversation. This includes two scenarios: - -1. **When the list of messages for the conversation is fetched**: In this case you need to obtain the last message in the list of messages and pass the message Id of that message to the markAsRead() method. -2. **When the user is on the chat window and a real-time message is received:** In this case you need to obtain the message Id of the message and pass it to the markAsRead() method - - - -```js -var messageId = "MESSAGE_ID"; -var receiverId = "MESSAGE_SENDER_UID"; -var receiverType = "user"; -var senderId = "MESSAGE_SENDER_UID"; -CometChat.markAsRead(messageId, receiverId, receiverType, senderId); -``` - - - - -```js -var messageId = "MESSAGE_ID"; -var receiverId = "MESSAGE_RECEIVER_GUID"; -var receiverType = "group"; -var senderId = "MESSAGE_SENDER_UID"; -CometChat.markAsRead(messageId, receiverId, receiverType, senderId); -``` - - - - -```ts -var messageId: string = "MESSAGE_ID"; -var receiverId: string = "MESSAGE_SENDER_UID"; -var receiverType: string = "user"; -var senderId: string = "MESSAGE_SENDER_UID"; -CometChat.markAsRead(messageId, receiverId, receiverType, senderId); -``` - - - - -```ts -var messageId: string = "MESSAGE_ID"; -var receiverId: string = "MESSAGE_RECEIVER_GUID"; -var receiverType: string = "group"; -var senderId: string = "MESSAGE_SENDER_UID"; -CometChat.markAsRead(messageId, receiverId, receiverType, senderId); -``` - - - - - -This method will mark all the messages before the messageId specified, for the conversation with receiverId and receiverType(user/group) as read. - -In case you would like to be notified of an error if the receipts fail to go through you can use `.then(successCallback, failureCallback)` of the `markAsDelivered` method. - - - -```js -CometChat.markAsRead(message.getId(), message.getSender().getUid(), 'user', message.getSender().getUid()).then( - () => { - console.log("mark as read success."); - }, error => { - console.log("An error occurred when marking the message as read.", error); - } -); -``` - - - - -```js -CometChat.markAsRead(message.getId(), message.getReceiverUid(), 'group', message.getSender().getUid()).then( - () => { - console.log("mark as read success."); - }, error => { - console.log("An error occurred when marking the message as read.", error); - } -); -``` - - - - -```ts -var messageId: string = "MESSAGE_ID"; -var receiverId: string = "MESSAGE_SENDER_UID"; -var receiverType: string = "user"; -var senderId: string = "MESSAGE_SENDER_UID"; -CometChat.markAsRead(messageId, receiverId, receiverType, senderId).then( - () => { - console.log("mark as read success."); - }, (error: CometChat.CometChatException) => { - console.log("An error occurred when marking the message as read.", error); - } -); -``` - - - - -```ts -var messageId: string = "MESSAGE_ID"; -var receiverId: string = "MESSAGE_RECEIVER_GUID"; -var receiverType: string = "group"; -var senderId: string = "MESSAGE_SENDER_UID"; -CometChat.markAsRead(messageId, receiverId, receiverType, senderId).then( - () => { - console.log("mark as read success."); - }, (error: CometChat.CometChatException) => { - console.log("An error occurred when marking the message as read.", error); - } -); -``` - - - - - -Another option the CometChat SDK provides is to pass the entire message object to the markAsRead() method. - - - -```js -CometChat.markAsRead(message) -``` - - - - -```ts -let message: CometChat.BaseMessage; -CometChat.markAsRead(message); -``` - - - - - -In case you would like to be notified of an error if the receipts fail to go through you can use `.then(successCallback, failureCallback)` of the `markAsDelivered` method. - - - -```js -CometChat.markAsRead(message).then( - () => { - console.log("mark as read success."); - }, error => { - console.log("An error occurred when marking the message as read.", error); - } -); -``` - - - - -```ts -let message: CometChat.BaseMessage; -CometChat.markAsRead(message).then( - () => { - console.log("mark as read success."); - }, (error: CometChat.CometChatException) => { - console.log("An error occurred when marking the message as read.", error); - } -); -``` - - - - - -## Receive Delivery & Read Receipts - -*In other words, as a recipient, how do I know when a message I sent has been delivered or read by someone?* - -### Real-time Receipts - -Real-time events for messages of a conversation being read or delivered can be obtained in the `onMessagesRead()` and the `onMessagesDelivered()` methods of the `MessageListener` class. - - - -```js -let listenerId = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener( - "listenerId", - new CometChat.MessageListener({ - onMessagesDelivered: messageReceipt => { - console.log("MessageDeliverd", { messageReceipt }); - }, - onMessagesRead: messageReceipt => { - console.log("MessageRead", { messageReceipt }); - } - }) -); -``` - - - - -```ts -let listenerId: string = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener( - listenerId, - new CometChat.MessageListener({ - onMessagesDelivered: (messageReceipt: CometChat.MessageReceipt) => { - console.log("MessageDeliverd", { messageReceipt }); - }, - onMessagesRead: (messageReceipt: CometChat.MessageReceipt) => { - console.log("MessageRead", { messageReceipt }); - } - }) -); -``` - - - - - -You will receive events in the form of `MessageReceipt` objects. The message receipt contains the below parameters: - -| Parameter | Information | -| -------------- | -------------------------------------------------------------------------------------------------------------------- | -| `messageId` | The Id of the message prior to which all the messages for that particular conversation have been marked as read. | -| `sender` | User object containing the details of the user who has marked the message as read. | -| `receiverId` | Id of the receiver whose conversation has been marked as read. | -| `receiverType` | type of the receiver (user/group) | -| `receiptType` | Type of the receipt (read/delivered) | -| `deliveredAt` | The timestamp of the time when the message was delivered. This will only be present if the receiptType is delivered. | -| `readAt` | The timestamp of the time when the message was read. This will only be present when the receiptType is read. | - -### Missed Receipts - -You will receive message receipts when you load offline messages. For groups, we do not include the list the users that have received it. You need to call the `getMessageReceipts()` method for it. - -While fetching messages in bulk, if the message is a part of a user conversation, the message object will have two fields viz. `deliveredAt` and `readAt` which hold the timestamp for the time the message was delivered and read respectively. using these two variables, the delivery and read status for a user message can be obtained. - -However, for a group message, the `deliveredAt` and `readAt` fields are never set and hence to get the status of the message you can use the below-described method. - -### Receipt History for a Single Message - -In order to fetch the message receipts, you can use the `getMessageReceipts()` method. - - - -```js -let messageId = msgId; -CometChat.getMessageReceipts(messageId).then( - receipts => { - console.log("Message details fetched:", receipts); - }, - error => { - console.log("Error in getting messag details ", error); - } -); -``` - - - - -```ts -let messageId: number = 1; -CometChat.getMessageReceipts(messageId).then( - (receipts: CometChat.MessageReceipt[]) => { - console.log("Message details fetched:", receipts); - }, (error: CometChat.CometChatException) => { - console.log("Error in getting messag details ", error); - } -); -``` - - - - - -You will receive a list of `MessageReceipt` objects. diff --git a/sdk/ionic-legacy/3.0/messaging-receive-messages.mdx b/sdk/ionic-legacy/3.0/messaging-receive-messages.mdx deleted file mode 100644 index ace720134..000000000 --- a/sdk/ionic-legacy/3.0/messaging-receive-messages.mdx +++ /dev/null @@ -1,945 +0,0 @@ ---- -title: "Receive Messages" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -Receiving messages with CometChat has two parts: - -1. Adding a listener to receive [real-time messages](/sdk/ionic-legacy/3.0/messaging-receive-messages#real-time-messages) when your app is running. -2. Calling a method to retrieve [missed messages](/sdk/ionic-legacy/3.0/messaging-receive-messages#missed-messages) when your app was not running. - -## Real-Time Messages - -*In other words, as a recipient, how do I receive messages when my app is running?* - -To receive real-time incoming messages, you need to register the `MessageListener` wherever you wish to receive the incoming messages. You can use the `addMessageListener()` method to do so. - - - -```js -let listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener( - listenerID, - new CometChat.MessageListener({ - onTextMessageReceived: (textMessage) => { - console.log("Text message received successfully", textMessage); - }, - onMediaMessageReceived: (mediaMessage) => { - console.log("Media message received successfully", mediaMessage); - }, - onCustomMessageReceived: (customMessage) => { - console.log("Custom message received successfully", customMessage); - }, - }) -); -``` - - - - -```ts -let listenerID: string = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener( - listenerID, - new CometChat.MessageListener({ - onTextMessageReceived: (textMessage: CometChat.TextMessage) => { - console.log("Text message received successfully", textMessage); - }, - onMediaMessageReceived: (mediaMessage: CometChat.MediaMessage) => { - console.log("Media message received successfully", mediaMessage); - }, - onCustomMessageReceived: (customMessage: CometChat.CustomMessage) => { - console.log("Custom message received successfully", customMessage); - }, - }) -); -``` - - - - - -| Parameter | Description | -| -------------- | --------------------------------------------- | -| **listenerId** | An ID that uniquely identifies that listener. | - -We recommend you remove the listener once you don't want to receive a message for particular listener. - - - -```js -let listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.removeMessageListener(listenerID); -``` - - - - -```ts -let listenerID: string = "UNIQUE_LISTENER_ID"; - -CometChat.removeMessageListener(listenerID); -``` - - - - - - - -As a sender, you will not receive your own message in a real-time message event. However, if a user is logged-in using multiple devices, they will receive an event for their own message in other devices. - - - -## Missed Messages - -*In other words, as a recipient, how do I receive messages that I missed when my app was not running?* - -For most use cases, you will need to add functionality to load missed messages. If you're building an on-demand or live streaming app, you may choose to skip this and fetch message history instead. - -Using the same `MessagesRequest` class and the filters provided by the `MessagesRequestBuilder` class, you can fetch the message that we sent to the logged-in user but were not delivered to him as he was offline. For this, you will require the ID of the last message received. You can either maintain it at your end or use the `getLastDeliveredMessageId()` method provided by the CometChat class. This ID needs to be passed to the `setMessageId()` method of the builder class. - -Now using the `fetchNext()` method, you can fetch all the messages that were sent to the user when he/she was offline. - -Calling the `fetchNext()` method on the same object repeatedly allows you to fetch all the offline messages for the logged in user. - -### Fetch Missed Messages of a particular one-on-one conversation - - - -```js -let UID = "UID"; -let limit = 30; -let latestId = await CometChat.getLastDeliveredMessageId(); - -var messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setMessageId(latestId) - .setLimit(limit) - .build(); - -messagesRequest.fetchNext().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```ts -let UID: string = "UID", - limit: number = 30, - latestId: number = await CometChat.getLastDeliveredMessageId(), - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setMessageId(latestId) - .setLimit(limit) - .build(); - -messagesRequest.fetchNext().then( - (messages: CometChat.BaseMessage[]) => { - console.log("Message list fetched:", messages); - }, - (error: CometChat.CometChatException) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -### Fetch Missed Messages of a particular group conversation - - - -```js -let GUID = "GUID"; -var limit = 30; -let latestId = await CometChat.getLastDeliveredMessageId(); - -var messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setMessageId(latestId) - .setLimit(limit) - .build(); - -messagesRequest.fetchNext().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```ts -let GUID: string = "GUID", - limit: number = 30, - latestId: number = await CometChat.getLastDeliveredMessageId(), - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setMessageId(latestId) - .setLimit(limit) - .build(); - -messagesRequest.fetchNext().then( - (messages: CometChat.BaseMessage[]) => { - console.log("Message list fetched:", messages); - }, - (error: CometChat.CometChatException) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -## Unread Messages - -*In other words, as a logged-in user, how do I fetch the messages I've not read?* - -Using the `MessagesRequest` class described above, you can fetch the unread messages for the logged in user. In order to achieve this, you need to set the `unread` variable in the builder to `true` using the `setUnread()` method so that only the unread messages are fetched. - -### Fetch Unread Messages of a particular one-on-one conversation - - - -```js -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setUnread(true) - .setLimit(limit) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```ts -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setUnread(true) - .setLimit(limit) - .build(); - -messagesRequest.fetchPrevious().then( - (messages: CometChat.BaseMessage[]) => { - console.log("Message list fetched:", messages); - }, - (error: CometChat.CometChatException) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -### Fetch Unread Messages of a particular group conversation - - - -```js -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setUnread(true) - .setLimit(limit) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```ts -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setUnread(true) - .setLimit(limit) - .build(); - -messagesRequest.fetchPrevious().then( - (messages: CometChat.BaseMessage[]) => { - console.log("Message list fetched:", messages); - }, - (error: CometChat.CometChatException) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - - -**Base Message** - -The list of messages received is in the form of objects of `BaseMessage` class. A BaseMessage can either be an object of the `TextMessage`, `MediaMessage`, `CustomMessage`, `Action` or `Call` class. You can use the `instanceOf` operator to check the type of object. - - - -## Message History - -*In other words, as a logged-in user, how do I fetch the complete message history?* - -### Fetch Message History of a particular one-on-one conversation - -Using the `MessagesRequest` class and the filters for the `MessagesRequestBuilder` class as shown in the below code snippet, you can fetch the entire conversation between the logged in user and any particular user. For this use case, it is mandatory to set the UID parameter using the `setUID()` method of the builder. This UID is the unique id of the user for which the conversation needs to be fetched. - - - -```js -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```ts -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder().setUID(UID).setLimit(limit).build(); - -messagesRequest.fetchPrevious().then( - (messages: CometChat.BaseMessage[]) => { - console.log("Message list fetched:", messages); - }, - (error: CometChat.CometChatException) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -Calling the `fetchPrevious()` method on the same object repeatedly allows you to fetch the entire conversation between the logged in user and the specified user. This can be implemented with upward scrolling to display the entire conversation. - -### Fetch Message History of a particular group conversation - -Using the `MessagesRequest` class and the filters for the `MessagesRequestBuilder` class as shown in the below code snippet, you can fetch the entire conversation for any group provided you have joined the group. For this use case, it is mandatory to set the GUID parameter using the `setGUID()` method of the builder. This GUID is the unique identifier of the Group for which the messages are to be fetched. - - - -```js -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```ts -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .build(); - -messagesRequest.fetchPrevious().then( - (messages: CometChat.BaseMessage[]) => { - console.log("Message list fetched:", messages); - }, - (error: CometChat.CometChatException) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -Calling the `fetchPrevious()` method on the same object repeatedly allows you to fetch the entire conversation for the group. This can be implemented with upward scrolling to display the entire conversation. - -## Search Messages - -Along with the other parameters mentioned above, you can use the `setSearchKeyword()` method provided by the `MessagesRequestBuilder` class. This method takes a string as input. This is the string that is to be searched amongst the messages. This can be used to fetch all the messages that contain the string in a paginated way. Calling the `fetchPrevious()` method on the same object repeatedly allows you to fetch all the messages with the keyword specified in all your conversations. - -### Search Messages in a particular one-on-one conversation - - - -```js -let UID = "UID"; -let limit = 30; -let searchKeyword = "Hello"; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```ts -let UID: string = "UID", - limit: number = 30, - searchKeyword: string = "Hello", - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); - -messagesRequest.fetchPrevious().then( - (messages: CometChat.BaseMessage[]) => { - console.log("Message list fetched:", messages); - }, - (error: CometChat.CometChatException) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -### Search Messages in a particular group conversation - - - -```js -let GUID = "GUID"; -let limit = 30; -let searchKeyword = "Hello"; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```ts -let GUID: string = "GUID", - limit: number = 30, - searchKeyword: string = "Hello", - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); - -messagesRequest.fetchPrevious().then( - (messages: CometChat.BaseMessage[]) => { - console.log("Message list fetched:", messages); - }, - (error: CometChat.CometChatException) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -## Unread Message Count - -*In other words, as a logged-in user, how do I find out the number of unread messages that I have?* - -### Fetch Unread Message Count of a particular one-on-one conversation - -*In other words, how do I find out the number of unread messages I have from a particular user?* - -In order to get the unread message count for a particular user, you can use the `getUnreadMessageCountForUser()`. - -This method has the below two variants: - - - -```js -CometChat.getUnreadMessageCountForUser(UID); -``` - - - - -```ts -let UID: string = "UID"; -CometChat.getUnreadMessageCountForUser(UID); -``` - - - - - -if you wish to ignore the messages from blocked users you can use the below syntax setting the boolean parameter to true: - - - -```js -CometChat.getUnreadMessageCountForUser(UID, hideMessagesFromBlockedUsers); -``` - - - - -```ts -let UID: string = "UID", - hideMessagesFromBlockedUsers: boolean = true; -CometChat.getUnreadMessageCountForUser(UID, hideMessagesFromBlockedUsers); -``` - - - - - - - -```js -let UID = "UID"; - -CometChat.getUnreadMessageCountForUser(UID).then( - (array) => { - console.log("Message count fetched", array); - }, - (error) => { - console.log("Error in getting message count", error); - } -); -``` - - - - -```ts -let UID: string = "UID"; - -CometChat.getUnreadMessageCountForUser(UID).then( - (unreadMessageCount: Object) => { - console.log("Message count fetched", unreadMessageCount); - }, - (error: CometChat.CometChatException) => { - console.log("Error in getting message count", error); - } -); -``` - - - - - -In the `then()` callback, you will receive an array which will contain the `UID` of the user as the key and the unread message count as the value. - -### Fetch Unread Message Count of a particular group conversation - -*In other words, how do I find out the number of unread messages I have in a single group?* - -In order to get the unread message count for a particular group, you can use the `getUnreadMessageCountForGroup()`. - -This method has the below two variants: - - - -```js -CometChat.getUnreadMessageCountForGroup(GUID); -``` - - - - -```ts -let GUID: string = "GUID"; -CometChat.getUnreadMessageCountForGroup(GUID); -``` - - - - - -if you wish to ignore the messages from blocked users you can use the below syntax setting the boolean parameter to true: - - - -```js -CometChat.getUnreadMessageCountForGroup(GUID, hideMessagesFromBlockedUsers); -``` - - - - -```ts -let GUID: string = "GUID", - hideMessagesFromBlockedUsers: boolean = true; -CometChat.getUnreadMessageCountForGroup(GUID, hideMessagesFromBlockedUsers); -``` - - - - - - - -```js -let GUID = "GUID"; - -CometChat.getUnreadMessageCountForGroup(GUID).then( - (array) => { - console.log("Message count fetched", array); - }, - (error) => { - console.log("Error in getting message count", error); - } -); -``` - - - - -```ts -let GUID: string = "GUID"; - -CometChat.getUnreadMessageCountForGroup(GUID).then( - (unreadMessageCount: Object) => { - console.log("Message count fetched", unreadMessageCount); - }, - (error: CometChat.CometChatException) => { - console.log("Error in getting message count", error); - } -); -``` - - - - - -In the `then()` callback, you will receive an array which will contain the `UID` of the user as the key and the unread message count as the value. - -### Fetch Unread Message Count of all one-on-one & group conversations - -*In other words, how do I find out the number of unread messages for every one-on-one and group conversation?* - -In order to get all the unread message count combined i.e unread message counts for all the users and groups, you can use the `getUnreadMessageCount()` method. - -This method has two variants: - - - -```js -CometChat.getUnreadMessageCount(); -``` - - - - -```ts -CometChat.getUnreadMessageCount(); -``` - - - - - -if you wish to ignore the messages from blocked users you can use the below syntax setting the boolean parameter to true: - - - -```js -CometChat.getUnreadMessageCount(hideMessagesFromBlockedUsers); -``` - - - - -```ts -let hideMessagesFromBlockedUsers: boolean = true; -CometChat.getUnreadMessageCount(hideMessagesFromBlockedUsers); -``` - - - - - - - -```js -CometChat.getUnreadMessageCount().then( - (array) => { - console.log("Message count fetched", array); - }, - (error) => { - console.log("Error in getting message count", error); - } -); -``` - - - - -```ts -CometChat.getUnreadMessageCount().then( - (unreadMessageCount: Object) => { - console.log("Message count fetched", unreadMessageCount); - }, - (error: CometChat.CometChatException) => { - console.log("Error in getting message count", error); - } -); -``` - - - - - -It return array having two keys: - -1. user - The value for this key holds another array that holds the UIDs of the users and their corresponding unread message counts -2. group - The value for this key holds another array that holds the GUIDs of the groups and their corresponding unread message counts - -### Fetch Unread Message Count of all one-on-one conversations - -In order to fetch the unread message counts for just the users, you can use the `getUnreadMessageCountForAllUsers()` method. This method just like others has two variants: - - - -```js -CometChat.getUnreadMessageCountForAllUsers(); -``` - - - - -```ts -CometChat.getUnreadMessageCountForAllUsers(); -``` - - - - - -if you wish to ignore the messages from blocked users you can use the below syntax setting the boolean parameter to true: - - - -```js -CometChat.getUnreadMessageCountForAllUsers(hideMessagesFromBlockedUsers); -``` - - - - -```ts -let hideMessagesFromBlockedUsers: boolean = true; -CometChat.getUnreadMessageCountForAllUsers(hideMessagesFromBlockedUsers); -``` - - - - - - - -```js -CometChat.getUnreadMessageCountForAllUsers().then( - (array) => { - console.log("Message count fetched", array); - }, - (error) => { - console.log("Error in getting message count", error); - } -); -``` - - - - -```ts -CometChat.getUnreadMessageCountForAllUsers().then( - (unreadMessageCount: Object) => { - console.log("Message count fetched", unreadMessageCount); - }, - (error: CometChat.CometChatException) => { - console.log("Error in getting message count", error); - } -); -``` - - - - - -It returns a Array which will contain the UIDs of the users as the key and the unread message counts as the values. - -### Fetch Unread Message Count of all group conversations - -In order to fetch the unread message counts for just the groups, you can use the `getUnreadMessageCountForAllGroups()` method. This method just like others has two variants: - - - -```js -CometChat.getUnreadMessageCountForAllGroups(); -``` - - - - -```ts -CometChat.getUnreadMessageCountForAllGroups(); -``` - - - - - -if you wish to ignore the messages from blocked users you can use the below syntax setting the boolean parameter to true: - - - -```js -CometChat.getUnreadMessageCountForAllGroups(hideMessagesFromBlockedUsers); -``` - - - - -```ts -let hideMessagesFromBlockedUsers: boolean = true; -CometChat.getUnreadMessageCountForAllGroups(hideMessagesFromBlockedUsers); -``` - - - - - - - -```js -CometChat.getUnreadMessageCountForAllGroups().then( - (array) => { - console.log("Message count fetched", array); - }, - (error) => { - console.log("Error in getting message count", error); - } -); -``` - - - - -```ts -CometChat.getUnreadMessageCountForAllGroups().then( - (unreadMessageCount: Object) => { - console.log("Message count fetched", unreadMessageCount); - }, - (error: CometChat.CometChatException) => { - console.log("Error in getting message count", error); - } -); -``` - - - - - -It returns a Array which will contain the GUIDs of the groups as the key and the unread message counts as the values. diff --git a/sdk/ionic-legacy/3.0/messaging-retrieve-conversations.mdx b/sdk/ionic-legacy/3.0/messaging-retrieve-conversations.mdx deleted file mode 100644 index d28a9dee9..000000000 --- a/sdk/ionic-legacy/3.0/messaging-retrieve-conversations.mdx +++ /dev/null @@ -1,425 +0,0 @@ ---- -title: "Retrieve Conversations" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -Conversations provide the last messages for every one-on-one and group conversation the logged-in user is a part of. This makes it easy for you to build a **Recent Chats** list. - -## Retrieve List of Conversations - -*In other words, as a logged-in user, how do I retrieve the latest conversations that I've been a part of?* - -In order to fetch the list of conversations, you can use the `ConversationsRequest` class. To use this class i.e to create an object of the `ConversationsRequest` class, you need to use the `ConversationsRequestBuilder` class. The `ConversationsRequestBuilder` class allows you to set the parameters based on which the conversations are to be fetched. - -The `ConversationsRequestBuilder` class allows you to set the below parameters: - -### Set Limit - -This method sets the limit i.e. the number of conversations that should be fetched in a single iteration. - - - -```js -let limit = 30; -let conversationRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .build(); -``` - - - - -```ts -let limit: number = 30, - conversationRequest: CometChat.ConversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .build(); -``` - - - - - -### Set Conversation Type - -This method can be used to fetch user or group conversations specifically. The `conversationType` variable can hold one of the below two values: - -* user - Only fetches user conversation. -* group - Only fetches group conversations. - -If none is set, the list of conversations will include both user and group conversations. - - - -```js -let limit = 30; -let conversationType = "group"; -let conversationRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setConversationType(conversationType) - .build(); -``` - - - - -```ts -let limit: number = 30, - conversationType: string = "group", - conversationRequest: CometChat.ConversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setConversationType(conversationType) - .build(); -``` - - - - - -### With User and Group Tags - -This method can be used to fetch the user/group tags in the `Conversation` Object. By default the value is false. - - - -```js -let limit = 30; -let conversationRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .withUserAndGroupTags(true) - .build(); -``` - - - - -```ts -let limit: number = 30, - conversationRequest: CometChat.ConversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .withUserAndGroupTags(true) - .build(); -``` - - - - - -### Set User Tags - -This method fetches user conversations which has the specified tags. - - - -```js -let limit = 30; -let userTags = ["tag1"]; -let conversationRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setUserTags(userTags) - .build(); -``` - - - - -```ts -let limit: number = 30, - userTags: Array = ["tag1"], - conversationRequest: CometChat.ConversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setUserTags(userTags) - .build(); -``` - - - - - -### Set Group Tags - -This method fetches group conversations which has the specified tags. - - - -```js -let limit = 30; -let groupTags = ["tag1"]; -let conversationRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setGroupTags(groupTags) - .build(); -``` - - - - -```ts -let limit: number = 30, - groupTags: Array = ["tag1"], - conversationRequest: CometChat.ConversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setGroupTags(groupTags) - .build(); -``` - - - - - -### With Tags - -This method makes sure that the tags associated the conversations are returned along with the other details of the conversations. The default value for this parameter is `false` - - - -```js -let limit = 30; -let conversationRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .withTags(true) - .build(); -``` - - - - -```ts -let limit: number = 30, - conversationRequest: CometChat.ConversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .withTags(true) - .build(); -``` - - - - - -### Set Tags - -This method helps you fetch the conversations based on the specified tags. - - - -```js -let limit = 30; -let tags = ["archivedChat"]; -let conversationRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setTags(tags) - .build(); -``` - - - - -```ts -let limit: number = 30, - tags: Array = ["archivedChat"], - conversationRequest: CometChat.ConversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setTags(tags) - .build(); -``` - - - - - -Finally, once all the parameters are set to the builder class, you need to call the `build()` method to get the object of the `ConversationsRequest` class. - -Once you have the object of the `ConversationsRequest` class, you need to call the `fetchNext()` method. Calling this method will return a list of `Conversation` objects containing X number of users depending on the limit set. - -A Maximum of only 50 Conversations can be fetched at once. - - - -```js -let limit = 30; -let conversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .build(); - -conversationsRequest.fetchNext().then( - conversationList => { - console.log("Conversations list received:", conversationList); - }, error => { - console.log("Conversations list fetching failed with error:", error); - } -); -``` - - - - -```ts -let limit: number = 30, - conversationsRequest: CometChat.ConversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .build(); - -conversationsRequest.fetchNext().then( - (conversationList: CometChat.Conversation[]) => { - console.log("Conversations list received:", conversationList); - }, (error: CometChat.CometChatException) => { - console.log("Conversations list fetching failed with error:", error); - } -); -``` - - - - - -The `Conversation` Object consists of the below fields: - -| Field | Information | -| ------------------ | ----------------------------------------------------------------- | -| conversationId | ID of the conversation. | -| conversationType | Type of conversation. (user/group) | -| lastMessage | Last message the conversation. | -| conversationWith | User or Group object containing the details of the user or group. | -| unreadMessageCount | Unread message count for the conversation. | - -## Tag Conversation - -*In other words, as a logged-in user, how do I tag a conversation?* - -In order to tag a specific conversation, you can use the `tagConversation()` method. The `tagConversation()` method accepts three parameters. - -1. `conversationWith`: UID/GUID of the user/group whose conversation you want to fetch. - -2. `conversationType`: The `conversationType` variable can hold one of the below two values: - - 1. user - Only fetches user conversation. - 2. group - Only fetches group conversations. - -3. `tags`: The `tags` variable will be a list of tags you want to add to a conversation. - - - -```js -let tags = ["archivedChat"]; -CometChat.tagConversation('conversationWith', 'conversationType', tags).then( - conversation => { - console.log('conversation', conversation); - }, error => { - console.log('error while fetching a conversation', error); - } -); -``` - - - - -```ts -let conversationWith: string = "UID", - tags: Array = ["archivedChat"], - conversationType: string = "user"; -CometChat.tagConversation(conversationWith, conversationType, tags).then( - (conversation: CometChat.Conversation) => { - console.log('conversation', conversation); - }, (error: CometChat.CometChatException) => { - console.log('error while fetching a conversation', error); - } -); -``` - - - - - - - -The tags for conversations are one-way. This means that if user A tags a conversation with user B, that tag will be applied to that conversation only for user A. - - - -## Retrieve Single Conversation - -*In other words, as a logged-in user, how do I retrieve a specific conversation?* - -In order to fetch a specific conversation, you can use the `getConversation` method. The `getConversation` method accepts two parameters. - -1. `conversationWith`: UID/GUID of the user/group whose conversation you want to fetch. -2. `conversationType`: The `conversationType` variable can hold one of the below two values: - -* user - Only fetches user conversation. -* group - Only fetches group conversations. - - - -```js -CometChat.getConversation('conversationWith', 'conversationType').then( - conversation => { - console.log('conversation', conversation); - }, error => { - console.log('error while fetching a conversation', error); - } -); -``` - - - - -```ts -let conversationWith: string = "UID", - conversationType: string = "user"; -CometChat.getConversation(conversationWith, conversationType).then( - (conversation: CometChat.Conversation) => { - console.log('conversation', conversation); - }, (error: CometChat.CometChatException) => { - console.log('error while fetching a conversation', error); - } -); -``` - - - - - -## Convert Messages to Conversations - -As per our [receive messages](/sdk/ionic-legacy/3.0/messaging-receive-messages) guide, for real-time messages, you will always receive `Message` objects and not `Conversation` objects. Thus, you will need a mechanism to convert the Message object to `Conversation` object. You can use the `getConversationFromMessage(BaseMessage message)` of the `CometChatHelper` class. - - - -```js -CometChat.CometChatHelper.getConversationFromMessage(message).then( - conversation => { - console.log("Conversation Object", conversation); - }, error => { - console.log("Error while converting message object", error); - } -); -``` - - - - -```ts -let message: CometChat.TextMessage | CometChat.MediaMessage | CometChat.CustomMessage; -CometChat.CometChatHelper.getConversationFromMessage(message).then( - (conversation: CometChat.Conversation) => { - console.log("Conversation Object", conversation); - }, (error: CometChat.CometChatException) => { - console.log("Error while converting message object", error); - } -); -``` - - - - - - - -While converting `Message` object to `Conversation` object, the `unreadMessageCount` & `tags` will not be available in the `Conversation` object. The unread message count needs to be managed in your client-side code. - - diff --git a/sdk/ionic-legacy/3.0/messaging-send-message.mdx b/sdk/ionic-legacy/3.0/messaging-send-message.mdx deleted file mode 100644 index 6b248c669..000000000 --- a/sdk/ionic-legacy/3.0/messaging-send-message.mdx +++ /dev/null @@ -1,970 +0,0 @@ ---- -title: "Send A Message" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -Using CometChat, you can send three types of messages: - -1. A [text message](/sdk/ionic-legacy/3.0/messaging-send-message#text-message), the most common and standard message type. -2. A [media message](/sdk/ionic-legacy/3.0/messaging-send-message#media-message), for sending photos, videos and files. -3. A [custom message](/sdk/ionic-legacy/3.0/messaging-send-message#custom-message), for sending completely custom data using JSON structures. - -You can also send metadata along with a text, media or custom message. Think, for example, if you'd want to share the user's location with every message, you can use the metadata field - -## Text Message - -*In other words, as a sender, how do I send a text message?* - -To send a text message to a single user or group, you need to use the `sendMessage()` method and pass a `TextMessage` object to it. - -### Add Metadata - -To send custom data along with a text message, you can use the `setMetadata` method and pass a `JSONObject` to it. - - - -```js -let metadata = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002" -}; - -textMessage.setMetadata(metadata); -``` - - - - -```ts -let metadata: Object = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002" -}; - -textMessage.setMetadata(metadata); -``` - - - - - -### Add Tags - -To add a tag to a message you can use the `setTags()` method of the TextMessage Class. The `setTags()` method accepts a list of tags. - - - -```js -let tags = ["starredMessage"]; - -textMessage.setTags(tags); -``` - - - - -```ts -let tags: Array = ["starredMessage"]; - -textMessage.setTags(tags); -``` - - - - - -Once the text message object is ready, you need to use the `sendMessage()` method to send the text message to the recipient. - - - -```js -let receiverID = "UID"; -let messageText = "Hello world!"; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let textMessage = new CometChat.TextMessage(receiverID, messageText, receiverType); - -CometChat.sendMessage(textMessage).then( - message => { - console.log("Message sent successfully:", message); - }, error => { - console.log("Message sending failed with error:", error); - } -); -``` - - - - -```js -let receiverID = "GUID"; -let messageText = "Hello world!"; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; -let textMessage = new CometChat.TextMessage(receiverID, messageText, receiverType); - -CometChat.sendMessage(textMessage).then( - message => { - console.log("Message sent successfully:", message); - }, error => { - console.log("Message sending failed with error:", error); - } -); -``` - - - - -```ts -let receiverID: string = "UID", - messageText: string = "Hello world!", - receiverType: string = CometChat.RECEIVER_TYPE.USER, - textMessage: CometChat.TextMessage = new CometChat.TextMessage(receiverID, messageText, receiverType); - -CometChat.sendMessage(textMessage).then( - (message: CometChat.TextMessage) => { - console.log("Message sent successfully:", message); - }, (error: CometChat.CometChatException) => { - console.log("Message sending failed with error:", error); - } -); -``` - - - - -```ts -let receiverID: string = "GUID", - messageText: string = "Hello world!", - receiverType: string = CometChat.RECEIVER_TYPE.GROUP, - textMessage: CometChat.TextMessage = new CometChat.TextMessage(receiverID, messageText, receiverType); - -CometChat.sendMessage(textMessage).then( - (message: CometChat.TextMessage) => { - console.log("Message sent successfully:", message); - }, (error: CometChat.CometChatException) => { - console.log("Message sending failed with error:", error); - } -); -``` - - - - - -The `TextMessage` class constructor takes the following parameters: - -| Parameter | Description | | -| ---------------- | ------------------------------------------------------------------------------------------------------------- | -------- | -| **receiverID** | `UID` of the user or `GUID` of the group receiving the message | Required | -| **messageText** | The text message | Required | -| **receiverType** | The type of the receiver- `CometChatConstants.RECEIVER_TYPE_USER` or `CometChatConstants.RECEIVER_TYPE_GROUP` | Required | - -When a text message is sent successfully, the response will include a `TextMessage` object which includes all information related to the sent message. - -## Media Message - -*In other words, as a sender, how do I send a media message like photos, videos & files?* - -To send a media message to any user or group, you need to use the `sendMediaMessage()` method and pass a `MediaMessage` object to it. - -### Add Metadata - -To send custom data along with a media message, you can use the `setMetadata` method and pass a `JSONObject` to it. - - - -```js -let metadata = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002" -}; - -mediaMessage.setMetadata(metadata); -``` - - - - -```ts -let metadata = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002" -}; - -mediaMessage.setMetadata(metadata); -``` - - - - - -### Add Caption(Text along with Media Message) - -To send a caption with a media message, you can use `setCaption` method and pass text to it. - - - -```js -let tags = ["starredMessage"]; - -mediaMessage.setTags(tags); -``` - - - - -```ts -let caption: string = "Random Caption"; - -mediaMessage.setCaption(caption); -``` - - - - - -### Add Tags - -To add a tag to a message you can use the `setTags()` method of the MediaMessage Class. The `setTags()` method accepts a list of tags. - - - -```js -let tags = ["starredMessage"]; - -mediaMessage.setTags(tags); -``` - - - - -```ts -let tags: Array = ["starredMessage"]; - -mediaMessage.setTags(tags); -``` - - - - - -There are 2 ways you can send Media Messages using the CometChat SDK: - -1. **By providing the File :** You can directly share the file object while creating an object of the MediaMessage class. When the media message is sent using the `sendMediaMessage()` method, this file is then uploaded to CometChat servers and the URL of the file is sent in the success response of the `sendMediaMessage()` function. - -Getting file Object: You can use different ionic packages for sending media messages. We demonstrate how to send images using CometChat. - - - -```js -const options = { - outputType: 1 -}; -this.imagePicker.getPictures(options) - .then((results) => { - results[0] = 'data:image/jpeg;base64,' + results[0]; - const blob_nw = this.dataURItoBlob(results[0]); - const date = new Date(); - const file = { - file: blob_nw, - type: 'image/jpeg', - name: 'temp_img' + date.getTime() - }; - - this.sendMediaMessage(file); - }, (err) => { - console.log(err); -}); - -dataURItoBlob(dataURI) { - const byteString = atob(dataURI.split(',')[1]); - const mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; - const ab = new ArrayBuffer(byteString.length); - const ia = new Uint8Array(ab); - for (let i = 0; i < byteString.length; i++) { - ia[i] = byteString.charCodeAt(i); - } - const bb = new Blob([ab], {type: mimeString}); - return bb; -} -``` - - - - - - - -```js -let receiverID = "UID"; -let file = "FILE_OBJECT"; -let messageType = CometChat.MESSAGE_TYPE.FILE; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let mediaMessage = new CometChat.MediaMessage(receiverID, file, messageType, receiverType); - -CometChat.sendMediaMessage(mediaMessage).then( - message => { - console.log("Media message sent successfully", message); - }, error => { - console.log("Media message sending failed with error", error); - } -); -``` - - - - -```js -let receiverID = "GUID"; -let file = "FILE_OBJECT"; -let messageType = CometChat.MESSAGE_TYPE.FILE; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; -let mediaMessage = new CometChat.MediaMessage(receiverID, file, messageType, receiverType); - -CometChat.sendMediaMessage(mediaMessage).then( - message => { - console.log("Media message sent successfully", message); - }, error => { - console.log("Media message sending failed with error", error); - } -); -``` - - - - -```ts -let receiverID: string = "UID", - messageType: string = CometChat.MESSAGE_TYPE.FILE, - receiverType: string = CometChat.RECEIVER_TYPE.USER, - mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(receiverID, `INPUT FILE OBJECT`, messageType, receiverType); - -CometChat.sendMediaMessage(mediaMessage).then( - (message: CometChat.MediaMessage) => { - console.log("Media message sent successfully", message); - }, (error: CometChat.CometChatException) => { - console.log("Media message sending failed with error", error); - } -); -``` - - - - -```ts -let receiverID: string = "GUID", - messageType: string = CometChat.MESSAGE_TYPE.FILE, - receiverType: string = CometChat.RECEIVER_TYPE.GROUP, - mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(receiverID, `INPUT FILE OBJECT`, messageType, receiverType); - -CometChat.sendMediaMessage(mediaMessage).then( - (message: CometChat.MediaMessage) => { - console.log("Media message sent successfully", message); - }, (error: CometChat.CometChatException) => { - console.log("Media message sending failed with error", error); - } -); -``` - - - - - -The `MediaMessage` class constructor takes the following parameters: - -| Parameter | Description | -| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **receiverId** | The `UID` or `GUID` of the recipient. | -| **file** | The file object to be sent | -| **messageType** | The type of the message that needs to be sent which in this case can be: 1.`CometChat.MESSAGE_TYPE.IMAGE` 2.`CometChat.MESSAGE_TYPE.VIDEO` 3.`CometChat.MESSAGE_TYPE.AUDIO` 4.`CometChat.MESSAGE_TYPE.FILE` | -| **receiverType** | The type of the receiver to whom the message is to be sent. `1. CometChat.RECEIVER_TYPE.USER`2. CometChat.RECEIVER\_TYPE.GROUP | - -2. **By providing the URL of the File:** The second way to send media messages using the CometChat SDK is to provide the SDK with the URL of any file that is hosted on your servers or any cloud storage. To achieve this you will have to make use of the Attachment class. For more information, you can refer to the below code snippet: - - - -```js -let receiverID = "cometchat-uid-2"; -let messageType = CometChat.MESSAGE_TYPE.IMAGE; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let mediaMessage = new CometChat.MediaMessage(receiverID, "", messageType, receiverType); - -let file = { - name: "mario", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/mario/mario_PNG125.png" -}; - -let attachment = new CometChat.Attachment(file); - -mediaMessage.setAttachment(attachment); - -CometChat.sendMediaMessage(mediaMessage).then( - mediaMessage => { - console.log("message", mediaMessage) - }, error => { - console.log("error in sending message", error) - } -); -``` - - - - -```js -let receiverID = "cometchat-guid-1"; -let messageType = CometChat.MESSAGE_TYPE.IMAGE; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; -let mediaMessage = new CometChat.MediaMessage(receiverID, "", messageType, receiverType); - -let file = { - name: "mario", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/mario/mario_PNG125.png" -}; - -let attachment = new CometChat.Attachment(file); - -mediaMessage.setAttachment(attachment); - -CometChat.sendMediaMessage(mediaMessage).then( - mediaMessage => { - console.log("message", mediaMessage) - }, error => { - console.log("error in sending message", error) - } -); -``` - - - - -```ts -let receiverID: string = "cometchat-uid-2", - messageType: string = CometChat.MESSAGE_TYPE.IMAGE, - receiverType: string = CometChat.RECEIVER_TYPE.USER, - mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(receiverID, "", messageType, receiverType); - -let file: Object = { - name: "mario", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/mario/mario_PNG125.png" -}; - -let attachment: CometChat.Attachment = new CometChat.Attachment(file); - -mediaMessage.setAttachment(attachment); - -CometChat.sendMediaMessage(mediaMessage).then( - (mediaMessage: CometChat.MediaMessage) => { - console.log("message", mediaMessage) - }, (error: CometChat.CometChatException) => { - console.log("error in sending message", error) - } -); -``` - - - - -```ts -let receiverID: string = "cometchat-guid-1", - messageType: string = CometChat.MESSAGE_TYPE.IMAGE, - receiverType: string = CometChat.RECEIVER_TYPE.GROUP, - mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(receiverID, "", messageType, receiverType); - -let file: Object = { - name: "mario", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/mario/mario_PNG125.png" -}; - -let attachment: CometChat.Attachment = new CometChat.Attachment(file); - -mediaMessage.setAttachment(attachment); - -CometChat.sendMediaMessage(mediaMessage).then( - (mediaMessage: CometChat.MediaMessage) => { - console.log("message", mediaMessage) - }, (error: CometChat.CometChatException) => { - console.log("error in sending message", error) - } -); -``` - - - - - -When a media message is sent successfully, the response will include a `MediaMessage` object which includes all information related to the sent message. - -## Multiple Attachments in a Media Message - -Starting version 3.0.9 & above the SDK supports sending of multiple attachments in a single media message. As in case for single attachment in a media message, there are two ways you can send Media Messages using the CometChat SDK: - -1. **By providing an array of files:** You can now share an array of files while creating an object of the MediaMessage class. When the media message is sent using the `sendMediaMessage()` method, the files are uploaded to the CometChat servers & the URL of the files are sent in the success response of the `sendMediaMessage()` method. - -Getting the file Object: You can use different ionic packages for sending media messages. We demonstrate how to send images using CometChat. - - - -```js -const options = { - outputType: 1 -}; -this.imagePicker.getPictures(options) - .then((results) => { - if(results.length > 1){ - let files = []; - for(var i = 0;i { - console.log(err); -}); - -dataURItoBlob(dataURI) { - const byteString = atob(dataURI.split(',')[1]); - const mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; - const ab = new ArrayBuffer(byteString.length); - const ia = new Uint8Array(ab); - for (let i = 0; i < byteString.length; i++) { - ia[i] = byteString.charCodeAt(i); - } - const bb = new Blob([ab], {type: mimeString}); - return bb; -} -``` - - - - - - - -```js -let receiverID = "UID"; -let messageType = CometChat.MESSAGE_TYPE.FILE; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let mediaMessage = new CometChat.MediaMessage(receiverID, files, messageType, receiverType); - -CometChat.sendMediaMessage(mediaMessage).then( - message => { - console.log("Media message sent successfully", message); - }, error => { - console.log("Media message sending failed with error", error); - } -); -``` - - - - -```ts -let receiverID = "GUID"; -let messageType = CometChat.MESSAGE_TYPE.FILE; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; -let mediaMessage = new CometChat.MediaMessage(receiverID, file, messageType, receiverType); - -CometChat.sendMediaMessage(mediaMessage).then( - message => { - console.log("Media message sent successfully", message); - }, error => { - console.log("Media message sending failed with error", error); - } -); -``` - - - - -```js -let receiverID: string = "UID", - messageType: string = CometChat.MESSAGE_TYPE.FILE, - receiverType: string = CometChat.RECEIVER_TYPE.USER, - mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(receiverID, files, messageType, receiverType); - -CometChat.sendMediaMessage(mediaMessage).then( - (message: CometChat.MediaMessage) => { - console.log("Media message sent successfully", message); - }, (error: CometChat.CometChatException) => { - console.log("Media message sending failed with error", error); - } -); -``` - - - - -```ts -let receiverID: string = "GUID", - messageType: string = CometChat.MESSAGE_TYPE.FILE, - receiverType: string = CometChat.RECEIVER_TYPE.GROUP, - mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(receiverID, files, messageType, receiverType); - -CometChat.sendMediaMessage(mediaMessage).then( - (message: CometChat.MediaMessage) => { - console.log("Media message sent successfully", message); - }, (error: CometChat.CometChatException) => { - console.log("Media message sending failed with error", error); - } -); -``` - - - - - -The `MediaMessage` class constructor takes the following parameters: - -| Parameter | Description | -| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **receiverId** | The `UID` or `GUID` of the recipient. | -| **files** | An array of files. | -| **messageType** | The type of the message that needs to be sent which in this case can be: 1.`CometChat.MESSAGE_TYPE.IMAGE` 2.`CometChat.MESSAGE_TYPE.VIDEO` 3.`CometChat.MESSAGE_TYPE.AUDIO` 4.`CometChat.MESSAGE_TYPE.FILE` | -| **receiverType** | The type of the receiver to whom the message is to be sent. `1. CometChat.RECEIVER_TYPE.USER`2. CometChat.RECEIVER\_TYPE.GROUP\`\` | - -2. **By providing the URL of the multiple files:** The second way to send multiple attachments in a single media message using the CometChat SDK is to provide the SDK with the URL of multiple files that is hosted on your servers or any cloud storage. To achieve this you will have to make use of the Attachment class. For more information, you can refer to the below code snippet: - - - -```js -let receiverID = "cometchat-uid-2"; -let messageType = CometChat.MESSAGE_TYPE.IMAGE; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let mediaMessage = new CometChat.MediaMessage(receiverID, "", messageType, receiverType); - -let attachment1 = { - name: "mario", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/mario/mario_PNG125.png" -}; - -let attachment2 = { - name: "jaguar", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/jaguar/jaguar_PNG20759.png" -}; - -let attachments = []; -attachments.push(new CometChat.Attachment(attachment1)); -attachments.push(new CometChat.Attachment(attachment2)); - -mediaMessage.setAttachments(attachments); - -CometChat.sendMediaMessage(mediaMessage).then( - mediaMessage => { - console.log("message", mediaMessage) - }, error => { - console.log("error in sending message", error) - } -); -``` - - - - -```ts -let receiverID: string = "cometchat-uid-2", - messageType: string = CometChat.MESSAGE_TYPE.IMAGE, - receiverType: string = CometChat.RECEIVER_TYPE.USER, - mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(receiverID, "", messageType, receiverType); - -let attachment1: Object = { - name: "mario", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/mario/mario_PNG125.png" -}; - -let attachment2: Object = { - name: "jaguar", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/jaguar/jaguar_PNG20759.png" -}; - -let attachments: Array = []; -attachments.push(new CometChat.Attachment(attachment1)); -attachments.push(new CometChat.Attachment(attachment2)); - -mediaMessage.setAttachments(attachments); - -CometChat.sendMediaMessage(mediaMessage).then( - (mediaMessage: CometChat.MediaMessage) => { - console.log("message", mediaMessage) - }, (error: CometChat.CometChatException) => { - console.log("error in sending message", error) - } -); -``` - - - - -```js -let receiverID = "cometchat-guid-1"; -let messageType = CometChat.MESSAGE_TYPE.IMAGE; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; -let mediaMessage = new CometChat.MediaMessage(receiverID, "", messageType, receiverType); - -let attachment1 = { - name: "mario", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/mario/mario_PNG125.png" -}; - -let attachment2 = { - name: "jaguar", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/jaguar/jaguar_PNG20759.png" -}; - -let attachments = []; -attachments.push(new CometChat.Attachment(attachment1)); -attachments.push(new CometChat.Attachment(attachment2)); - -mediaMessage.setAttachments(attachments); - -CometChat.sendMediaMessage(mediaMessage).then( - mediaMessage => { - console.log("message", mediaMessage) - }, error => { - console.log("error in sending message", error) - } -); -``` - - - - -```ts -let receiverID: string = "cometchat-guid-1", - messageType: string = CometChat.MESSAGE_TYPE.IMAGE, - receiverType: string = CometChat.RECEIVER_TYPE.GROUP, - mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage(receiverID, "", messageType, receiverType); - -let attachment1: Object = { - name: "mario", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/mario/mario_PNG125.png" -}; - -let attachment2: Object = { - name: "jaguar", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/jaguar/jaguar_PNG20759.png" -}; - -let attachments: Array = []; -attachments.push(new CometChat.Attachment(attachment1)); -attachments.push(new CometChat.Attachment(attachment2)); - -mediaMessage.setAttachments(attachments); - -CometChat.sendMediaMessage(mediaMessage).then( - (mediaMessage: CometChat.MediaMessage) => { - console.log("message", mediaMessage) - }, (error: CometChat.CometChatException) => { - console.log("error in sending message", error) - } -); -``` - - - - - -When a media message is sent successfully, the response will include a `MediaMessage` object which includes all information related to the sent message. - -You can use the `setMetadata()`, `setCaption()` & `setTags()` methods to add metadata, caption and tags respectively in exactly the same way as it is done while sending a single file or attachment in a Media Message. - -## Custom Message - -*In other words, as a sender, how do I send a custom message like location co-ordinates?* - -CometChat allows you to send custom messages which are neither text nor media messages. - -In order to send a custom message, you need to use the `sendCustomMessage()` method. - -The `sendCustomMessage()` methods takes an object of the `CustomMessage` which can be obtained using the below constructor. - - - -```js -var customMessage = new CometChat.CustomMessage(receiverID, receiverType, customType, customData); -``` - - - - -```ts -let customMessage: CometChat.CustomMessage = new CometChat.CustomMessage(receiverID, receiverType, customType, customData); -``` - - - - - -The above constructor, helps you create a custom message with the message type set to whatever is passed to the constructor and the category set to `custom`. - -The parameters involved are: - -1. `receiverId` - Unique id of the user or group to which the message is to be sent. -2. `receiverType` - Type of the receiver i.e user or group -3. `customType` - custom message type that you need to set -4. `customData` - The data to be passed as the message in the form of a JSONObject. - -You can also use the subType field of the `CustomMessage` class to set a specific type for the custom message. This can be achieved using the `setSubtype()` method. - -### Add Tags - -To add a tag to a message you can use the `setTags()` method of the CustomMessage Class. The `setTags()` method accepts a list of tags. - - - -```js -let tags = ["starredMessage"]; - -customMessage.setTags(tags); -``` - - - - -```ts -let tags: Array = ["starredMessage"]; - -customMessage.setTags(tags); -``` - - - - - -Once the object of `CustomMessage` class is ready you can send the custom message using the `sendCustomMessage()` method. - - - -```js -let receiverID = "UID"; -let customData = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002" -}; -let customType = "location"; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let customMessage = new CometChat.CustomMessage(receiverID, receiverType, customType, customData); - -CometChat.sendCustomMessage(customMessage).then( - message => { - console.log("custom message sent successfully", message); - }, error => { - console.log("custom message sending failed with error", error); - } -); -``` - - - - -```js -let receiverID = "GUID"; -let customData = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002" -}; -let customType = "location"; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; - -let customMessage = new CometChat.CustomMessage(receiverID, receiverType, customType, customData); - -CometChat.sendCustomMessage(customMessage).then( - message => { - console.log("custom message sent successfully", message); - }, error => { - console.log("custom message sending failed with error", error); - } -); -``` - - - - -```ts -let receiverID: string = "UID", - customData: Object = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002" - }, - customType: string = "location", - receiverType: string = CometChat.RECEIVER_TYPE.USER, - customMessage: CometChat.CustomMessage = new CometChat.CustomMessage(receiverID, receiverType, customType, customData); - -CometChat.sendCustomMessage(customMessage).then( - (message: CometChat.CustomMessage) => { - console.log("custom message sent successfully", message); - }, (error: CometChat.CometChatException) => { - console.log("custom message sending failed with error", error); - } -); -``` - - - - -```ts -let receiverID: string = "GUID", - customData: Object = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002" - }, - customType: string = "location", - receiverType: string = CometChat.RECEIVER_TYPE.GROUP, - customMessage: CometChat.CustomMessage = new CometChat.CustomMessage(receiverID, receiverType, customType, customData); - -CometChat.sendCustomMessage(customMessage).then( - (message: CometChat.CustomMessage) => { - console.log("custom message sent successfully", message); - }, (error: CometChat.CometChatException) => { - console.log("custom message sending failed with error", error); - } -); -``` - - - - - -The above sample explains how custom messages can be used to share the location with a user. The same can be achieved for groups. - -On success, you will receive an object of the `CustomMessage` class. diff --git a/sdk/ionic-legacy/3.0/messaging-typing-indicators.mdx b/sdk/ionic-legacy/3.0/messaging-typing-indicators.mdx deleted file mode 100644 index 16480114e..000000000 --- a/sdk/ionic-legacy/3.0/messaging-typing-indicators.mdx +++ /dev/null @@ -1,178 +0,0 @@ ---- -title: "Typing Indicators" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Send a Typing Indicator - -*In other words, as a sender, how do I let the recipient(s) know that I'm typing?* - -### Start Typing - -You can use the `startTyping()` method to inform the receiver that the logged in user has started typing. The receiver will receive this information in the `onTypingStarted()` method of the `MessageListener` class. In order to send the typing indicator, you need to use the `TypingIndicator` class. - - - -```js -let receiverId = "UID"; -let receiverType = CometChat.RECEIVER_TYPE.USER; - -let typingNotification = new CometChat.TypingIndicator(receiverId, receiverType); -CometChat.startTyping(typingNotification); -``` - - - - -```js -let receiverId = "GUID"; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; - -let typingNotification = new CometChat.TypingIndicator(receiverId,receiverType); -CometChat.startTyping(typingNotification); -``` - - - - -```ts -let receiverId: string = "UID"; -let receiverType: string = CometChat.RECEIVER_TYPE.USER; - -let typingNotification: CometChat.TypingIndicator = new CometChat.TypingIndicator(receiverId, receiverType); -CometChat.startTyping(typingNotification); -``` - - - - -```ts -let receiverId: string = "GUID"; -let receiverType: string = CometChat.RECEIVER_TYPE.GROUP; - -let typingNotification: CometChat.TypingIndicator = new CometChat.TypingIndicator(receiverId, receiverType); -CometChat.startTyping(typingNotification); -``` - - - - - -### Stop Typing - -You can use the `endTyping()` method to inform the receiver that the logged in user has stopped typing. The receiver will receive this information in the `onTypingEnded()` method of the `MessageListener` class. In order to send the typing indicator, you need to use the `TypingIndicator` class. - - - -```js -let receiverId = "UID"; -let receiverType = CometChat.RECEIVER_TYPE.USER; - -let typingNotification = new CometChat.TypingIndicator(receiverId, receiverType); -CometChat.endTyping(typingNotification); -``` - - - - -```js -let receiverId = "GUID"; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; - -let typingNotification = new CometChat.TypingIndicator(receiverId, receiverType); -CometChat.endTyping(typingNotification); -``` - - - - -```ts -let receiverId: string = "UID"; -let receiverType: string = CometChat.RECEIVER_TYPE.USER; - -let typingNotification: CometChat.TypingIndicator = new CometChat.TypingIndicator(receiverId, receiverType); -CometChat.endTyping(typingNotification); -``` - - - - -```ts -let receiverId: string = "GUID"; -let receiverType: string = CometChat.RECEIVER_TYPE.GROUP; - -let typingNotification: CometChat.TypingIndicator = new CometChat.TypingIndicator(receiverId, receiverType); -CometChat.endTyping(typingNotification); -``` - - - - - - -**Custom Data** - -You can use the `metadata` field of the `TypingIndicator` class to pass additional data along with the typing indicators. The metadata field is a JSONObject and can be set using the `setMetadata()` method of the `TypingIndicator` class. This data will be received at the receiver end and can be obtained using the `getMetadata()` method. - - - -## Real-time Typing Indicators - -*In other words, as a recipient, how do I know when someone is typing?* - -You will receive the typing indicators in the `onTypingStarted()` and the `onTypingEnded()` method of the registered `MessageListener` class. - - - -```js -let listenerId = "UNIQUE_LITENER_ID"; - -CometChat.addMessageListener( - listenerId, - new CometChat.MessageListener({ - onTypingStarted: typingIndicator => { - console.log("Typing started :", typingIndicator); - }, - onTypingEnded: typingIndicator => { - console.log("Typing ended :", typingIndicator); - } - }) -); -``` - - - - -```ts -let listenerId: string = "UNIQUE_LITENER_ID"; - -CometChat.addMessageListener( - listenerId, - new CometChat.MessageListener({ - onTypingStarted: (typingIndicator: CometChat.TypingIndicator) => { - console.log("Typing started :", typingIndicator); - }, - onTypingEnded: (typingIndicator: CometChat.TypingIndicator) => { - console.log("Typing ended :", typingIndicator); - } - }) -); -``` - - - - - -The `TypingIndicator` class consists of the below parameters: - -| Parameter | Information | -| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **sender** | An object of the `User` class holding all the information. related to the sender of the typing indicator. | -| **receiverId** | Unique Id of the receiver. This can be the Id of the group or the user the typing indicator is sent to. | -| **receiverType** | This parameter indicates if the typing indicator is to be sent to a user or a group. The possible values are: 1. `CometChatConstants.RECEIVER_TYPE_USER` 2. `CometChatConstants.RECEIVER_TYPE_GROUP` | -| **metadata** | A JSONObject to provider additional data. | diff --git a/sdk/ionic-legacy/3.0/messaging.mdx b/sdk/ionic-legacy/3.0/messaging.mdx deleted file mode 100644 index 93d23f05f..000000000 --- a/sdk/ionic-legacy/3.0/messaging.mdx +++ /dev/null @@ -1,16 +0,0 @@ ---- -title: "Messaging" -sidebarTitle: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -Messaging is one of the core features of CometChat. We've thoughtfully created methods to help you send, receive and fetch message history. - -At the minimum, you must add code for [sending messages](/sdk/ionic-legacy/3.0/messaging-send-message) and [receiving messages](/sdk/ionic-legacy/3.0/messaging-receive-messages) - -Once you've implemented that, you can proceed to more advanced features like [typing indicators](/sdk/ionic-legacy/3.0/messaging-typing-indicators) and [delivery & read receipts](/sdk/ionic-legacy/3.0/messaging-receipts). diff --git a/sdk/ionic-legacy/3.0/overview.mdx b/sdk/ionic-legacy/3.0/overview.mdx deleted file mode 100644 index f203d4838..000000000 --- a/sdk/ionic-legacy/3.0/overview.mdx +++ /dev/null @@ -1,337 +0,0 @@ ---- -title: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -This guide demonstrates how to add real-time Ionic chat to a Cordova/Ionic application using CometChat. - -Before you begin, we strongly recommend you read the [Key Concepts](/sdk/ionic-legacy/3.0/key-concepts) guide. - -#### I want to integrate with my app - -1. [Get your application keys](overview#get-your-application-keys) -2. [Add the CometChat dependency](overview#add-the-cometchat-dependency) -3. [Initialize CometChat](overview#initialize-cometchat) -4. [Register and Login your user](overview#register-and-login-your-user) - -### Get your Application Keys - -[Signup for CometChat](https://app.cometchat.com) and then: - -1. Create a new app -2. Head over to the **API & Auth Keys** section and note the **Auth Key**, **App ID** & **Region** - -## Add the CometChat Dependency - -Install the package as NPM module: - - - -```js -npm install @cometchat-pro/cordova-ionic-chat@3.0.12 -``` - - - - - - - -v2.4+ onwards, Voice & Video Calling functionality has been moved to a separate library. In case you plan to use the calling feature, please install the Calling dependency (@cometchat-pro/ionic-calls). - -For capacitor v2 apps, `npm install @cometchat-pro/ionic-calls@2.1.2 --save` - -For capacitor v3 apps, `npm install @cometchat-pro/ionic-calls@2.3.0 --save` - -The calling component requires some additional configuration. Please follow the steps mentioned [here](/sdk/ionic-legacy/3.0/overview#calling-component-configuration). - - - - - -The Calling Component (@cometchat-pro/ionic-calls) is a capacitor plugin so it won't work in a Cordova project. - - - -## Calling Component Configuration - -**Android** - -Goto `./android` folder and open **project-level** build Gradle file and add all repository URLs in the `repositories` block under the `allprojects` section. - - - -```gradle -allprojects { - repositories { - maven { - url "https://dl.cloudsmith.io/public/cometchat/cometchat-pro-android/maven/" - } - } -} -``` - - - - - -You also need to update the minimum SDK version to `24`. You can update the minSDKVersion in the `variables.gradle` file located in the `android` folder. - - - -```gradle -minSdkVersion = 24 -``` - - - - - -For capacitor **v2**, you need to add the Calling Plugin in the Main Activity. The below changes are not required for capacitor **v3** & above. - - - -```java -package io.ionic.starter; - -import android.os.Bundle; - -import com.cometchat.calling.Calling; //Add this line - -import com.getcapacitor.BridgeActivity; -import com.getcapacitor.Plugin; - -import java.util.ArrayList; - -public class MainActivity extends BridgeActivity { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - this.init(savedInstanceState, new ArrayList>() {{ - add(Calling.class); - }}); - } -} -``` - - - - - -**iOS**: - -Please update the minimum target version in the Podfile. Goto **./ios/App** folder and open the Podfile. - - - -``` -// For @cometchat-pro/ionic-calls version below 2.3.0 -platform :ios, '11.0' - -// For @cometchat-pro/ionic-calls version 2.3.0 & above -platform :ios, '12.0' -``` - - - - - -Open the `ios/App` folder and run `pod install` this will create an `App.xcworkspace` open this and run the app. - -## Initialize CometChat - -The `init()` method initialises the settings required for CometChat. The `init()` method takes the below parameters: - -1. appId - Your CometChat App ID -2. appSettings - An object of the AppSettings class can be created using the AppSettingsBuilder class. The region field is mandatory and can be set using the `setRegion()` method. - -The `AppSettings` class allows you to configure two settings: - -* **Region**: The region where you app was created. -* [Presence Subscription](/sdk/ionic-legacy/3.0/user-presence): Represents the subscription type for user presence (real-time online/offline status) -* **autoEstablishSocketConnection(boolean value)**: This property takes a boolean value which when set to `true` informs the SDK to manage the web-socket connection internally. If set to `false` , it informs the SDK that the web-socket connection will be managed manually. The default value for this parameter is true. For more information on this, please check the [Managing Web-Socket connections manually](/sdk/ionic-legacy/3.0/advanced-managing-web-socket-connections-manually) section. The default value for this property is **true.** -* **overrideAdminHost(adminHost: string)**: This method takes the admin URL as input and uses this admin URL instead of the default admin URL. This can be used in case of dedicated deployment of CometChat. -* **overrideClientHost(clientHost: string)**: This method takes the client URL as input and uses this client URL instead of the default client URL. This can be used in case of dedicated deployment of CometChat. - -You need to call `init()` before calling any other method from CometChat. We suggest you call the `init()` method on app startup, preferably in the `index.js` file. - - - -```js -var appID = "APP_ID"; -var region = "REGION"; -var appSetting = new CometChat.AppSettingsBuilder() - .subscribePresenceForAllUsers() - .setRegion(region) - .autoEstablishSocketConnection(true) - .build(); -CometChat.init(appID, appSetting).then( - () => { - console.log("Initialization completed successfully"); - }, - (error) => { - console.log("Initialization failed with error:", error); - } -); -``` - - - - -```ts -let appID: string = "APP_ID", - region: string = "APP_REGION", - appSetting: CometChat.AppSettings = new CometChat.AppSettingsBuilder() - .subscribePresenceForAllUsers() - .setRegion(region) - .autoEstablishSocketConnection(true) - .build(); -CometChat.init(appID, appSetting).then( - (initialized: boolean) => { - console.log("Initialization completed successfully", initialized); - }, - (error: CometChat.CometChatException) => { - console.log("Initialization failed with error:", error); - } -); -``` - - - - - -Make sure you replace the `APP_ID` with your CometChat **App ID** and `REGION` with your **App Region** in the above code. - -## Register and Login your user - -Once initialization is successful, you will need to create a user. To create users on the fly, you can use the `createUser()` method. This method takes a `User` object and the `Auth Key` as input parameters and returns the created `User` object if the request is successful. - - - -```js -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); - } -); -``` - - - - -```ts -let authKey: string = "AUTH_KEY", - UID: string = "user1", - name: string = "Kevin"; - -var user = new CometChat.User(UID); - -user.setName(name); - -CometChat.createUser(user, authKey).then( - (user: CometChat.User) => { - console.log("user created", user); - }, - (error: CometChat.CometChatException) => { - console.log("error", error); - } -); -``` - - - - - -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. - -We recommend you call the CometChat `login()` method once your user logs into your app. The `login()` method needs to be called only once. - - - -```js -var UID = "cometchat-uid-1"; -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 }); - } - ); - } - }, - (error) => { - console.log("Some Error Occured", { error }); - } -); -``` - - - - -```ts -var UID: string = "cometchat-uid-1", - authKey: string = "AUTH_KEY"; - -CometChat.getLoggedinUser().then( - (user: CometChat.User) => { - if (!user) { - CometChat.login(UID, authKey).then( - (user: CometChat.User) => { - console.log("Login Successful:", { user }); - }, - (error: CometChat.CometChatException) => { - console.log("Login failed with exception:", { error }); - } - ); - } - }, - (error: CometChat.CometChatException) => { - console.log("Some Error Occured", { error }); - } -); -``` - - - - - -Make sure you replace the `AUTH_KEY` with your CometChat **Auth Key** in the above code. - - -Sample Users - -We have set-up 5 users for testing having UIDs: `cometchat-uid-1`, `cometchat-uid-2`, `cometchat-uid-3`, `cometchat-uid-4` and `cometchat-uid-5`. - - - -The `login()` method returns the `User` object containing all the information of the logged-in user. - - - -UID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed. - - diff --git a/sdk/ionic-legacy/3.0/rate-limits.mdx b/sdk/ionic-legacy/3.0/rate-limits.mdx deleted file mode 100644 index 2b8a91edb..000000000 --- a/sdk/ionic-legacy/3.0/rate-limits.mdx +++ /dev/null @@ -1,52 +0,0 @@ ---- -title: "Rate Limits" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -### CometChat Pro REST API Rate Limits - - - -The rate limits below are for general applications. Rate limits can be adjusted on a per need basis, depending on your use-case and plan. - - - -1. App Level Rate Limit - request per app per min -2. APIKey Rate Limit - request per APIKey per min -3. User Level Rate Limit - request per login per min - - - -The rate limits will be cumulative> i.e. Suppose the rate limit for core operations is 100/min. Then the customer can either login, join group or leave group etc. for total 100/min. - - - -### - -| `Rate Limiting Groups` | `100` | `1K` | `2500` | `5K` | `10k` | -| ---------------------- | ------- | ------- | ------- | ------- | ------- | -| Standard Operations | 20k req | 20k req | 20k req | 20k req | 20k req | -| Core Operations | 10k req | 10k req | 10k req | 10k req | 10k req | - -## What happens when rate limit is reached ? - -The request isn't processed and a response is sent containing a 429 response code. Along with the response code there will be couple of headers sent which specifies the time in seconds that you must wait before you can try request again. - -`Retry-After: 15` - -`X-Rate-Limit-Reset: 1625143246` - -## Is there any endpoint that returns rate limit of all resources ? - -No, we don't provide a rate-limit endpoint. - -However, we do provide the following response headers that you can use to confirm the app's current rate limit and monitor the number of requests remaining in the current minute: - -`X-Rate-Limit: 700` - -`X-Rate-Limit-Remaining: 699` diff --git a/sdk/ionic-legacy/3.0/resources-all-real-time-listeners.mdx b/sdk/ionic-legacy/3.0/resources-all-real-time-listeners.mdx deleted file mode 100644 index a49b6cb24..000000000 --- a/sdk/ionic-legacy/3.0/resources-all-real-time-listeners.mdx +++ /dev/null @@ -1,400 +0,0 @@ ---- -title: "All Real Time Listeners" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -CometChat provides 4 listeners viz. - -1. [User Listener](/sdk/ionic-legacy/3.0/resources-all-real-time-listeners#user-listener) -2. [Group Listener](/sdk/ionic-legacy/3.0/resources-all-real-time-listeners#group-listener) -3. [Message Listener](/sdk/ionic-legacy/3.0/resources-all-real-time-listeners#message-listener) -4. [Call Listener](/sdk/ionic-legacy/3.0/resources-all-real-time-listeners#call-listener) - -## User Listener - -The `UserListener` class provides you with live events related to users. Below are the callback methods provided by the `UserListener` class. - -| Method | Information | -| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **onUserOnline(User user)** | This method is triggered when a user comes online and is available to chat. The details of the user can be obtained from the user object received as the method parameter. | -| **onUserOffline(User user)** | This method is triggered when a user goes offline. The details of the user can be obtained from the User object received as the parameter. | - -To add the `UserListener`, you need to use the `addUserListener()` method provided by the `CometChat` class. - - - -```js -var listenerID = "UNIQUE_LISTENER_ID"; -CometChat.addUserListener( - listenerID, - new CometChat.UserListener({ - onUserOnline: onlineUser => { - /* when someuser/friend comes online, user will be received here */ - console.log("On User Online:", { onlineUser }); - }, - onUserOffline: offlineUser => { - /* when someuser/friend went offline, user will be received here */ - console.log("On User Offline:", { offlineUser }); - } - }) -); -``` - - - - -```ts -var listenerID: string = "UNIQUE_LISTENER_ID"; -CometChat.addUserListener( - listenerID, - new CometChat.UserListener({ - onUserOnline: (onlineUser: CometChat.User) => { - /* when someuser/friend comes online, user will be received here */ - console.log("On User Online:", { onlineUser }); - }, - onUserOffline: (offlineUser: CometChat.User) => { - /* when someuser/friend went offline, user will be received here */ - console.log("On User Offline:", { offlineUser }); - } - }) -); -``` - - - - - -where `UNIQUE_LISTENER_ID` is the unique identifier for the listener. Please make sure that no two listeners are added with the same listener id as this could lead to unexpected behavior resulting in loss of events. - -Once the `UserListener` is not in use, you need to remove the listener using the `removeUserListener()` method which takes the id of the listener to be removed as the parameter. - - - -```js -CometChat.removeUserListener(UNIQUE_LISTENER_ID) -``` - - - - -```ts -let listenerID: string = "UNIQUE_LISTENER_ID"; -CometChat.removeUserListener(listenerID); -``` - - - - - -## Group Listener - -The `GroupListener` class provides you with all the real-time events related to groups. Below are the callback methods provided by the `GroupListener` class. - -| Method | Information | -| -------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| **onGroupMemberJoined(Action action, User joinedUser, Group joinedGroup)** | This method is triggered when a user joins any group. All the members present in the group will receive this event. | -| **onGroupMemberLeft(Action action, User leftUser, Group leftGroup)** | This method is triggered when a user who was a member of any group leaves the group. All the members of the group receive this event. | -| **onGroupMemberKicked(Action action, User kickedUser, User kickedBy, Group kickedFrom)** | This method is triggered when a user is kicked from a group. All the members including the user receive this event | -| **onGroupMemberBanned(Action action, User bannedUser, User bannedBy, Group bannedFrom)** | This method is triggered when a user is banned from a group. All the members including the user receive this event | -| **onGroupMemberUnbanned(Action action, User unbannedUser, User unbannedBy, Group unbannedFrom)** | This method is triggered when a user is banned from a group. All the members of the group receive this event. | -| **onGroupMemberScopeChanged(Action action, User changedUser, String newScope, String oldScope, Group changedGroup)** | This method is triggered when the scope of any Group Member has been changed. All the members that are a part of that group receive this event | -| **onMemberAddedToGroup(Action action, User userAdded, User addedBy, Group addedTo)** | This method is triggered when a user is added to any group. All the members including the user himself receive this event. | - -To add the `GroupListener`, you need to use the `addGroupListener()` method provided by the `CometChat` class. - - - -```js -CometChat.addGroupListener( - "UNIQUE_LISTENER_ID", - new CometChat.GroupListener({ - onGroupMemberJoined: (message, joinedUser, joinedGroup) => { - console.log("onGroupMemberJoined", { message, joinedUser, joinedGroup }); - }, - onGroupMemberLeft: (message, leftUser, leftGroup) => { - console.log("onGroupMemberLeft", { message, leftUser, leftGroup }); - }, - onGroupMemberKicked: (message, kickedUser, kickedBy, kickedFrom) => { - console.log("onGroupMemberKicked", { message, kickedUser, kickedBy, kickedFrom }); - }, - onGroupMemberBanned: (message, bannedUser, bannedBy, bannedFrom) => { - console.log("onGroupMemberBanned", { message, bannedUser, bannedBy, bannedFrom }); - }, - onGroupMemberUnbanned: (message, unbannedUser, unbannedBy, unbannedFrom) => { - console.log("onGroupMemberUnbanned", { message, unbannedUser, unbannedBy, unbannedFrom }); - }, - onGroupMemberScopeChanged: (message, changedUser, newScope, oldScope, changedGroup) => { - console.log("onGroupMemberScopeChanged", { message, changedUser, newScope, oldScope, changedGroup }); - }, - onMemberAddedToGroup: (message, userAdded, addedby, addedTo) => { - console.log("onMemberAddedToGroup", { message, addedby, userAdded, addedTo }); - }, - }) -); -``` - - - - -```ts -CometChat.addGroupListener( - "UNIQUE_LISTENER_ID", - new CometChat.GroupListener({ - onGroupMemberJoined: (message: CometChat.Action, joinedUser: CometChat.User, joinedGroup: CometChat.Group) => { - console.log("onGroupMemberJoined", { message, joinedUser, joinedGroup }); - }, - onGroupMemberLeft: (message: CometChat.Action, leftUser: CometChat.User, leftGroup: CometChat.Group) => { - console.log("onGroupMemberLeft", { message, leftUser, leftGroup }); - }, - onGroupMemberKicked: (message: CometChat.Action, kickedUser: CometChat.User, kickedBy: CometChat.User, kickedFrom: CometChat.Group) => { - console.log("onGroupMemberKicked", { message, kickedUser, kickedBy, kickedFrom }); - }, - onGroupMemberBanned: (message: CometChat.Action, bannedUser: CometChat.User, bannedBy: CometChat.User, bannedFrom: CometChat.Group) => { - console.log("onGroupMemberBanned", { message, bannedUser, bannedBy, bannedFrom }); - }, - onGroupMemberUnbanned: (message: CometChat.Action, unbannedUser: CometChat.User, unbannedBy: CometChat.User, unbannedFrom: CometChat.Group) => { - console.log("onGroupMemberUnbanned", { message, unbannedUser, unbannedBy, unbannedFrom }); - }, - onGroupMemberScopeChanged: (message: CometChat.Action, changedUser: CometChat.User, newScope: string, oldScope: string, changedGroup: CometChat.Group) => { - console.log("onGroupMemberScopeChanged", { message, changedUser, newScope, oldScope, changedGroup }); - }, - onMemberAddedToGroup: (message: CometChat.Action, userAdded: CometChat.User, addedby: CometChat.User, addedTo: CometChat.Group) => { - console.log("onMemberAddedToGroup", { message, userAdded, addedby, addedTo }); - }, - }) -); -``` - - - - - -where `UNIQUE_LISTENER_ID` is the unique identifier for the listener. Please make sure that no two listeners are added with the same listener id as this could lead to unexpected behavior resulting in loss of events. - -Once the `GroupListener` is not in use, you need to remove the listener using the `removeGroupListener()` method which takes the id of the listener to be removed as the parameter. - - - -```js -CometChat.removeGroupListener(UNIQUE_LISTENER_ID) -``` - - - - -```ts -let listenerID: string = "UNIQUE_LISTENER_ID"; -CometChat.removeGroupListener(listenerID); -``` - - - - - -## Message Listener - -The `MessageListener` class provides you with live events related to messages. Below are the callback methods provided by the `MessageListener` class. - -| Method | Information | -| ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------- | -| **onTextMessageReceived(TextMessage message)** | This event is triggered when a Text Message is received. | -| **onMediaMessageReceived(MediaMessage message)** | This event is triggered when a Media Message is received. | -| **onCustomMessageReceived(CustomMessage message)** | This event is triggered when a Custom Message is received. | -| **onTypingStarted(TypingIndicator typingIndicator)** | This event is triggered when a user starts typing in a user/group conversation | -| **onTypingEnded(TypingIndicator typingIndicator)** | This event is triggered when a user stops typing in a user/group conversation. | -| **onMessagesDelivered(MessageReceipt messageReceipt)** | This event is triggered when a set of messages are marked as delivered for any particular conversation. | -| **onMessagesRead(MessageReceipt messageReceipt)** | This event is triggered when a set of messages are marked as read for any particular conversation. | -| **onMessageEdited(BaseMessage message)** | This method is triggered when a particular message has been edited in a user/group conversation. | -| **onMessageDeleted(BaseMessage message)** | This event is triggered when a particular message is deleted in a user/group conversation. | - -To add the `MessageListener`, you need to use the `addMessageListener()` method provided by the `CometChat` class. - - - -```js -CometChat.addMessageListener( - "UNIQUE_LISTENER_ID", - new CometChat.MessageListener({ - onTextMessageReceived: textMessage => { - console.log("Text message received successfully", textMessage); - }, - onMediaMessageReceived: mediaMessage => { - console.log("Media message received successfully", mediaMessage); - }, - onCustomMessageReceived: customMessage => { - console.log("Custom message received successfully", customMessage); - }, - onMessagesDelivered: messageReceipt => { - console.log("Message Delivered", messageReceipt); - }, - onMessagesRead: messageReceipt => { - console.log("Message Read", messageReceipt); - }, - onTypingStarted: typingIndicator => { - console.log("Typing Started", typingIndicator); - }, - onTypingEnded: typingIndicator => { - console.log("Typing Ended", typingIndicator); - }, - onMessagesDeleted: message => { - console.log("Message Delted", message); - }, - onMessagesEdited: message => { - console.log("Message Edited", message); - } - }) -); -``` - - - - -```ts -CometChat.addMessageListener( - "UNIQUE_LISTENER_ID", - new CometChat.MessageListener({ - onTextMessageReceived: (textMessage: CometChat.TextMessage) => { - console.log("Text message received successfully", textMessage); - }, - onMediaMessageReceived: (mediaMessage: CometChat.MediaMessage) => { - console.log("Media message received successfully", mediaMessage); - }, - onCustomMessageReceived: (customMessage: CometChat.CustomMessage) => { - console.log("Custom message received successfully", customMessage); - }, - onMessagesDelivered: (messageReceipt: CometChat.MessageReceipt) => { - console.log("Message Delivered", messageReceipt); - }, - onMessagesRead: (messageReceipt: CometChat.MessageReceipt) => { - console.log("Message Read", messageReceipt); - }, - onTypingStarted: (typingIndicator: CometChat.TypingIndicator) => { - console.log("Typing Started", typingIndicator); - }, - onTypingEnded: (typingIndicator: CometChat.TypingIndicator) => { - console.log("Typing Ended", typingIndicator); - }, - onMessagesDeleted: (message: CometChat.BaseMessage) => { - console.log("Message Delted", message); - }, - onMessagesEdited: (message: CometChat.BaseMessage) => { - console.log("Message Edited", message); - } - }) -); -``` - - - - - -where `UNIQUE_LISTENER_ID` is the unique identifier for the listener. Please make sure that no two listeners are added with the same listener id as this could lead to unexpected behavior resulting in loss of events. - -Once the `MessageListener` is not in use, you need to remove the listener using the `removeMessageListener()` method which takes the id of the listener to be removed as the parameter. - - - -```js -CometChat.removeMessageListener(UNIQUE_LISTENER_ID); -``` - - - - -```ts -let listenerID: string = "UNIQUE_LISTENER_ID"; -CometChat.removeMessageListener(listenerID); -``` - - - - - -## Call Listener - -The `CallListener` class provides you with live events related to calls. Below are the callback methods provided by the `CallListener` class. - -| Method | Information | -| -------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **onIncomingCallReceived(Call call)** | This event is triggered when the logged-in user receives an incoming call. The details of the call can be obtained from the Call object received as the method parameter. | -| **onOutgoingCallAccepted(Call call)** | This event is triggered when the call initiated by the logged-in user is accepted by the recipient. The details of the call can be obtained from the Call object received as the method parameter. | -| **onOutgoingCallRejected(Call call)** | This event is triggered when the call initiated by the logged-in user is rejected by the recipient. The details of the call can be obtained from the Call object received as the method parameter | -| **onIncomingCallCancelled(Call call)** | This event is triggered when an incoming call is canceled by the initiator of the call. The details of the call can be obtained from the Call object received as the method parameter | - -To add the `CallListener`, you need to use the `addCallListener()` method provided by the `CometChat` class. - - - -```js -CometChat.addCallListener( - "UNIQUE_LISTENER_ID", - new CometChat.CallListener({ - onIncomingCallReceived(call) { - console.log("Incoming call:", call); - }, - onOutgoingCallAccepted(call) { - console.log("Outgoing call accepted:", call); - }, - onOutgoingCallRejected(call) { - console.log("Outgoing call rejected:", call); - }, - onIncomingCallCancelled(call) { - console.log("Incoming call calcelled:", call); - } - }) -); -``` - - - - -```ts -CometChat.addCallListener( - "UNIQUE_LISTENER_ID", - new CometChat.CallListener({ - onIncomingCallReceived: (call: CometChat.Call) => { - console.log("Incoming call:", call); - }, - onOutgoingCallAccepted: (call: CometChat.Call) => { - console.log("Outgoing call accepted:", call); - }, - onOutgoingCallRejected: (call: CometChat.Call) => { - console.log("Outgoing call rejected:", call); - }, - onIncomingCallCancelled: (call: CometChat.Call) => { - console.log("Incoming call calcelled:", call); - } - }) -); -``` - - - - - -where `UNIQUE_LISTENER_ID` is the unique identifier for the listener. Please make sure that no two listeners are added with the same listener id as this could lead to unexpected behavior resulting in loss of events. - -Once the `CallListener` is not in use, you need to remove the listener using the `removeCallListener()` method which takes the id of the listener to be removed as the parameter. - - - -```js -CometChat.removeCallListener(UNIQUE_LISTENER_ID); -``` - - - - -```ts -let listenerID: string = "UNIQUE_LISTENER_ID"; -CometChat.removeCallListener(listenerID); -``` - - - - diff --git a/sdk/ionic-legacy/3.0/resources-upgrading-from-v2.mdx b/sdk/ionic-legacy/3.0/resources-upgrading-from-v2.mdx deleted file mode 100644 index b8d1dc5eb..000000000 --- a/sdk/ionic-legacy/3.0/resources-upgrading-from-v2.mdx +++ /dev/null @@ -1,78 +0,0 @@ ---- -title: "Upgrading From V2" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -Upgrading from v2.x to v3 is fairly simple. Below are the major changes that are released as a part of CometChat Pro v3: - -Please follow the [setup](/sdk/ionic-legacy/3.0/setup) instructions to upgrade to the latest V3 version. - - - -v3 apps are compatible only with v3.x SDKs and will not function with v2.x SDKs. In case you want to migrate an existing v2 app to v3, you can achieve this from the [CometChat Dashboard](https://app.cometchat.com/). - - - -## Delivery Receipts - -In v2.x, the messages were being marked as delivered internally by the SDKs. Starting v3, we have stopped marking the messages as delivered internally and it will have to be managed via the SDK. - -You can read more about the `markAsDelivered()` method [here](/sdk/ionic-legacy/3.0/messaging-receipts#mark-messages-as-delivered). - -## Read Receipts - -Starting v3.0, the method signature has been changed. Now the `markAsRead()` takes 4 parameters: `messageId`,`receiverId`, `receiverType` & `senderId` as input. This method will mark all the messages before the provided messageId for the conversation with the specified `receiverId` as read. Also, we have added one more signature of `markAsRead()` which takes only 1 parameter: `message` Object as input. - -You can read more about the `markAsRead()` method [here](/sdk/ionic-legacy/3.0/messaging-receipts#mark-messages-as-read). - - - -```js -//v2.x - -CometChat.markAsRead(messageId, receiverId, receiverType); - -//v3.x - -CometChat.markAsRead(messageId, receiverId, receiverType, senderId); -// OR -CometChat.markAsRead(message); -``` - - - - - -## User/Group Tags in Conversation - -In v2.x, the user/group tags were by default fetched in a `Conversation` Object while fetching the `Conversation List`. - -Starting v3, we have added a method (`withUserAndGroupTags()`) to fetch the user/group tags in a `Conversation` Object while fetching the `Conversation List`. - - - -```js -let conversationRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(50) - .withUserAndGroupTags(true) - .build(); -``` - - - - -```ts -let conversationRequest: CometChat.ConversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(50) - .withUserAndGroupTags(true) - .build(); -``` - - - - diff --git a/sdk/ionic-legacy/3.0/resources.mdx b/sdk/ionic-legacy/3.0/resources.mdx deleted file mode 100644 index 9e266702a..000000000 --- a/sdk/ionic-legacy/3.0/resources.mdx +++ /dev/null @@ -1,16 +0,0 @@ ---- -title: "Resources" -sidebarTitle: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -We have a number of resources that will help you while integrating CometChat in your app. - -You can begin with the [all real-time listeners](/sdk/ionic-legacy/3.0/resources-all-real-time-listeners) guide. - -If you're upgrading from v2, we recommend reading our [upgrading from v2](/sdk/ionic-legacy/3.0/resources-upgrading-from-v2) guide. diff --git a/sdk/ionic-legacy/3.0/setup.mdx b/sdk/ionic-legacy/3.0/setup.mdx deleted file mode 100644 index 749785a73..000000000 --- a/sdk/ionic-legacy/3.0/setup.mdx +++ /dev/null @@ -1,211 +0,0 @@ ---- -title: "Setup" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - - -Migrating app version from v2 to v3 ? - -Skip the create new app step. Your existing v2 app can be migrated to v3.> Follow steps mentioned in **Add the CometChat dependency** section below to upgrade to latest version of v3 - - - -## Get your Application Keys - -[Signup for CometChat](https://app.cometchat.com) and then: - -1. Create a new app -2. Head over to the **API & Auth Keys** section and note the **Auth Key**, **App ID** & **Region** - -## Add the CometChat Dependency - -Install the package as NPM module: - - - -``` -npm install @cometchat-pro/cordova-ionic-chat@3.0.12 -``` - - - - - - - -v2.4+ onwards, Voice & Video Calling functionality has been moved to a separate library. In case you plan to use the calling feature, please install the Calling dependency (@cometchat-pro/ionic-calls). - -For Capacitor v2 apps, `npm install @cometchat-pro/ionic-calls@2.1.2 --save` - -For capacitor v3 apps, `npm install @cometchat-pro/ionic-calls@2.3.0--save` - -The calling component requires some additional configuration. Please follow the steps mentioned [here](/sdk/ionic-legacy/3.0/setup#calling-component-configuration). - - - - - -The Calling Component (@cometchat-pro/ionic-calls) is a capacitor plugin so it won't work in a Cordova project. - - - -## Calling Component Configuration - -**Android** - -Goto `./android` folder and open **project-level** build Gradle file and add all repository URLs in the `repositories` block under the `allprojects` section. - - - -```gradle -allprojects { - repositories { - maven { - url "https://dl.cloudsmith.io/public/cometchat/cometchat-pro-android/maven/" - } - } -} -``` - - - - - -You also need to update the minimum SDK version to `24`. You can update the minSDKVersion in the `variables.gradle` file located in the `android` folder. - - - -```gradle -minSdkVersion = 24 -``` - - - - - -In the Main activity you need to map Capacitor class add(Calling.class); - -**Note**: Only for capacitor v2 plugin (`@cometchat-pro/ionic-calls: 2.1.2` ) - - - -```java -package io.ionic.starter; - -import android.os.Bundle; - -import com.cometchat.calling.Calling; //Add this line - -import com.getcapacitor.BridgeActivity; -import com.getcapacitor.Plugin; - -import java.util.ArrayList; - -public class MainActivity extends BridgeActivity { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - this.init(savedInstanceState, new ArrayList>() {{ - add(Calling.class); - }}); - } -} -``` - - - - - -**iOS**: - -Please update the minimum target version in the Podfile. Goto **./ios/App** folder and open the Podfile. - - - -``` -// For @cometchat-pro/ionic-calls version below 2.3.0 -platform :ios, '11.0' - -// For @cometchat-pro/ionic-calls version 2.3.0 & above -platform :ios, '12.0' -``` - - - - - -Open the `ios/App` folder and run `pod install` this will create an `App.xcworkspace` open this and run the app. - -## Initialize CometChat - -The `init()` method initialises the settings required for CometChat. The `init()` method takes the below parameters: - -1. appId - Your CometChat App ID -2. appSettings - An object of the AppSettings class can be created using the AppSettingsBuilder class. The region field is mandatory and can be set using the `setRegion()` method. - -The `AppSettings` class allows you to configure two settings: - -* **Region**: The region where you app was created. -* [Presence Subscription](/sdk/ionic-legacy/3.0/user-presence): Represents the subscription type for user presence (real-time online/offline status) -* **autoEstablishSocketConnection(boolean value)**: This property takes a boolean value which when set to true informs the SDK to manage the web-socket connection internally. If set to false, it informs the SDK that the web-socket connection will be managed manually. The default value for this parameter is true. For more information on this, please check the [Managing Web-Socket connections manually](/sdk/ionic-legacy/3.0/advanced-managing-web-socket-connections-manually) section. The default value for this property is **true.** -* **overrideAdminHost(adminHost: string)**: This method takes the admin URL as input and uses this admin URL instead of the default admin URL. This can be used in case of dedicated deployment of CometChat. -* **overrideClientHost(clientHost: string)**: This method takes the client URL as input and uses this client URL instead of the default client URL. This can be used in case of dedicated deployment of CometChat. - -You need to call `init()` before calling any other method from CometChat. We suggest you call the `init()` method on app startup, preferably in the `index.js` file. - - - -```js -let appID = "APP_ID"; -let region = "REGION"; -let cometChatSettings = new CometChat.AppSettingsBuilder() - .subscribePresenceForAllUsers() - .setRegion(region) - .autoEstablishSocketConnection(true) - .build(); -CometChat.init(appID, cometChatSettings).then( - () => { - console.log("Initialization completed successfully"); - }, - (error) => { - console.log("Initialization failed with error:", error); - } -); -``` - - - - -```ts -let appID: string = "APP_ID", - region: string = "APP_REGION", - appSetting: CometChat.AppSettings = new CometChat.AppSettingsBuilder() - .subscribePresenceForAllUsers() - .setRegion(region) - .autoEstablishSocketConnection(true) - .build(); -CometChat.init(appID, appSetting).then( - (initialized: boolean) => { - console.log("Initialization completed successfully", initialized); - }, - (error: CometChat.CometChatException) => { - console.log("Initialization failed with error:", error); - } -); -``` - - - - - -Make sure you replace the `APP_ID` with your CometChat **App ID** and `REGION` with your **App Region** in the above code. - -| Parameter | Description | -| ---------- | ----------------------------------- | -| appID | CometChat App ID | -| appSetting | An object of the AppSettings class. | diff --git a/sdk/ionic-legacy/3.0/threaded-messages.mdx b/sdk/ionic-legacy/3.0/threaded-messages.mdx deleted file mode 100644 index 003e595d4..000000000 --- a/sdk/ionic-legacy/3.0/threaded-messages.mdx +++ /dev/null @@ -1,276 +0,0 @@ ---- -title: "Threaded Messages" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -Messages that are started from a particular message are called Threaded messages or simply threads. Each Thread is attached to a message which is the Parent message for that thread. - -## Send Message in a Thread - -As mentioned in the [Send a Message](/sdk/ionic-legacy/3.0/messaging-send-message) section. You can either send a message to a User or a Group based on the `receiverType` and the UID/GUID specified for the message. A message can belong to either of the below types: - -1. Text Message -2. Media Message -3. Custom Message. - -Any of the above messages can be sent in a thread. As mentioned, a thread is identified based on the Parent message. So while sending a message the `parentMessageId` must be set for the message to indicate that the message to be sent needs to be a part of the thread with the specified `parentMessageId`. - -This can be achieved using the `setParentMessageId()` method provided by the object of the `TextMessage`, `MediaMessage` and `CustomMessage` class. The id specified in the `setParentMessageId()` method maps the message sent to the particular thread. - -**Example to Send a Text Message in a thread in a user conversation.** - - - -```js -let textMessage = new CometChat.TextMessage(UID, "Hello", CometChat.RECEIVER_TYPE.USER); -textMessage.setParentMessageId(100); - -CometChat.sendMessage(textMessage).then( - message => { - console.log('Message sent successfully', message); - }, err => { - console.log('err', err); - } -) -``` - - - - -```ts -let receiverId = "UID", - receiverType: string = CometChat.RECEIVER_TYPE.USER, - textMessage: CometChat.TextMessage = new CometChat.TextMessage(receiverId, "Hello", receiverType), - messageId: number = 100; - -textMessage.setParentMessageId(messageId); - -CometChat.sendMessage(textMessage).then( - (message: CometChat.TextMessage) => { - console.log('Message sent successfully', message); - }, (error: CometChat.CometChatException) => { - console.log('Message sending failed', error); - } -); -``` - - - - - -The above snippet shows how a message with the text "Hello" can be sent in the thread with `parentMessageId` 100. - -Similarly, using the `setparentMessageId()` method, Media and Custom Messages can be sent in threads too. - -### Receiving Real-Time Messages - -The procedure to receive real-time messages is exactly the same as mentioned in the [Receive Messages](/sdk/ionic-legacy/3.0/messaging-receive-messages). This can be achieved using the `MessageListener` class provided by the SDK. - -To add a MessageListener, you can use the `addMessageListener()` method of the SDK. The only thing that needs to be checked is if the received message belongs to the active thread. This can be done using the `parentMessageId` field of the message object. - - - -```js -var listenerID = "UNIQUE_LISTENER_ID"; -var activeThreadId = 100; - -CometChat.addMessageListener( - listenerID, - new CometChat.MessageListener({ - onTextMessageReceived: textMessage => { - if(textMessage.getParentMessageId() == activeThreadId) { - console.log("Text message received for active thread.", textMessage); - } - }, - onMediaMessageReceived: mediaMessage => { - if(mediaMessage.getParentMessageId() == activeThreadId) { - console.log("Media message received for active thread.", textMessage); - } - }, - onCustomMessageReceived: customMessage => { - if(customMessage.getParentMessageId() == activeThreadId) { - console.log("Custom message received for active thread.", textMessage); - } - } - }) -); -``` - - - - -```ts -var listenerID: string = "UNIQUE_LISTENER_ID", - activeThreadId: number = 100; - -CometChat.addMessageListener( - listenerID, - new CometChat.MessageListener({ - onTextMessageReceived: (textMessage: CometChat.TextMessage) => { - if (textMessage.getParentMessageId() == activeThreadId) { - console.log("Text message received for active thread.", textMessage); - } - }, - onMediaMessageReceived: (mediaMessage: CometChat.MediaMessage) => { - if (mediaMessage.getParentMessageId() == activeThreadId) { - console.log("Media message received for active thread.", mediaMessage); - } - }, - onCustomMessageReceived: (customMessage: CometChat.CustomMessage) => { - if (customMessage.getParentMessageId() == activeThreadId) { - console.log("Custom message received for active thread.", customMessage); - } - } - }) -); -``` - - - - - -### Fetch all the messages for any particular thread. - -You can fetch all the messages belonging to a particular thread by using the `MessagesRequest` class. In order to get an object of the `MessagesRequest` class, you need to use the `MessagesRequestBuilder` class. and use the `setParentMessageId()` method of the `MessagesRequestBuilder` to inform the SDK that you only need the messages belonging to the thread with the specified parentMessageId. - -Once you have the object of the `MessagesRequest` class, you need to call the `fetchPrevious()` method to get the latest messages in the thread. In one integration, a maximum of 100 messages can be fetched. If you wish to fetch the next set of messages, you need to call the `fetchPrevious()` method again on the same object. - - - -```js -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setLimit(30) - .setParentMessageId(100) - .build(); - -messagesRequest.fetchPrevious().then( - messages => { - console.log("Messages for thread fetched successfully", messages); - }, - error => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```ts -let limit: number = 30, - parentMessageId: number = 1, - messagesRequest: CometChat.MessagesRequest = new CometChat.MessagesRequestBuilder() - .setLimit(limit) - .setParentMessageId(parentMessageId) - .build(); - -messagesRequest.fetchPrevious().then( - (messages: CometChat.BaseMessage[]) => { - console.log("Messages for thread fetched successfully", messages); - }, (error: CometChat.CometChatException) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -## Avoid Threaded Messages in User/Group Conversations - -While fetching messages for normal user/group conversations using the `MessagesRequest`, the threaded messages by default will be a part of the list of messages received. In order to exclude the threaded messages from the list of user/group messages, you need to use the `hideReplies()` method of the `MessagesRequestBuilder` class. This method takes a boolean argument which when set to true excludes the messages belonging to threads from the list of messages. - - - -```js -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .hideReplies(true) - .build(); - -messagesRequest.fetchPrevious().then( - messages => { - console.log("Messages for thread fetched successfully", messages); - }, error => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```js -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hideReplies(true) - .build(); - -messagesRequest.fetchPrevious().then( - messages => { - console.log("Messages for thread fetched successfully", messages); - }, error => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```ts -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .hideReplies(true) - .build(); - -messagesRequest.fetchPrevious().then( - (messages: CometChat.BaseMessage[]) => { - console.log("Messages fetched successfully", messages); - }, (error: CometChat.CometChatException) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```ts -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hideReplies(true) - .build(); - -messagesRequest.fetchPrevious().then( - (messages: CometChat.BaseMessage[]) => { - console.log("Messages fetched successfully", messages); - }, (error: CometChat.CometChatException) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -The above snippet will return messages between the logged in user and `cometchat-uid-1` excluding all the threaded messages belonging to the same conversation. diff --git a/sdk/ionic-legacy/3.0/transient-messages.mdx b/sdk/ionic-legacy/3.0/transient-messages.mdx deleted file mode 100644 index 0957aa42e..000000000 --- a/sdk/ionic-legacy/3.0/transient-messages.mdx +++ /dev/null @@ -1,116 +0,0 @@ ---- -title: "Transient Messages" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -Transient messages are messages that are sent in real-time only and are not saved or tracked anywhere. The receiver of the message will only receive the message if he is online and these messages cannot be retrieved later. - -## Send a Transient Message - -You can use the `sendTransientMessage()` method to send a transient message to a user or in a group. The receiver will receive this information in the `onTransientMessageReceived()` method of the `MessageListener` class. In order to send the transient message, you need to use the `TransientMessage` class. - - - -```js -let receiverId = "UID"; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let data = { "LIVE_REACTION": "heart" }; - -let transientMessage = new CometChat.TransientMessage(receiverId, receiverType, data); -CometChat.sendTransientMessage(transientMessage); -``` - - - - -```js -let receiverId = "GUID"; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; -let data = { "LIVE_REACTION": "heart" }; - -let transientMessage = new CometChat.TransientMessage(receiverId, receiverType, data); -CometChat.sendTransientMessage(transientMessage); -``` - - - - -```ts -let receiverId: string = "UID"; -let receiverType: string = CometChat.RECEIVER_TYPE.USER; -let data: Object = { "LIVE_REACTION": "heart" }; - -let transientMessage: CometChat.TransientMessage = new CometChat.TransientMessage(receiverId, receiverType, data); -CometChat.sendTransientMessage(transientMessage); -``` - - - - -```ts -let receiverId: string = "GUID"; -let receiverType: string = CometChat.RECEIVER_TYPE.GROUP; -let data: Object = { "LIVE_REACTION": "heart" }; - -let transientMessage: CometChat.TransientMessage = new CometChat.TransientMessage(receiverId, receiverType, data); -CometChat.sendTransientMessage(transientMessage); -``` - - - - - -## Real-time Transient Messages - -*In other words, as a recipient, how do I know when someone sends a transient message?* - -You will receive the transient message in the `onTransientMessageReceived()` method of the registered `MessageListener` class. - - - -```js -let listenerId = "UNIQUE_LITENER_ID"; - -CometChat.addMessageListener( - listenerId, - new CometChat.MessageListener({ - onTransientMessageReceived: transientMessage => { - console.log('transient message received', transientMessage); - }, - }) -); -``` - - - - -```ts -let listenerId: string = "UNIQUE_LITENER_ID"; - -CometChat.addMessageListener( - listenerId, - new CometChat.MessageListener({ - onTransientMessageReceived: (transientMessage: CometChat.TransientMessage) => { - console.log('transient message received', transientMessage); - }, - }) -); -``` - - - - - -The `TransientMessage` class consists of the below parameters: - -| Parameter | Information | -| ---------------- | -------------------------------------------------------------------------------------------------------- | -| **sender** | An object of the User class holding all the information. related to the sender of the transient message. | -| **receiverId** | Unique Id of the receiver. This can be the Id of the group or the user the transient message is sent to. | -| **receiverType** | The type of the receiver - `CometChat.RECEIVER_TYPE.USER` or `CometChat.RECEIVER_TYPE.GROUP` | -| **data** | A JSONObject to provide data. | diff --git a/sdk/ionic-legacy/3.0/user-presence.mdx b/sdk/ionic-legacy/3.0/user-presence.mdx deleted file mode 100644 index 63f41e224..000000000 --- a/sdk/ionic-legacy/3.0/user-presence.mdx +++ /dev/null @@ -1,110 +0,0 @@ ---- -title: "User Presence" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -User Presence helps us understand if a user is available to chat or not. - -## Real-time Presence - -*In other words, as a logged-in user, how do I know if a user is online or offline?* - -Based on the settings provided in the AppSettings class while initializing the SDK using the `init()` method, the logged-in user will receive the presence for the other users in the app. - -In the `AppSettings` class, you can set the type of Presence you wish to receive for that particular session of the app. - -For presence subscription, the AppSettingsBuilder provides 3 methods : - -* `subscribePresenceForAllUsers()` - This will inform the logged-in user when any user in the app comes online or goes offline. -* `subscribePresenceForRoles(Array roles)` - This will inform the logged-in user, only when the users with the specified roles come online or go offline. -* `subscribePresenceForFriends()` - This will inform the logged-in user, only when either of his friends come online or go offline. - -If none of the above methods are used, no presence will be sent to the logged-in user. - -You need to register the `UserListener` using the `addUserListener()` method where ever you wish to receive these events in. - - - -```js -let listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.addUserListener( - listenerID, - new CometChat.UserListener({ - onUserOnline: onlineUser => { - console.log("On User Online:", { onlineUser }); - }, - onUserOffline: offlineUser => { - console.log("On User Offline:", { offlineUser }); - } - }) -); -``` - - - - -```ts -let listenerID: string = "UNIQUE_LISTENER_ID"; - -CometChat.addUserListener( - listenerID, - new CometChat.UserListener({ - onUserOnline: (onlineUser: CometChat.User) => { - console.log("On User Online:", { onlineUser }); - }, - onUserOffline: (offlineUser: CometChat.User) => { - console.log("On User Offline:", { offlineUser }); - } - }) -); -``` - - - - - -| Parameter | Description | -| ------------ | --------------------------------------------- | -| `listenerID` | An ID that uniquely identifies that listener. | - -You will receive an object of the `User` class in the listener methods. - -We recommend you remove the listener once the activity or view is not in use. We suggest adding this method when not in use. - - - -```js -let listenerID = "UNIQUE_LISTENER_ID"; -CometChat.removeUserListener(listenerID); -``` - - - - -```ts -let listenerID: string = "UNIQUE_LISTENER_ID"; -CometChat.removeUserListener(listenerID); -``` - - - - - -## User List Presence - -*In other words, as a logged-in user, when I retrieve the user list, how do I know if a user is online/offline?* - -When you fetch the list of users, in the [User](/sdk/ionic-legacy/3.0/users-user-management#user-class) object, you will receive 2 fields - -1. `status` - This will hold either of the two values : - -* online - This indicates that the user is currently online and available to chat. -* offline - This indicates that the user is currently offline and is not available to chat. - -2. `lastActiveAt` - in case the user is offline, this field holds the timestamp of the time when the user was last online. This can be used to display the Last seen of the user if need be. diff --git a/sdk/ionic-legacy/3.0/users-block-users.mdx b/sdk/ionic-legacy/3.0/users-block-users.mdx deleted file mode 100644 index 928783103..000000000 --- a/sdk/ionic-legacy/3.0/users-block-users.mdx +++ /dev/null @@ -1,229 +0,0 @@ ---- -title: "Block Users" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Block Users - -*In other words, as a logged-in user, how do I block a user from sending me messages?* - -You can block users using the `blockUsers()` method. Once any user is blocked, all the communication to and from the respective user will be completely blocked. You can block multiple users in a single operation. The `blockUsers()` method takes a `Array` as a parameter which holds the list of `UID's` to be blocked. - - - -```js -var usersList = ["UID1", "UID2", "UID3"]; -CometChat.blockUsers(usersList).then( - list => { - console.log("users list blocked", { list }); - }, error => { - console.log("Blocking user fails with error", error); - } -); -``` - - - - -```ts -var usersList: String[] = ["UID1", "UID2", "UID3"]; - -CometChat.blockUsers(usersList).then( - (list: Object) => { - console.log("users list blocked", { list }); - }, (error: CometChat.CometChatException) => { - console.log("Blocking user fails with error", error); - } -); -``` - - - - - -It returns a Array which contains `UID's` as the keys and "success" or "fail" as the value based on if the block operation for the `UID` was successful or not. - -## Unblock Users - -*In other words, as a logged-in user, how do I unblock a user I previously blocked?* - -You can unblock the already blocked users using the `unblockUsers()` method. You can unblock multiple users in a single operation. The `unblockUsers()` method takes a `Array` as a parameter which holds the list of `UID's` to be unblocked. - - - -```js -var usersList = ["UID1", "UID2", "UID3"]; - -CometChat.unblockUsers(usersList).then( - list => { - console.log("users list unblocked", { list }); - }, error => { - console.log("unblocking user fails with error", error); - } -); -``` - - - - -```ts -var usersList: String[] = ["UID1", "UID2", "UID3"]; - -CometChat.unblockUsers(usersList).then( - (list: Object) => { - console.log("users list blocked", { list }); - }, (error: CometChat.CometChatException) => { - console.log("Blocking user fails with error", error); - } -); -``` - - - - - -It returns a Array which contains `UID's` as the keys and `success` or `fail` as the value based on if the unblock operation for the `UID` was successful or not. - -## Get List of Blocked Users - -*In other words, as a logged-in user, how do I get a list of all users I've blocked?* - -In order to fetch the list of blocked users, you can use the `BlockedUsersRequest` class. To use this class i.e to create an object of the `BlockedUsersRequest class`, you need to use the `BlockedUsersRequestBuilder` class. The `BlockedUsersRequestBuilder` class allows you to set the parameters based on which the blocked users are to be fetched. - -The `BlockedUsersRequestBuilder` class allows you to set the below parameters: - -### Set Limit - -This method sets the limit i.e. the number of blocked users that should be fetched in a single iteration. - - - -```js -let limit = 30; -let blockedUsersRequest = new BlockedUsersRequest.BlockedUsersRequestBuilder() - .setLimit(limit) - .build(); -``` - - - - -```ts -let limit: number = 30; -let blockedUsersRequest: CometChat.BlockedUsersRequest = new CometChat.BlockedUsersRequestBuilder() - .setLimit(limit) - .build(); -``` - - - - - -### Set Search Keyword - -This method allows you to set the search string based on which the blocked users are to be fetched. - - - -```js -let limit = 30; -let searchKeyword = "super"; -let blockedUsersRequest = new BlockedUsersRequest.BlockedUsersRequestBuilder() - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - -```ts -let limit: number = 30; -let searchKeyword: string = "super"; -let blockedUsersRequest: CometChat.BlockedUsersRequest = new CometChat.BlockedUsersRequestBuilder() - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - - -### Set Direction - -* CometChat.BlockedUsersRequest.directions.BLOCKED\_BY\_ME - This will ensure that the list of blocked users only contains the users blocked by the logged in user. -* CometChat.BlockedUsersRequest.directions.HAS\_BLOCKED\_ME - This will ensure that the list of blocked users only contains the users that have blocked the logged in user. -* CometChat.BlockedUsersRequest.directions.BOTH - This will make sure the list of users includes both the above cases. This is the default value for the direction variable if it is not set. - - - -```js -let limit = 30; -let blockedUsersRequest = new BlockedUsersRequest.BlockedUsersRequestBuilder() - .setLimit(limit) - .setDirection(CometChat.BlockedUsersRequest.directions.BLOCKED_BY_ME) - .build(); -``` - - - - -```ts -let limit: number = 30; -let blockedUsersRequest: CometChat.BlockedUsersRequest = new CometChat.BlockedUsersRequestBuilder() - .setLimit(limit) - .setDirection(CometChat.BlockedUsersRequest.directions.BLOCKED_BY_ME) - .build(); -``` - - - - - -Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the `BlockedUsersRequest` class. - -Once you have the object of the `BlockedUsersRequest` class, you need to call the `fetchNext()` method. Calling this method will return a list of `User` objects containing n number of blocked users where N is the limit set in the builder class. - - - -```js -var limit = 30; -var blockedUsersRequest = new CometChat.BlockedUsersRequestBuilder() - .setLimit(limit) - .build(); -blockedUsersRequest.fetchNext().then( - userList => { - console.log("Blocked user list received:", userList); - }, error => { - console.log("Blocked user list fetching failed with error:", error); - } -); -``` - - - - -```ts -let limit: number = 30; -let blockedUsersRequest: CometChat.BlockedUsersRequest = new CometChat.BlockedUsersRequestBuilder() - .setLimit(limit) - .build(); - -blockedUsersRequest.fetchNext().then( - (userList: CometChat.User[]) => { - console.log("Blocked user list received:", userList); - }, (error: CometChat.CometChatException) => { - console.log("Blocked user list fetching failed with error:", error); - } -); -``` - - - - diff --git a/sdk/ionic-legacy/3.0/users-retrieve-users.mdx b/sdk/ionic-legacy/3.0/users-retrieve-users.mdx deleted file mode 100644 index fee905d82..000000000 --- a/sdk/ionic-legacy/3.0/users-retrieve-users.mdx +++ /dev/null @@ -1,541 +0,0 @@ ---- -title: "Retrieve Users" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Retrieve Logged In User Details - -You can get the details of the logged-in user using the `getLoggedInUser()` method. This method can also be used to check if the user is logged in or not. If the method returns `Promise` with reject callback, it indicates that the user is not logged in and you need to log the user into CometChat SDK. - - - -```js -var user = CometChat.getLoggedinUser().then( - user => { - console.log("user details:", { user }); - }, error => { - console.log("error getting details:", { error }); - } -); -``` - - - - -```ts -CometChat.getLoggedinUser().then( - (user: CometChat.User) => { - console.log("user details:", { user }); - }, (error: CometChat.CometChatException) => { - console.log("error getting details:", { error }); - } -); -``` - - - - - -This method will return a `User` object containing all the information related to the logged-in user. - -## Retrieve List of Users - -In order to fetch the list of users, you can use the `UsersRequest` class. To use this class i.e to create an object of the `UsersRequest` class, you need to use the `UsersRequestBuilder` class. The `UsersRequestBuilder` class allows you to set the parameters based on which the users are to be fetched. - -The `UsersRequestBuilder` class allows you to set the below parameters: - -### Set Limit - -This method sets the limit i.e. the number of users that should be fetched in a single iteration. - - - -```js -let limit = 30; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .build(); -``` - - - - -```ts -let limit: number = 30; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .build(); -``` - - - - - -### Set Search Keyword - -This method allows you to set the search string based on which the users are to be fetched. - - - -```js -let limit = 30; -let searchKeyword = "super"; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - -```ts -let limit: number = 30; -let searchKeyword: string = "super"; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - - -### Search In - -This method allows you to define in which user property should the searchKeyword be searched. This method only works in combination with `setSearchKeyword()`. By default the keyword is searched in both UID & Name. - - - -```js -let limit = 30; -let searchKeyword = "super"; -let searchIn = ["uid", "name"]; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .searchIn(searchIn) - .build(); -``` - - - - -```ts -let limit: number = 30; -let searchKeyword: string = "super"; -let searchIn: Array = ["uid", "name"]; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .searchIn(searchIn) - .build(); -``` - - - - - -### Set Status - -The status based on which the users are to be fetched. The status parameter can contain one of the below two values: - -* CometChat.USER\_STATUS.ONLINE - will return the list of only online users. -* CometChat.USER\_STATUS.OFFLINE - will return the list of only offline users. - -If this parameter is not set, will return all the available users. - - - -```js -let limit = 30; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setStatus(CometChat.USER_STATUS.ONLINE) - .build() -``` - - - - -```ts -let limit: number = 30; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setStatus(CometChat.USER_STATUS.ONLINE) - .build(); -``` - - - - - -### Hide Blocked Users - -This method is used to determine if the blocked users should be returned as a part of the user list. If set to true, the user list will not contain the users blocked by the logged in user. - - - -```js -let limit = 30; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .hideBlockedUsers(true) - .build(); -``` - - - - -```ts -let limit: number = 30; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .hideBlockedUsers(true) - .build(); -``` - - - - - -### Set Roles - -This method allows you to fetch the users based on multiple roles. - - - -```js -let limit = 30; -let roles = ["default", "dev"]; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setRoles(roles) - .build(); -``` - - - - -```ts -let limit: number = 30; -let roles: Array = ["default", "dev"]; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setRoles(roles) - .build(); -``` - - - - - -### Friends Only - -This property when set to true will return only the friends of the logged-in user. - - - -```js -let limit = 30; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .friendsOnly(true) - .build(); -``` - - - - -```ts -let limit: number = 30; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .friendsOnly(true) - .build(); -``` - - - - - -### Set Tags - -This method accepts a list of tags based on which the list of users is to be fetched. The list fetched will only contain the users that have been tagged with the specified tags. - - - -```js -let limit = 30; -let tags = ["tag1", "tag2"]; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setTags(tags) - .build(); -``` - - - - -```ts -let limit: number = 30; -let tags: Array = ["tag1", "tag2"]; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setTags(tags) - .build(); -``` - - - - - -### With Tags - -This property when set to true will fetch tags data along with the list of users. - - - -```js -let limit = 30; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .withTags(true) - .build(); -``` - - - - -```ts -let limit: number = 30; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .withTags(true) - .build(); -``` - - - - - -### Set UIDs - -This method accepts a list of UIDs based on which the list of users is fetched. A maximum of `25` users can be fetched. - - - -```js -let limit = 30; -let UIDs = ["cometchat-uid-1", "cometchat-uid-2"]; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setUIDs(UIDs) - .build(); -``` - - - - -```ts -let limit: number = 30; -let UIDs: Array = ["cometchat-uid-1", "cometchat-uid-2"]; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setUIDs(UIDs) - .build(); -``` - - - - - -### Sort By - -This method allows you to sort the User List by a specific property of User. By default the User List is sorted by `status => name => UID` . If `name` is pass to the `sortBy()` method the user list will be sorted by `name => UID`. - - - -```js -let limit = 30; -let UIDs = ["cometchat-uid-1", "cometchat-uid-2"]; -let sortBy = "name"; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .sortBy(sortBy) - .build(); -``` - - - - -```ts -let limit: number = 30; -let sortBy: string = "name"; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .sortBy(sortBy) - .build(); -``` - - - - - -### Sort By Order - -This method allows you to sort the User List in a specific order. By default the user list is sorted in ascending order. - - - -```js -let limit = 30; -let sortByOrder = "desc"; -let usersReques = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .sortByOrder(sortOrder) - .build(); -``` - - - - -```ts -let limit: number = 30; -let sortOrder: string = "desc"; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .sortOrder(sortOrder) - .build(); -``` - - - - - -Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the UsersRequest class. - -Once you have the object of the UsersRequest class, you need to call the fetchNext() method. Calling this method will return a list of User objects containing n number of users where n is the limit set in the builder class. - - - -```js -var limit = 30; -var usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .build(); - -usersRequest.fetchNext().then( - userList => { - console.log("User list received:", userList); - }, error => { - console.log("User list fetching failed with error:", error); - } -); -``` - - - - -```ts -let limit: number = 30; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .build(); - -usersRequest.fetchNext().then( - (userList: CometChat.User[]) => { - console.log("User list received:", userList); - }, (error: CometChat.CometChatException) => { - console.log("User list fetching failed with error:", error); - } -); -``` - - - - - -## Retrieve Particular User Details - -To get the information of a user, you can use the `getUser()` method. - - - -```js -let UID = "UID"; -CometChat.getUser(UID).then( - user => { - console.log("User details fetched for user:", user); - }, error => { - console.log("User details fetching failed with error:", error); - } -); -``` - - - - -```ts -let UID: string = "UID"; -CometChat.getUser(UID).then( - (user: CometChat.User) => { - console.log("User details fetched for user:", user); - }, (error: CometChat.CometChatException) => { - console.log("User details fetching failed with error:", error); - } -); -``` - - - - - -The `getUser()` method takes the following parameters: - -| Parameter | Description | -| --------- | ---------------------------------------------------------- | -| UID | The UID of the user for whom the details are to be fetched | - -It returns the `User` object containing the details of the user. - -## Get online user count - -To get the total count of online users for your app, you can use the `getOnlineUserCount()` method. - - - -```js -CometChat.getOnlineUserCount().then( - userCount => { - console.log("Total online user count:", userCount); - }, error => { - console.log("Online user count fetching failed with error:", error); - } -); -``` - - - - -```ts -CometChat.getOnlineUserCount().then( - (userCount: number) => { - console.log("Total online user count:", userCount); - }, (error: CometChat.CometChatException) => { - console.log("Online user count fetching failed with error:", error); - } -); -``` - - - - - -This method returns the total online user count for your app. diff --git a/sdk/ionic-legacy/3.0/users-user-management.mdx b/sdk/ionic-legacy/3.0/users-user-management.mdx deleted file mode 100644 index d88e783dc..000000000 --- a/sdk/ionic-legacy/3.0/users-user-management.mdx +++ /dev/null @@ -1,207 +0,0 @@ ---- -title: "User Management" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -When a user logs into your app, you need to programmatically login the user into CometChat. But before you log in the user to CometChat, you need to create the user. - -Summing up- - -**When a user registers in your app** - -1. You add the user details in your database -2. You create a user in CometChat - -**When a user logs into your app** - -1. You log in the user to your app -2. You [log in the user to CometChat](/sdk/ionic-legacy/3.0/authentication) (programmatically) - -## Creating a user - -Ideally, user creation should take place at your backend. You can refer to our Rest API to learn more about [creating a user](https://api-explorer.cometchat.com/reference/creates-user) and use the appropriate code sample based on your backend language. - -However, if you wish to create users on the fly, you can use the `createUser()` method. This method takes a `User` object and the `Auth Key` as input parameters and returns the created `User` object if the request is successful. - - - -```js -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); - } -); -``` - - - - -```ts -let authKey: string = "AUTH_KEY"; -var uid: string = "user1"; -var name: string = "Kevin"; - -var user: CometChat.User = new CometChat.User(uid); - -user.setName(name); - -CometChat.createUser(user, authKey).then( - (user: CometChat.User) => { - console.log("user created", user); - }, - (error: CometChat.CometChatException) => { - console.log("error", error); - } -); -``` - - - - - - - -UID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed. - - - -## Updating a user - -Updating a user similar to creating a user should ideally be achieved at your backend using the Restful APIs. For more information, you can check the [update a user](https://api-explorer.cometchat.com/reference/update-user) section. However, this can be achieved on the fly as well as using the `updateUser()` method. This method takes a `User` object and the `Auth Key` as inputs and returns the updated `User` object on the successful execution of the request. - - - -```js -let authKey = "AUTH_KEY"; -let uid = "user1"; -let name = "Kevin Fernandez"; - -var user = new CometChat.User(uid); - -user.setName(name); - -CometChat.updateUser(user, authKey).then( - (user) => { - console.log("user updated", user); - }, - (error) => { - console.log("error", error); - } -); -``` - - - - -```ts -let authKey: string = "AUTH_KEY"; -var uid: string = "user1"; -var name: string = "Kevin Fernandez"; - -var user: CometChat.User = new CometChat.User(uid); - -user.setName(name); - -CometChat.updateUser(user, authKey).then( - (user: CometChat.User) => { - console.log("user updated", user); - }, - (error: CometChat.CometChatException) => { - console.log("error", error); - } -); -``` - - - - - -Please make sure the `User` object provided to the `updateUser()` method has the `UID` of the user to be updated set. - -## Updating logged-in user - -Updating a logged-in user is similar to updating a user. The only difference being this method does not require an AuthKey. This method takes a `User` object as input and returns the updated `User` object on the successful execution of the request. - - - -```js -let uid = "user1"; -let name = "Kevin Fernandez"; - -var user = new CometChat.User(uid); - -user.setName(name); - -CometChat.updateCurrentUserDetails(user).then( - (user) => { - console.log("user updated", user); - }, - (error) => { - console.log("error", error); - } -); -``` - - - - -```ts -var uid: string = "user1"; -var name: string = "Kevin Fernandez"; - -var user: CometChat.User = new CometChat.User(uid); - -user.setName(name); - -CometChat.updateCurrentUserDetails(user).then( - (user: CometChat.User) => { - console.log("user updated", user); - }, - (error: CometChat.CometChatException) => { - console.log("error", error); - } -); -``` - - - - - -By using the `updateCurrentUserDetails()` method one can only update the logged-in user irrespective of the UID passed. Also, it is not possible to update the role of a logged-in user. - -## Deleting a user - -Deleting a user can only be achieved via the Restful APIs. For more information please check the [delete a user](https://api-explorer.cometchat.com/reference/delete-user) section. - -## User Class - -| Field | Editable | Information | -| ------------- | --------------------------------------------------- | -------------------------------------------------------------------- | -| uid | specified on user creation. Not editable after that | Unique identifier of the user | -| name | Yes | Display name of the user | -| avatar | Yes | URL to profile picture of the user | -| link | Yes | URL to profile page | -| role | Yes | User role of the user for role based access control | -| metadata | Yes | Additional information about the user as JSON | -| status | No | Status of the user. Could be either online/offline | -| statusMessage | Yes | Any custom status message that needs to be set for a user | -| lastActiveAt | No | The unix timestamp of the time the user was last active. | -| hasBlockedMe | No | A boolean that determines if the user has blocked the logged in user | -| blockedByMe | No | A boolean that determines if the logged in user has blocked the user | -| tags | Yes | A list of tags to identify specific users | diff --git a/sdk/ionic-legacy/3.0/users.mdx b/sdk/ionic-legacy/3.0/users.mdx deleted file mode 100644 index eca83955b..000000000 --- a/sdk/ionic-legacy/3.0/users.mdx +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: "Users" -sidebarTitle: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -The primary aim for our user's functionality is to allow you to quickly retrieve and add users to CometChat. - -You can begin with [user management](/sdk/ionic-legacy/3.0/users-user-management) to sync your users to CometChat. Once that is done, you can [retrieve users](/sdk/ionic-legacy/3.0/users-retrieve-users) and display them in your app. diff --git a/sdk/ionic-legacy/3.0/v3-calling-recording.mdx b/sdk/ionic-legacy/3.0/v3-calling-recording.mdx deleted file mode 100644 index 224ef92d3..000000000 --- a/sdk/ionic-legacy/3.0/v3-calling-recording.mdx +++ /dev/null @@ -1,111 +0,0 @@ ---- -title: "Recording (Beta)" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -This section will guide you to implement call recording feature for the voice and video calls. - -## Implementation - -Once you have decided to implement [Default Calling](/sdk/ionic-legacy/3.0/calling-default-calling) or [Direct Calling](/sdk/ionic-legacy/3.0/calling-direct-calling) and followed the steps to implement them. Just few additional listeners and methods will help you quickly implement call recording in your app. - -You need to make changes in the CometChat.startCall method and add the required listeners for recording. Please make sure your callSettings is configured accordingly for [Default Calling](/sdk/ionic-legacy/3.0/calling-default-calling) or [Direct Calling](/sdk/ionic-legacy/3.0/calling-direct-calling). - -A basic example of how to make changes to implement recording for a direct call/ a default call: - - - -```js -// Add listeners onRecordingStarted and onRecordingStopped to the startCall method -let sessionId = "SESSION_ID"; -let audioOnly = false; -let defaultLayout = true; -let showRecordingButton = true; - -let callSettings = new CometChat.CallSettingsBuilder() - .enableDefaultLayout(defaultLayout) - .showRecordingButton(showRecordingButton) - .setSessionID(sessionId) - .setIsAudioOnlyCall(audioOnly) - .build(); - -CometChat.startCall( - callSettings, - document.getElementById("callScreen"), - new CometChat.OngoingCallListener({ - onRecordingStarted: recordingStartedBy => { - // This event will work in JS SDK v3.0.8 & later. - console.log("Listener => onRecordingStarted:", recordingStartedBy); - }, - onRecordingStopped: recordingStoppedBy => { - // This event will work in JS SDK v3.0.8 & later. - console.log("Listener => onRecordingStopped:", recordingStoppedBy); - }, - }) -); -``` - - - - -```ts -// Add listeners onRecordingStarted and onRecordingStopped to the startCall method. -let sessionId: string = "SESSION_ID"; -let audioOnly: boolean = false; -let defaultLayout: boolean = true; -let showRecordingButton: boolean = true; - -let callSettings: CometChat.CallSettings = new CometChat.CallSettingsBuilder() - .enableDefaultLayout(defaultLayout) - .showRecordingButton(showRecordingButton) - .setSessionID(sessionId) - .setIsAudioOnlyCall(audioOnly) - .build(); - -CometChat.startCall( - callSettings, - document.getElementById("callScreen"), - new CometChat.OngoingCallListener({ - onRecordingStarted: (recordingStartedBy: CometChat.User) => { - // This event will work in JS SDK v3.0.8 & later. - console.log("Listener => onRecordingStarted:", recordingStartedBy); - }, - onRecordingStopped: (recordingStoppedBy: CometChat.User) => { - // This event will work in JS SDK v3.0.8 & later. - console.log("Listener => onRecordingStopped:", recordingStoppedBy); - }, - }) -); -``` - - - - - -## Settings for call recording - -The `CallSettings` class allows you to customise the overall calling experience. The properties for the call/conference can be set using the `CallSettingsBuilder` class. This will eventually give you and object of the `CallSettings` class which you can pass to the `startCall()` method to start the call. - -The **mandatory** parameters that are required to be present for any call/conference to work are: - -1. sessionId - The unique session Id for the call/conference session. - -The options available for recording of calls are: - -| Setting | Description | -| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `showRecordingButton(showRecordingButton: boolean)` | If set to `true` it displays the Recording button in the button Layout.
if set to `false` it hides the Recording button in the button Layout.
**Default value = false** | -| `startRecordingOnCallStart(startRecordingOnCallStart: boolean)` | If set to `true` call recording will start as soon as the call is started.
if set to `false` call recording will not start as soon as the call is started.
**Default value = false** | - -## Downloading Recording - -Currently, the call recordings are available on the [CometChat Dashboard](https://app.cometchat.com) under the Calls Section. You can refer to the below screenshot. - - - - diff --git a/sdk/ionic-legacy/3.0/v3-setup.mdx b/sdk/ionic-legacy/3.0/v3-setup.mdx deleted file mode 100644 index 7c00d62f7..000000000 --- a/sdk/ionic-legacy/3.0/v3-setup.mdx +++ /dev/null @@ -1,121 +0,0 @@ ---- -title: "Setup" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Get your Application Keys - -[Signup for CometChat](https://app.cometchat.com) and then: - -1. Create a new app -2. Head over to the **Credentials** section and note the **App ID, Auth Key** & **Region** - -## Add the CometChatCalls Dependency - -Install the package as NPM module: - - - -``` -npm install @cometchat-pro/ionic-calls@latest --save -``` - - - - -``` -yarn add @cometchat-pro/ionic-calls@latest -``` - - - - - -Then, import the `CometChatCalls` class wherever you want to use `CometChatCalls`. - - - -```js -import { CometChatCalls } from "@cometchat-pro/ionic-calls"; -``` - - - - -```ts -import { CometChatCalls } from "@cometchat-pro/ionic-calls"; -``` - - - - - -### Initialize CometChatCalls - -The `init()` method initialises the settings required for `CometChatCalls`. The `init()` method takes a single paramater, that is the instance of `CallAppSettings` class. - -The `CallAppSettingsBuilder` class allows you to configure three settings: - -1. **appID:** You CometChat App ID -2. **region**: The region where your app was created -3. **host:** This method takes the client URL as input and uses this client URL instead of the default client URL. This can be used in case of dedicated deployment of CometChat. - -You need to call init() before calling any other method from `CometChatCalls`. We suggest you call the init() method on app startup, preferably in the index.js file. - - - -```js -let appID = "APP_ID"; -let region = "REGION"; - -const callAppSetting = new CometChatCalls.CallAppSettingsBuilder() - .setAppId(appID) - .setRegion(region) - .build(); - -CometChatCalls.init(callAppSetting).then( - () => { - console.log('CometChatCalls initialization completed successfully'); - }, - error => { - console.log('CometChatCalls initialization failed with error:', error); - }, -); -``` - - - - -```ts -let appID = "APP_ID"; -let region = "REGION"; - -const callAppSetting = new CometChatCalls.CallAppSettingsBuilder() - .setAppId(appID) - .setRegion(region) - .build(); - -CometChatCalls.init(callAppSetting).then( - () => { - console.log('CometChatCalls initialization completed successfully'); - }, - error => { - console.log('CometChatCalls initialization failed with error:', error); - }, -); -``` - - - - - -Make sure you replace the `APP_ID` with your CometChat **App ID** and `REGION` with your **App Region** in the above code. - -| Parameter | Description | -| ----------------- | ---------------------------------------- | -| `callAppSettings` | An object of the `CallAppSettings` class | diff --git a/sdk/ionic-legacy/3.0/v3-start-call-session.mdx b/sdk/ionic-legacy/3.0/v3-start-call-session.mdx deleted file mode 100644 index e81d52542..000000000 --- a/sdk/ionic-legacy/3.0/v3-start-call-session.mdx +++ /dev/null @@ -1,217 +0,0 @@ ---- -title: "Direct Calling" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -## Overview - -This guide demonstrates how to start call using Cometchat's calling sdk. Before you begin, we strongly recommend you read the calling setup guide. - -## Generate Call Token - -Prior to starting the call session, it is necessary to have a call token. A call token can be generated using the `generateToken` method of `CometChatCalls` class. - - - -```js -const loggedInUser = await CometChat.getLoggedinUser(); -if (loggedInUser) { - const authToken = loggedInUser.getAuthToken(); - const sessionID = "SESSION_ID_HERE"; - - CometChatCalls.generateToken(sessionID, authToken).then( - (res) => { - console.log("Call token fetched: ", res.token); - }, - (err) => { - console.log("Generating call token failed with error: ", err); - } - ); -} -``` - - - - -```ts -const loggedInUser = await CometChat.getLoggedinUser(); -if (loggedInUser) { - const authToken = loggedInUser.getAuthToken(); - const sessionID = "SESSION_ID_HERE"; - - CometChatCalls.generateToken(sessionID, authToken).then( - (res) => { - console.log("Call token fetched: ", res.token); - }, - (err) => { - console.log("Generating call token failed with error: ", err); - } - ); -} -``` - - - - - -| Parameter | Description | -| --------- | --------------------------------------------------------------------------------------------------------------------------------------- | -| sessionID | A unique random session ID. In case you are using default call then session ID is available in the `Call` object. | -| authToken | The user auth token is logged in user auth token which you can get by calling CometChat's Chat SDK method `CometChat.getLoggedinUser()` | - -| Error Code | Error Message | -| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| INVALID\_ARGUMENT\_EXCEPTION | If you pass invalid param to a function or you don't pass the required params. example: Authtoken and session are required, Invalid callToken passed, please verify. | - -On success of `generateToken` method you will get the response object containing call token with key named `token`. - -## Start Call Session - -The most important class that will be used in the implementation is the `CallSettings` class. This class allows you to set the various parameters for the call/conference. In order to set the various parameters of the `CallSettings` class, you need to use the `CallSettingsBuilder` class. Below are the various options available with the `CallSettings` class. - -The **mandatory** parameters that are required to be present for any call/conference to work are: - -1. **callToken:** The unique token for the call/conference session. -2. **callSettings:** The object of CallSettings class. - -A basic example of how to start a call session: - - - -```js -let audioOnly = false; -let defaultLayout = true; - -let callListener: CometChat.OngoingCallListener = new CometChat.OngoingCallListener({ - onUserJoined: (user) => { - console.log("user joined:", user); - }, - onUserLeft: (user) => { - console.log("user left:", user); - }, - onUserListUpdated: (userList) => { - console.log("user list:", userList); - }, - onCallEnded: () => { - console.log("Call ended"); - }, - onError: (error) => { - console.log("Error :", error); - }, - onAudioModesUpdated: (audioModes) => { - console.log("audio modes:", audioModes); - }, - onCallSwitchedToVideo: ({sessionId, initiator, acceptor}) => { - console.log("call switched to video:", {sessionId, initiator, acceptor}); - }, - onUserMuted: ({userMuted, userMutedBy}) => { - console.log("user muted:", {userMuted, userMutedBy}); - } -}); - -let callSettings = new CometChat.CallSettingsBuilder() - .enableDefaultLayout(defaultLayout) - .setIsAudioOnlyCall(audioOnly) - .setCallEventListener(callListener) - .build(); - -CometChatCalls.startSession(callsettings, callToken); -``` - - - - -```ts -let sessionID: string = "SESSION_ID"; -let audioOnly: boolean = false; -let defaultLayout: boolean = true; -let callListener: CometChat.OngoingCallListener = new CometChat.OngoingCallListener({ - onUserJoined: (user: CometChat.User) => { - console.log("user joined:", user); - }, - onUserLeft: (user: CometChat.User) => { - console.log("user left:", user); - }, - onUserListUpdated: (userList: CometChat.User[]) => { - console.log("user list:", userList); - }, - onCallEnded: (call: CometChat.Call) => { - console.log("Call ended:", call); - }, - onError: (error: CometChat.CometChatException) => { - console.log("Error :", error); - }, - onAudioModesUpdated: (audioModes: CometChat.AudioMode[]) => { - console.log("audio modes:", audioModes); - } -}); - -let callSettings: CometChat.CallSettings = new CometChat.CallSettingsBuilder() - .enableDefaultLayout(defaultLayout) - .setSessionID(sessionID) - .setIsAudioOnlyCall(audioOnly) - .setCallEventListener(callListener) - .build(); - -CometChat.startCall(callSettings); -``` - - - - - -The `setIsAudioOnlyCall()` method allows you to set if the call is supposed to be an audio call or an audio-video call. If set to true, the call will be an audio-only call else when set to false the call will be an audio-video call. The default is false, so if not set, the call will be an audio-video call. - -| Parameter | Description | -| -------------- | ---------------------------------------------------------------------------------------------------------------------------- | -| `callToken` | An authorization token used to start the call session, received by calling `generateToken` method of `CometChatCalls` class. | -| `callSettings` | Object of `CallSettings` class. | - -| Error Code | Error Message | -| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ | -| INVALID\_PROP\_EXCEPTION | If you pass an invalid prop to a functional component or you don't pass the required prop. example: Component requires valid call settings | -| API\_ERROR | If there is some error thrown by the API server For example unauthorized | -| UNKNOWN\_API\_ERROR | If there is some API error but it didn't come from the server. For example, if the internet is not available and API is called. | -| AUTH\_ERR\_TOKEN\_INVALID\_SIGNATURE | if Token is invalid | - -The `OngoingCallListener` listener provides you with the below callback methods: - -| Callback Method | Description | -| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `onUserJoined(user)` | This method is called when any other user joins the call. The user details can be obtained from the `user` object provided. | -| `onUserLeft(user)` | This method is called when a user leaves the call. The details of the user can be obtained from the provided `user` object. | -| `onCallEnded()` | This method is called when the call is successfully ended. | -| `onUserListUpdated(userList)` | This method is triggered every time a participant joins or leaves the call providing the list of users active in the call. | -| `onAudioModesUpdated(audioModes)` | This callback is triggered if any new audio output source is available or becomes unavailable. | -| `onCallSwitchedToVideo(event)` | This callback is triggered when an audio call is converted into a video call. The event object contains three keys named `sessionId` , `initiator` and `responder` | -| `onUserMuted(event)` | This callback is triggered when a user is muted in the call. | - -## Settings - -The `CallSettings` class is the most important class when it comes to the implementation of the Calling feature. This is the class that allows you to customize the overall calling experience. The properties for the call/conference can be set using the `CallSettingsBuilder` class. This will eventually give you and object of the `CallSettings` class which you can pass to the `startSession()` method to start the call. - -The options available for customization of calls are: - -| Setting | Description | -| ---------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `enableDefaultLayout(defaultLayout: boolean)` | If set to `true` enables the default layout for handling the call operations.
If set to `false` it hides the button layout and just displays the Call View.
**Default value = true** | -| `showEndCallButton(showEndCallButton: boolean)` | If set to `true` it displays the EndCallButton in Button Layout.
if set to `false` it hides the EndCallButton in Button Layout.
**Default value = true** | -| `showPauseVideoButton(showPauseVideoButton: boolean)` | If set to `true` it displays the PauseVideoButton in Button Layout.
if set to `false` it hides the PauseVideoButton in Button Layout.
**Default value = true** | -| `showMuteAudioButton(showMuteAudioButton: boolean)` | If set to `true` it displays the MuteAudioButton in Button Layout.
if set to `false` it hides the MuteAudioButton in Button Layout.
**Default value = true** | -| `showSwitchCameraButton(showSwitchCameraButton: boolean)` | If set to `true` it displays the SwitchCameraButton in Button Layout.
if set to `false` it hides the SwitchCameraButton in Button Layout.
**Default value = true** | -| `showAudioModeButton(showAudioModeButton: boolean)` | If set to `true` it displays the AudioModeButton in Button Layout.
if set to `false` it hides the AudioModeButton in Button Layout.
**Default value = true** | -| `setIsAudioOnlyCall(audioOnly: boolean)` | If set to true, the call will be strictly an audio call.
If ser to false, the call will be an audio-video call.
**Default value = false** | -| `setMode(mode: string)` | CometChat provides 3 options for the calling UI.
1. CometChat.CALL\_MODE.DEFAULT
2. CometChat.CALL\_MODE.SPOTLIGHT
**Default value = CometChat.CALL\_MODE.DEFAULT** | -| `startWithAudioMuted(audioMuted: boolean)` | This ensures the call is started with the audio muted if set to true.
**Default value = false** | -| `startWithVideoMuted(videoMuted: boolean)` | This ensures the call is started with the video paused if set to true.
**Default value = false** | -| `setDefaultAudioMode(audioMode: string)` | This method can be used if you wish to start the call with a specific audio mode. The available options are
1. CometChat.AUDIO\_MODE.SPEAKER = "SPEAKER"
2. CometChat.AUDIO\_MODE.EARPIECE = "EARPIECE"
3. CometChat.AUDIO\_MODE.BLUETOOTH = "BLUETOOTH"
4. CometChat.AUDIO\_MODE.HEADPHONES = "HEADPHONES" | -| `showSwitchToVideoCallButton(switchCall: boolean)` | This method shows/hides the switch to video call button. If set to true it will display the switch to video call button. If set to false it will hide the switch to video call button.
**Default value = true** | -| `setAvatarMode(avatarMode: string)` | This method sets the mode of avatar. The avatar mode can be `circle`, `square` or `fullscreen`.
**Default value = circle** | -| `setMainVideoContainerSetting(containerSettings: MainVideoContainerSetting)` | This method can be used to customize the main video container. You can read more about this [here](/sdk/ionic-legacy/3.0/v3-video-view-customisation). | -| `enableVideoTileClick(enableVideoTileClick: boolean)` | This method can be used to enable/disable video tile click functionality in **Spotlight** mode.
**Default value = true** | -| `enableVideoTileDrag(enableVideoTileDrag: boolean)` | This method can be used to enable/disable video tile drag functionality in **Spotlight** mode.
**Default value = true** | diff --git a/sdk/ionic-legacy/3.0/v3-video-view-customisation.mdx b/sdk/ionic-legacy/3.0/v3-video-view-customisation.mdx deleted file mode 100644 index 76880e195..000000000 --- a/sdk/ionic-legacy/3.0/v3-video-view-customisation.mdx +++ /dev/null @@ -1,46 +0,0 @@ ---- -title: "Video View Customisation" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -This section will guide you to customise the main video container. - -## Implementation - -Once you have decided to implement [Default Calling](/sdk/ionic-legacy/3.0/calling-default-calling) or [Direct Calling](/sdk/ionic-legacy/3.0/calling-direct-calling) calling and followed the steps to implement them. Just few additional methods will help you quickly customize the main video container. - -Please make sure your callSettings is configured accordingly for [Default Calling](/sdk/ionic-legacy/3.0/calling-default-calling) or [Direct Calling](/sdk/ionic-legacy/3.0/calling-direct-calling). - -## Main Video Container Setting - -The `MainVideoContainerSetting` Class is the required in case you want to customise the main video view. You need to pass the Object of the `MainVideoContainerSetting` Class in the `setMainVideoContainerSetting()` method of the `CallSettingsBuilder`. - -| Setting | Description | -| ------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `setMainVideoAspectRatio(aspectRatio: string)` | This method is used to set the aspect ratio of main video. The default value is **contain.**

Possible Values:
**1. CometChat.CallSettings. ASPECT\_RATIO\_CONTAIN**
**2. CometChat.CallSettings. ASPECT\_RATIO\_COVER** | -| `setFullScreenButtonParams(position: string, visibility: boolean)` | This method is used to set the position & visibility parameter of the full screen button. By default the full screen button is visible in the **bottom-right** position.

Possible Values for **POSITION:**
1. **CometChat.CallSettings. POSITION\_TOP\_LEFT**
2. **CometChat.CallSettings. POSITION\_TOP\_RIGHT**
3. **CometChat.CallSettings. POSITION\_BOTTOM\_LEFT**
4. **CometChat.CallSettings. POSITION\_BOTTOM\_RIGHT**

Possible Values for **VISIBILITY:**
1. **true**
2. **false** | -| `setNameLabelParams(position: string, visibility: boolean, backgroundColor: string)` | This method is used to set the position, visibility & background color of the name label. By default the name label is visible in the **bottom-left** position with a background-color **#333333**

Possible Values for **POSITION:**
1. **CometChat.CallSettings. POSITION\_TOP\_LEFT**
2. **CometChat.CallSettings. POSITION\_TOP\_RIGHT**
3. **CometChat.CallSettings. POSITION\_BOTTOM\_LEFT**
4. **CometChat.CallSettings. POSITION\_BOTTOM\_RIGHT**

Possible Values for **VISIBILITY:**
1. **true**
2. **false** | -| `setZoomButtonParams(position: string, visibility: boolean)` | This method is used to set the position, visibility of the zoom button. By default the zoom button is visible in the **bottom-right** position.

Possible Values for **POSITION:**
1. **CometChat.CallSettings. POSITION\_TOP\_LEFT**
2. **CometChat.CallSettings. POSITION\_TOP\_RIGHT**
3. **CometChat.CallSettings. POSITION\_BOTTOM\_LEFT**
4. **CometChat.CallSettings. POSITION\_BOTTOM\_RIGHT**

Possible Values for **VISIBILITY:**
1. **true**
2. **false** | -| `setUserListButtonParams(position: string, visibility: boolean)` | This method is used to set the position, visibility of the user list button. By default the user list button is visible in the **bottom-right**

position. Possible Values for **POSITION:**
1. **CometChat.CallSettings. POSITION\_TOP\_LEFT**
2. **CometChat.CallSettings. POSITION\_TOP\_RIGHT**
3. **CometChat.CallSettings. POSITION\_BOTTOM\_LEFT**
4. **CometChat.CallSettings. POSITION\_BOTTOM\_RIGHT**

Possible Values for **VISIBILITY:**
1. **true**
2. **false** | - -Example: - - - -```js -let videoSettings = new CometChat.MainVideoContainerSetting(); - -videoSettings.setMainVideoAspectRatio(CometChat.CallSettings.ASPECT_RATIO_CONTAIN); videoSettings.setFullScreenButtonParams(CometChat.CallSettings.POSITION_BOTTOM_RIGHT, true); -videoSettings.setNameLabelParams(CometChat.CallSettings.POSITION_BOTTOM_LEFT, true, "#333333"); -videoSettings.setZoomButtonParams(CometChat.CallSettings.POSITION_BOTTOM_RIGHT, true); -videoSettings.setUserListButtonParams(CometChat.CallSettings.POSITION_BOTTOM_RIGHT, true); -``` - - - - diff --git a/sdk/ionic-legacy/3.0/video-view-customisation.mdx b/sdk/ionic-legacy/3.0/video-view-customisation.mdx deleted file mode 100644 index 414e4b4dc..000000000 --- a/sdk/ionic-legacy/3.0/video-view-customisation.mdx +++ /dev/null @@ -1,46 +0,0 @@ ---- -title: "Video View Customisation" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -This section will guide you to customise the main video container. - -## Implementation - -Once you have decided to implement [Default Calling](/sdk/ionic-legacy/3.0/calling-default-calling) or [Direct Calling](/sdk/ionic-legacy/3.0/calling-direct-calling) calling and followed the steps to implement them. Just few additional methods will help you quickly customize the main video container. - -Please make sure your callSettings is configured accordingly for [Default Calling](/sdk/ionic-legacy/3.0/calling-default-calling) or [Direct Calling](/sdk/ionic-legacy/3.0/calling-direct-calling). - -## Main Video Container Setting - -The `MainVideoContainerSetting` Class is the required in case you want to customise the main video view. You need to pass the Object of the `MainVideoContainerSetting` Class in the `setMainVideoContainerSetting()` method of the `CallSettingsBuilder`. - -| Setting | Description | -| ------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `setMainVideoAspectRatio(aspectRatio: string)` | This method is used to set the aspect ratio of main video. The default value is **contain.**

Possible Values:
**1. CometChat.CallSettings. ASPECT\_RATIO\_CONTAIN**
**2. CometChat.CallSettings. ASPECT\_RATIO\_COVER** | -| `setFullScreenButtonParams(position: string, visibility: boolean)` | This method is used to set the position & visibility parameter of the full screen button. By default the full screen button is visible in the **bottom-right** position.

Possible Values for **POSITION:**
1. **CometChat.CallSettings. POSITION\_TOP\_LEFT**
2. **CometChat.CallSettings. POSITION\_TOP\_RIGHT**
3. **CometChat.CallSettings. POSITION\_BOTTOM\_LEFT**
4. **CometChat.CallSettings. POSITION\_BOTTOM\_RIGHT**

Possible Values for **VISIBILITY:**
1. **true**
2. **false** | -| `setNameLabelParams(position: string, visibility: boolean, backgroundColor: string)` | This method is used to set the position, visibility & background color of the name label. By default the name label is visible in the **bottom-left** position with a background-color **#333333**

Possible Values for **POSITION:**
1. **CometChat.CallSettings. POSITION\_TOP\_LEFT**
2. **CometChat.CallSettings. POSITION\_TOP\_RIGHT**
3. **CometChat.CallSettings. POSITION\_BOTTOM\_LEFT**
4. **CometChat.CallSettings. POSITION\_BOTTOM\_RIGHT**

Possible Values for **VISIBILITY:**
1. **true**
2. **false** | -| `setZoomButtonParams(position: string, visibility: boolean)` | This method is used to set the position, visibility of the zoom button. By default the zoom button is visible in the **bottom-right** position.

Possible Values for **POSITION:**
1. **CometChat.CallSettings. POSITION\_TOP\_LEFT**
2. **CometChat.CallSettings. POSITION\_TOP\_RIGHT**
3. **CometChat.CallSettings. POSITION\_BOTTOM\_LEFT**
4. **CometChat.CallSettings. POSITION\_BOTTOM\_RIGHT**

Possible Values for **VISIBILITY:**
1. **true**
2. **false** | -| `setUserListButtonParams(position: string, visibility: boolean)` | This method is used to set the position, visibility of the user list button. By default the user list button is visible in the **bottom-right** position.

Possible Values for **POSITION:**
1. **CometChat.CallSettings. POSITION\_TOP\_LEFT**
2. **CometChat.CallSettings. POSITION\_TOP\_RIGHT**
3. **CometChat.CallSettings. POSITION\_BOTTOM\_LEFT**
4. **CometChat.CallSettings. POSITION\_BOTTOM\_RIGHT**

Possible Values for **VISIBILITY:**
1. **true**
2. **false** | - -Example: - - - -```js -let videoSettings = new CometChat.MainVideoContainerSetting(); - -videoSettings.setMainVideoAspectRatio(CometChat.CallSettings.ASPECT_RATIO_CONTAIN); videoSettings.setFullScreenButtonParams(CometChat.CallSettings.POSITION_BOTTOM_RIGHT, true); -videoSettings.setNameLabelParams(CometChat.CallSettings.POSITION_BOTTOM_LEFT, true, "#333333"); -videoSettings.setZoomButtonParams(CometChat.CallSettings.POSITION_BOTTOM_RIGHT, true); -videoSettings.setUserListButtonParams(CometChat.CallSettings.POSITION_BOTTOM_RIGHT, true); -``` - - - - diff --git a/sdk/ionic-legacy/3.0/webhooks.mdx b/sdk/ionic-legacy/3.0/webhooks.mdx deleted file mode 100644 index 5903df759..000000000 --- a/sdk/ionic-legacy/3.0/webhooks.mdx +++ /dev/null @@ -1,70 +0,0 @@ ---- -title: "Webhooks" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. - - - - -CometChat can send webhook events that notify your application any time an event happens on your account. - -## Setting up webhooks - -### Create a webhook endpoint - -Webhook data is sent as JSON in the POST request body. Creating a webhook endpoint on your server is no different from creating any page on your website. With PHP, you might create a new .php file on your server; with a Ruby framework like Sinatra, you would add a new route with the desired URL. - -### Test the endpoint locally - -Once you’ve added an endpoint to your server, start an instance locally and use a tool like [ngrok](https://ngrok.com) to make your endpoint available for receiving events. - -Start ngrok in a command prompt with the same port number that you have configured for your server (e.g., ./ngrok http 8000). You should see information about your tunnel session such as status, expiration, and version. Take note of the Forwarding addresses (e.g., [https://xxxxxxxx.ngrok.io](https://xxxxxxxx.ngrok.io) -> localhost:8000) as this is required for the following step. - -### Configure webhook settings - -With your endpoint created, you need to tell CometChat about where to send events to. In the Dashboard's Webhooks section, click **Create Webhook** to reveal a form to add a new webhook for receiving events. You can enter any URL as the destination for events. However, this should be a dedicated page on your server that is set up to receive webhook events. - -Once you've created the webhook, click **View/Update** to add a trigger. We support two types of triggers- - -| Trigger | Description | -| --------------- | ----------------------------------------------------------- | -| after\_message | The endpoint will be triggered after a message is sent. | -| before\_message | The endpoint will be triggered when a message is in-flight. | - -The `after_message` trigger is fairly straightforward. CometChat will call your endpoint once a message has been sent. - -The `before_message` trigger is useful when you want to add metadata to a message before it reaches the recipient. The data you return will be automatically added to the message metadata: - - - -```json -{ - "@injected": { - "webhooks": { - "webhook-id": { - // JSON Object Response From Endpoint - } - } - } -} -``` - - - - - -You can also decide to drop a message by returning the following JSON object- - - - -```json -{ - "action": "do_not_propagate" -} -``` - - - - diff --git a/sdk/ionic-legacy/additional-message-filtering.mdx b/sdk/ionic-legacy/additional-message-filtering.mdx deleted file mode 100644 index feab05e15..000000000 --- a/sdk/ionic-legacy/additional-message-filtering.mdx +++ /dev/null @@ -1,1417 +0,0 @@ ---- -title: "Additional Message Filtering" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/additional-message-filtering) which provides full compatibility with Ionic applications. - - -The `MessagesRequest` class as you must be familiar with helps you to fetch messages based on the various parameters provided to it. This document will help you understand better the various options that are available using the `MessagesRequest` class. - -The `MessagesRequest` class is designed using the `Builder design pattern`. In order to obtain an object of the `MessagesRequest` class, you will have to make use of the `MessagesRequestBuilder` class in the `MessagesRequest` class. - -The `MessagesRequestBuilder` class allows you to set various parameters to the `MessagesRequest` class based on which the messages are fetched. - -Steps to generate an object of the MessagesRequest class: - -1. Create an object of the `MessagesRequestBuilder` class. -2. Set all the parameters you wish to set. -3. Call the `build()` method of the `MessagesRequestBuilder` class to get an object of the `MessagesRequest` class. - -Once you have an object of the `MessagesRequest` class, you can call either the `fetchNext()` method or the `fetchPrevious()` method using the object. - -1. fetchNext() - Calling this method will return the messages after the specified parameters. -2. fetchPrevious() - Calling this method will give you messages before the specified parameters. - -Both `fetchPrevious()` and `fetchNext()` return an array of [`BaseMessage`](/sdk/reference/messages#basemessage) objects (which may be [`TextMessage`](/sdk/reference/messages#textmessage), [`MediaMessage`](/sdk/reference/messages#mediamessage), [`CustomMessage`](/sdk/reference/messages#custommessage), or other subclasses depending on the filters applied). - -Since messages are obtained in a paginated manner, a `maximum of 100` messages can be pulled in a single iteration. Calling the `fetchPrevious()`/`fetchNext()` method on the same `MessagesRequest` object will get you the next set of messages. - -Now that you are clear how to use the `MessagesRequest` class, below are the various options available: - -## Number of messages fetched - -*In other words, how do I set the number of messages fetched in a single iteration* - -To achieve this, you can use the `setLimit()` method. This method takes an integer value as the input and informs the SDK to fetch the specified number of messages in one iteration. The maximum number of messages that can be fetched in one go is `100`. - - - -```javascript -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setLimit(50) - .build(); -``` - - - - -```typescript -let messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder().setLimit(50).build(); -``` - - - - - -## Messages for a user conversation - -\_In other words, how do I fetch messages between me and any user \_ - -This can be achieved using the `setUID()` method. This method takes the UID of the user with whom the conversation is to be fetched. When a valid UID is passed, the SDK will return all the messages that are a part of the conversation between the logged-in user and the UID that has been specified. - - - -```javascript -let UID = "UID"; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(50) - .build(); -``` - - - - -```typescript -let UID: string = "UID", - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder().setUID(UID).setLimit(50).build(); -``` - - - - - -## Messages for a group conversation - -*In other words, how do I fetch messages for any group conversation* - -You can achieve this using the `setGUID()` method. This method takes the GUID of a group for which the conversations are to be fetched. Passing a valid GUID to this method will return all the messages that are a part of the group conversation. Please note that the logged-in user must be a member of the group to fetch the messages for that group. - - - -```javascript -let GUID = "GUID"; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(50) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID", - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder().setGUID(GUID).setLimit(50).build(); -``` - - - - - - - -If none of the above two methods `setUID()` and `setGUID()` is used, an empty array will be returned. All the parameters discussed below should be used along with the setUID() or setGUID() methods. - - - -## Messages before/after a message - -\_In other words, how do I fetch messages before or after a particular message \_ - -This can be achieved using the `setMessageId()` method. This method takes the message-id as input and provides messages only after/before the message-id based on if the fetchNext() or fetchPrevious() method is triggered. - - - -```javascript -let UID = "UID"; -let messageId = 1; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setMessageId(messageId) - .setLimit(limit) - .build(); -``` - - - - -```typescript -let GUID = "GUID"; -let messageId = 1; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setMessageId(messageId) - .setLimit(limit) - .build(); -``` - - - - -```typescript -let UID: string = "UID", - messageId: number = 1, - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setMessageId(messageId) - .setLimit(limit) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID", - messageId: number = 1, - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setMessageId(messageId) - .setLimit(limit) - .build(); -``` - - - - - -This method can be used along with `setUID()` or `setGUID()` methods to fetch messages after/before any specific message-id for a particular user/group conversation. - -## Messages before/after a given time - -\_In other words, how do I fetch messages before or after a particular date or time \_ - -You can easily achieve this using the `setTimestamp()` method. This method takes the Unix timestamp as input and provides messages only after/before the timestamp based on if fetchNext() or fetchPrevious() method is triggered. - - - -```javascript -let UID = "UID"; -let timestamp = 1602221371; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setTimestamp(timestamp) - .setLimit(limit) - .build(); -``` - - - - -```javascript -let GUID = "GUID"; -let timestamp = 1602221371; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setTimestamp(timestamp) - .setLimit(limit) - .build(); -``` - - - - -```typescript -let UID: string = "UID", - timestamp: number = 1602221371, - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setTimestamp(timestamp) - .setLimit(limit) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID", - timestamp: number = 1602221371, - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setTimestamp(timestamp) - .setLimit(limit) - .build(); -``` - - - - - -This method can be used along with `setUID()` or `setGUID()` methods to fetch messages after/before any specific date or time for a particular user/group conversation. - -## Unread messages - -\_In other words, how do I fetch unread messages \_ - -This can easily be achieved using setting the unread flag to true. For this, you need to use the `setUnread()` method. This method takes a boolean value as input. If the value is set to true, the SDK will return just the unread messages. - - - -```javascript -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setUnread(true) - .setLimit(limit) - .build(); -``` - - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setUnread(true) - .setLimit(limit) - .build(); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setUnread(true) - .setLimit(limit) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setUnread(true) - .setLimit(limit) - .build(); -``` - - - - - -This method along with `setGUID()` or `setUID()` can be used to fetch unread messages for a particular group or user conversation respectively. - -## Exclude messages from blocked users - -\_In other words, how do I fetch messages excluding the messages from the users I have blocked \_ - -This can be easily achieved using the `hideMessagesFromBlockedUsers()` method. This method accepts a boolean value which determines if the messages from users blocked by the logged-in user need to be a part if the fetched messages. If the value is set to true, the messages will be hidden and won't be a part of the messages fetched. The default value is false i.e if this method is not used, the messages from blocked users will be included in the fetched messages. - - - -```javascript -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .hideMessagesFromBlockedUsers(true) - .setLimit(limit) - .build(); -``` - - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .hideMessagesFromBlockedUsers(true) - .setLimit(limit) - .build(); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .hideMessagesFromBlockedUsers(true) - .setLimit(limit) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .hideMessagesFromBlockedUsers(true) - .setLimit(limit) - .build(); -``` - - - - - -This method can be used to hide the messages by users blocked by logged in user in groups that both the members are a part of. - -## Updated and received messages - -\_In other words, how do I fetch messages that have been received or updated after a particular date or time \_ - -This method accepts a Unix timestamp value and will return all the messages that have been updated and the ones that have been sent/received after the specified time. The messages updated could mean the messages that have been marked as read/delivered or if the messages are edited or deleted. - - - -```javascript -let UID = "UID"; -let limit = 30; -let timestamp = 1602221371; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setUpdatedAfter(timestamp) - .setLimit(limit) - .build(); -``` - - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let timestamp = 1602221371; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setUpdatedAfter(timestamp) - .setLimit(limit) - .build(); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - timestamp: string = "1602221371", - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setUpdatedAfter(timestamp) - .setLimit(limit) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID", - limit: number = 30, - timestamp: string = "1602221371", - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setUpdatedAfter(timestamp) - .setLimit(limit) - .build(); -``` - - - - - -This can be useful in finding the messages that have been received or updated after a certain time. Can prove very useful if you are saving the messages locally and would like to know the messages that have been updated or received after the last message available in your local databases. - -## Updated messages only - -\_In other words, how do I fetch messages that have been updated after a particular date or time \_ - -This can be achieved easily by setting the updatesOnly parameter to true. To do so, you can use the updatesOnly() method. This method takes a boolean input and can be used with the `setUpdatedAfter()` method to get jus the updated messages and not the messages sent/received after the specified time. This method cannot be used independently and always needs to be used with the `setUpdatedAfter()` method. - - - -```javascript -let UID = "UID"; -let limit = 30; -let timestamp = 1602221371; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setUpdatedAfter(timestamp) - .updatesOnly(true) - .setLimit(limit) - .build(); -``` - - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let timestamp = 1602221371; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setUpdatedAfter(timestamp) - .updatesOnly(true) - .setLimit(limit) - .build(); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - timestamp: string = "1602221371", - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setUpdatedAfter(timestamp) - .updatesOnly(true) - .setLimit(limit) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID", - limit: number = 30, - timestamp: string = "1602221371", - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setUpdatedAfter(timestamp) - .updatesOnly(true) - .setLimit(limit) - .build(); -``` - - - - - -Messages for multiple categories - -*In other words, how do I fetch messages belonging to multiple categories* - -We recommend before trying this, you refer to the [Message structure and hierarchy guide](/sdk/ionic-legacy/message-structure-and-hierarchy) to get familiar with the various categories of messages. - -For this, you will have to use the `setCategories()` method. This method accepts a list of categories. This tells the SDK to fetch messages only belonging to these categories. - - - -```javascript -let UID = "UID"; -let limit = 30; -let categories = ["message", "custom"]; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setCategories(categories) - .setLimit(limit) - .build(); -``` - - - - -```typescript -let GUID = "GUID"; -let limit = 30; -let categories = ["message", "custom"]; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setCategories(categories) - .setLimit(limit) - .build(); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - categories: Array = ["message", "custom"], - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setCategories(categories) - .setLimit(limit) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID", - limit: number = 30, - categories: Array = ["message", "custom"], - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setCategories(categories) - .setLimit(limit) - .build(); -``` - - - - - -The above snippet will help you get only the messages belonging to the `message` and `custom` category. This can also be used to disable certain categories of messages like `call` and `action`. This along with `setGUID()` and `setUID()` can help display only the messages you wish to display avoiding the other category of messages. - -## Messages for multiple types - -\_In other words, how do I fetch messages belonging to multiple types \_ - -We recommend before trying this, you refer to the [Message structure & hierarchy guide](/sdk/ionic-legacy/message-structure-and-hierarchy) to get familiar with the various types of messages. - -This can be easily achieved using the `setTypes()` method. This method accepts a list of types. This tells the SDK to fetch messages only belonging to these types. - - - -```javascript -let UID = "UID"; -let limit = 30; -let categories = ["message"]; -let types = ["image", "video", "audio", "file"]; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setCategories(categories) - .setTypes(types) - .setLimit(limit) - .build(); -``` - - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let categories = ["message"]; -let types = ["image", "video", "audio", "file"]; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setCategories(categories) - .setTypes(types) - .setLimit(limit) - .build(); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - categories: Array = ["message", "custom"], - types: Array = ["image", "video", "audio", "file"], - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setCategories(categories) - .setTypes(types) - .setLimit(limit) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID", - limit: number = 30, - categories: Array = ["message", "custom"], - types: Array = ["image", "video", "audio", "file"], - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setCategories(categories) - .setTypes(types) - .setLimit(limit) - .build(); -``` - - - - - -Using the above code snippet, you can fetch all the media messages. This along with setUID() or setGUID() can be used to fetch media messages for any particular conversation. This can be useful in many other scenarios as well. - -## Messages for a specific thread - -\_In other words, how do I fetch messages that are a part of a thread and not directly a user/group conversations \_ - -This can be done using the `setParentMessageId()` method. This method needs to be used when you have implemented threaded conversations in your app. This method will return the messages only belonging to the thread with the specified parent Id. - - - -```javascript -let UID = "UID"; -let messageId = 1; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .setParentMessageId(messageId) - .build(); -``` - - - - -```javascript -let GUID = "GUID"; -let messageId = 1; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .setParentMessageId(messageId) - .build(); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - messageId: number = 1, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .setParentMessageId(messageId) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID", - limit: number = 30, - messageId: number = 1, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .setParentMessageId(messageId) - .build(); -``` - - - - - -The above code snippet returns the messages that belong to the thread with parent id 100. - -## Hide threaded messages in user/group conversations - -\*In other words, how do I exclude threaded messages from the normal user/group conversations \* - -In order to do this, you can use the `hideReplies()` method. This method is also related to threaded conversations. This method takes boolean as input. This boolean when set to true will make sure that the messages that belong to threads are not fetched. If set to false, which is also the default value, the messages belong to the threads will also be fetched along with other messages. - - - -```javascript -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .hideReplies(true) - .build(); -``` - - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hideReplies(true) - .build(); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .hideReplies(true) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hideReplies(true) - .build(); -``` - - - - - -## Hide deleted messages in user/group conversations - -\*In other words, how do I exclude deleted messages a user/group conversations\* - -In order to do this, you can use the `hideDeletedMessages()` method. This method takes boolean as input. This boolean when set to true will make sure that the deleted messages are not fetched. If set to false, which is also the default value, the deleted messages will also be fetched along with other messages. - - - -```javascript -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .hideDeletedMessages(true) - .build(); -``` - - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hideDeletedMessages(true) - .build(); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .hideDeletedMessages(true) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hideDeletedMessages(true) - .build(); -``` - - - - - -## Messages by tags - -*In other words, how do I fetch messages by tags* - -In order to do this, you can use the `setTags()` method. This method accepts a list of tags. This tells the SDK to fetch messages only belonging to these tags. - - - -```javascript -let UID = "UID"; -let limit = 30; -let tags = ["starredMessage"]; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .setTags(tags) - .build(); -``` - - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let tags = ["starredMessage"]; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .setTags(tags) - .build(); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - tags: Array = ["starredMessage"], - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .setTags(tags) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID", - limit: number = 30, - tags: Array = ["starredMessage"], - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .setTags(tags) - .build(); -``` - - - - - -## Messages with tags - -*In other words, how do I fetch messages with the tags information* - -In order to do this, you can use the `withTags()` method. This method accepts boolean as input. When set to `true` , the SDK will fetch messages along with the tags. When set to `false` , the SDK will not fetch tags associated with messages. The default value for this parameter is `false` . - - - -```javascript -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .withTags(true) - .build(); -``` - - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .withTags(tags) - .build(); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(UID) - .setLimit(limit) - .withTags(true) - .build(); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(UID) - .setLimit(limit) - .withTags(true) - .build(); -``` - - - - - -## Messages with links - -In other words, as a logged-in user, how do I fetch messages that contains links? - -In order to do this, you can use the `hasLinks()` method. This method accepts boolean as input. When set to `true` , the SDK will fetch messages which have links in the text. The default value for this parameter is `false`. - - - -This feature is only available with `Conversation & Advanced Search`. The `Conversation & Advanced Search` is only available in `Advanced` & `Custom` [plans](https://www.cometchat.com/pricing). If you're already on one of these plans, please enable the `Conversation & Advanced Search` from [CometChat Dashboard](https://app.cometchat.com) (Open your app, navigate to Chats -> Settings -> General Configuration) - - - - - -```javascript -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .hasLinks(true) - .build(); -``` - - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hasLinks(true) - .build(); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(UID) - .setLimit(limit) - .hasLinks(true) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hasLinks(true) - .build(); -``` - - - - - -## Messages with attachments - -In other words, as a logged-in user, how do I fetch messages that contains attachments? - -In order to do this, you can use the `hasAttachments()` method. This method accepts boolean as input. When set to `true` , the SDK will fetch messages which have attachments (image, audio, video or file). The default value for this parameter is `false`. - - - -This feature is only available with `Conversation & Advanced Search`. The `Conversation & Advanced Search` is only available in `Advanced` & `Custom` [plans](https://www.cometchat.com/pricing). If you're already on one of these plans, please enable the `Conversation & Advanced Search` from [CometChat Dashboard](https://app.cometchat.com) (Open your app, navigate to Chats -> Settings -> General Configuration) - - - - - -```javascript -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .hasAttachments(true) - .build(); -``` - - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hasAttachments(true) - .build(); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(UID) - .setLimit(limit) - .hasAttachments(true) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hasAttachments(true) - .build(); -``` - - - - - -## Messages with reactions - -In other words, as a logged-in user, how do I fetch messages that contains reactions? - -In order to do this, you can use the `hasReactions()` method. This method accepts boolean as input. When set to `true` , the SDK will fetch messages which have reactions. The default value for this parameter is `false`. - - - -This feature is only available with `Conversation & Advanced Search`. The `Conversation & Advanced Search` is only available in `Advanced` & `Custom` [plans](https://www.cometchat.com/pricing). If you're already on one of these plans, please enable the `Conversation & Advanced Search` from [CometChat Dashboard](https://app.cometchat.com) (Open your app, navigate to Chats -> Settings -> General Configuration) - - - - - -```javascript -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .hasReactions(true) - .build(); -``` - - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hasReactions(true) - .build(); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(UID) - .setLimit(limit) - .hasReactions(true) - .build(); -``` - - - - -```javascript -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hasReactions(true) - .build(); -``` - - - - - -## Messages with mentions - -In other words, as a logged-in user, how do I fetch messages that contains mentions? - -In order to do this, you can use the `hasMentions()` method. This method accepts boolean as input. When set to `true` , the SDK will fetch messages which have mentions. The default value for this parameter is `false`. - - - -This feature is only available with `Conversation & Advanced Search`. The `Conversation & Advanced Search` is only available in `Advanced` & `Custom` [plans](https://www.cometchat.com/pricing). If you're already on one of these plans, please enable the `Conversation & Advanced Search` from [CometChat Dashboard](https://app.cometchat.com) (Open your app, navigate to Chats -> Settings -> General Configuration) - - - - - -```javascript -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .hasMentions(true) - .build(); -``` - - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hasMentions(true) - .build(); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(UID) - .setLimit(limit) - .hasMentions(true) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hasMentions(true) - .build(); -``` - - - - - -## Messages with particular user mentions - -In other words, as a logged-in user, how do I fetch messages that mentions specific users? - -In order to do this, you can use the `setMentionedUIDs()` method. This method accepts an array of UIDs as input. When set, the SDK will fetch messages which have the mentions of the UIDs passed. - - - -This feature is only available with `Conversation & Advanced Search`. The `Conversation & Advanced Search` is only available in `Advanced` & `Custom` [plans](https://www.cometchat.com/pricing). If you're already on one of these plans, please enable the `Conversation & Advanced Search` from [CometChat Dashboard](https://app.cometchat.com) (Open your app, navigate to Chats -> Settings -> General Configuration) - - - - - -```javascript -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .setMentionedUIDs(["UID"]) - .build(); -``` - - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .setMentionedUIDs(["UID"]) - .build(); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(UID) - .setLimit(limit) - .setMentionedUIDs(["UID"]) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .setMentionedUIDs(["UID"]) - .build(); -``` - - - - - -## Messages with specific attachment types - -In other words, as a logged-in user, how do I fetch messages that contain specific types of attachments? - -In order to do this, you can use the `setAttachmentTypes()` method. This method accepts an array of `CometChat.AttachmentType` ENUM values as input. When provided, the SDK will fetch only those messages that include attachments of the specified types (such as image, audio, video, or file). - - - -This feature is only available with `Conversation & Advanced Search`. The `Conversation & Advanced Search` is only available in `Advanced` & `Custom` [plans](https://www.cometchat.com/pricing). If you're already on one of these plans, please enable the `Conversation & Advanced Search` from [CometChat Dashboard](https://app.cometchat.com) (Open your app, navigate to Chats -> Settings -> General Configuration) - - - - - -```javascript -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .setAttachmentTypes([CometChat.AttachmentType.IMAGE, CometChat.AttachmentType.VIDEO]) - .build(); -``` - - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .setAttachmentTypes([CometChat.AttachmentType.IMAGE, CometChat.AttachmentType.VIDEO]) - .build(); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(UID) - .setLimit(limit) - .setAttachmentTypes([CometChat.AttachmentType.IMAGE, CometChat.AttachmentType.VIDEO]) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .setAttachmentTypes([CometChat.AttachmentType.IMAGE, CometChat.AttachmentType.VIDEO]) - .build(); -``` - - - - diff --git a/sdk/ionic-legacy/advanced.mdx b/sdk/ionic-legacy/advanced.mdx deleted file mode 100644 index 9b295951e..000000000 --- a/sdk/ionic-legacy/advanced.mdx +++ /dev/null @@ -1,10 +0,0 @@ ---- -title: "Advanced" -sidebarTitle: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/advanced-overview) which provides full compatibility with Ionic applications. - - -This section helps you to know about the Connection Listeners. diff --git a/sdk/ionic-legacy/ai-chatbots-overview.mdx b/sdk/ionic-legacy/ai-chatbots-overview.mdx deleted file mode 100644 index a5e168a8e..000000000 --- a/sdk/ionic-legacy/ai-chatbots-overview.mdx +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: "Bots" -url: "/ai-chatbots/overview" ---- \ No newline at end of file diff --git a/sdk/ionic-legacy/ai-user-copilot-overview.mdx b/sdk/ionic-legacy/ai-user-copilot-overview.mdx deleted file mode 100644 index 3e798a3fb..000000000 --- a/sdk/ionic-legacy/ai-user-copilot-overview.mdx +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: "AI" -url: "/fundamentals/ai-user-copilot/overview" ---- \ No newline at end of file diff --git a/sdk/ionic-legacy/authentication.mdx b/sdk/ionic-legacy/authentication.mdx deleted file mode 100644 index 298a11dbe..000000000 --- a/sdk/ionic-legacy/authentication.mdx +++ /dev/null @@ -1,200 +0,0 @@ ---- -title: "Authentication" -sidebarTitle: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/authentication-overview) which provides full compatibility with Ionic applications. - - -## Create User - -Before you log in a user, you must add the user to CometChat. - -1. **For proof of concept/MVPs**: Create the user using the [CometChat Dashboard](https://app.cometchat.com). -2. **For production apps**: Use the CometChat [Create User API](https://api-explorer.cometchat.com/reference/creates-user) to create the user when your user signs up in your app. - - -Sample Users - -We have setup 5 users for testing having UIDs: `cometchat-uid-1`, `cometchat-uid-2`, `cometchat-uid-3`, `cometchat-uid-4` and `cometchat-uid-5`. - - - -Once initialization is successful, you will need to log the user into CometChat using the `login()` method. - -We recommend you call the CometChat `login` method once your user logs into your app. The `login()` method needs to be called only once. - - - -The CometChat SDK maintains the session of the logged-in user within the SDK. Thus you do not need to call the login method for every session. You can use the CometChat.getLoggedinUser() method to check if there is any existing session in the SDK. This method should return the details of the logged-in user. If this method returns null, it implies there is no session present within the SDK and you need to log the user into ComeChat. - - - -## Login using Auth Key - -This straightforward authentication method is ideal for proof-of-concept (POC) development or during the early stages of application development. For production environments, however, we strongly recommend using an [AuthToken](#login-using-auth-token) instead of an Auth Key to ensure enhanced security. - - - -```javascript -var UID = "UID"; -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 }); - } - ); - } - }, - (error) => { - console.log("Something went wrong", error); - } -); -``` - - - - -```typescript -var UID: string = "cometchat-uid-1", - authKey: string = "AUTH_KEY"; - -CometChat.getLoggedinUser().then( - (user: CometChat.User) => { - if (!user) { - CometChat.login(UID, authKey).then( - (user: CometChat.User) => { - console.log("Login Successful:", { user }); - }, - (error: CometChat.CometChatException) => { - console.log("Login failed with exception:", { error }); - } - ); - } - }, - (error: CometChat.CometChatException) => { - console.log("Some Error Occured", { error }); - } -); -``` - - - - - -| Parameters | Description | -| ---------- | ------------------------------------------------ | -| UID | The UID of the user that you would like to login | -| authKey | CometChat Auth Key | - -After the user logs in, their information is returned in the `User` object on `Promise` resolved. - -## Login using Auth Token - -This advanced authentication procedure does not use the Auth Key directly in your client code thus ensuring safety. - -1. [Create a User](https://api-explorer.cometchat.com/reference/creates-user) via the CometChat API when the user signs up in your app. -2. [Create an Auth Token](https://api-explorer.cometchat.com/reference/create-authtoken) via the CometChat API for the new user and save the token in your database. -3. Load the Auth Token in your client and pass it to the `login()` method. - - - -```javascript -var authToken = "AUTH_TOKEN"; - -CometChat.getLoggedinUser().then( - (user) => { - if (!user) { - CometChat.login(authToken).then( - (user) => { - console.log("Login Successful:", { user }); - }, - (error) => { - console.log("Login failed with exception:", { error }); - } - ); - } - }, - (error) => { - console.log("Something went wrong", error); - } -); -``` - - - - -```typescript -var authToken: string = "AUTH_TOKEN"; - -CometChat.getLoggedinUser().then( - (user: CometChat.User) => { - if (!user) { - CometChat.login(authToken).then( - (user: CometChat.User) => { - console.log("Login Successful:", { user }); - }, - (error: CometChat.CometChatException) => { - console.log("Login failed with exception:", { error }); - } - ); - } - }, - (error: CometChat.CometChatException) => { - console.log("Some Error Occured", { error }); - } -); -``` - - - - - -| Parameter | Description | -| --------- | ---------------------------------------------- | -| authToken | Auth Token of the user you would like to login | - -After the user logs in, their information is returned in the `User` object on the `Promise` resolved. - -## Logout - -You can use the `logout()` method to log out the user from CometChat. We suggest you call this method once your user has been successfully logged out from your app. - - - -```javascript -CometChat.logout().then( - () => { - console.log("Logout completed successfully"); - }, - (error) => { - console.log("Logout failed with exception:", { error }); - } -); -``` - - - - -```typescript -CometChat.logout().then( - (loggedOut: Object) => { - console.log("Logout completed successfully"); - }, - (error: CometChat.CometChatException) => { - console.log("Logout failed with exception:", { error }); - } -); -``` - - - - diff --git a/sdk/ionic-legacy/block-users.mdx b/sdk/ionic-legacy/block-users.mdx deleted file mode 100644 index 20434218b..000000000 --- a/sdk/ionic-legacy/block-users.mdx +++ /dev/null @@ -1,227 +0,0 @@ ---- -title: "Block Users" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/block-users) which provides full compatibility with Ionic applications. - - -## Block Users - -*In other words, as a logged-in user, how do I block a user from sending me messages?* - -You can block users using the `blockUsers()` method. Once any user is blocked, all the communication to and from the respective user will be completely blocked. You can block multiple users in a single operation. The `blockUsers()` method takes a `Array` as a parameter which holds the list of `UID's` to be blocked. - - - -```javascript -var usersList = ["UID1", "UID2", "UID3"]; -CometChat.blockUsers(usersList).then( -list => { - console.log("users list blocked", { list }); -}, error => { - console.log("Blocking user fails with error", error); -} -); -``` - - - - -```typescript -var usersList: String[] = ["UID1", "UID2", "UID3"]; - -CometChat.blockUsers(usersList).then( - (list: Object) => { - console.log("users list blocked", { list }); - }, (error: CometChat.CometChatException) => { - console.log("Blocking user fails with error", error); - } -); -``` - - - - - -It returns a Array which contains `UID's` as the keys and "success" or "fail" as the value based on if the block operation for the `UID` was successful or not. - -## Unblock Users - -*In other words, as a logged-in user, how do I unblock a user I previously blocked?* - -You can unblock the already blocked users using the `unblockUsers()` method. You can unblock multiple users in a single operation. The `unblockUsers()` method takes a `Array` as a parameter which holds the list of `UID's` to be unblocked. - - - -```javascript -var usersList = ["UID1", "UID2", "UID3"]; - -CometChat.unblockUsers(usersList).then( -list => { - console.log("users list unblocked", { list }); -}, error => { - console.log("unblocking user fails with error", error); -} -); -``` - - - - -```typescript -var usersList: String[] = ["UID1", "UID2", "UID3"]; - -CometChat.unblockUsers(usersList).then( - (list: Object) => { - console.log("users list blocked", { list }); - }, (error: CometChat.CometChatException) => { - console.log("Blocking user fails with error", error); - } -); -``` - - - - - -It returns a Array which contains `UID's` as the keys and `success` or `fail` as the value based on if the unblock operation for the `UID` was successful or not. - -## Get List of Blocked Users - -*In other words, as a logged-in user, how do I get a list of all users I've blocked?* - -In order to fetch the list of blocked users, you can use the `BlockedUsersRequest` class. To use this class i.e to create an object of the `BlockedUsersRequest class`, you need to use the `BlockedUsersRequestBuilder` class. The `BlockedUsersRequestBuilder` class allows you to set the parameters based on which the blocked users are to be fetched. - -The `BlockedUsersRequestBuilder` class allows you to set the below parameters: - -### Set Limit - -This method sets the limit i.e. the number of blocked users that should be fetched in a single iteration. - - - -```javascript -let limit = 30; -let blockedUsersRequest = new BlockedUsersRequest.BlockedUsersRequestBuilder() - .setLimit(limit) - .build(); -``` - - - - -```typescript -let limit: number = 30; -let blockedUsersRequest: CometChat.BlockedUsersRequest = new CometChat.BlockedUsersRequestBuilder() - .setLimit(limit) - .build(); -``` - - - - - -### Set Search Keyword - -This method allows you to set the search string based on which the blocked users are to be fetched. - - - -```javascript -let limit = 30; -let searchKeyword = "super"; -let blockedUsersRequest = new BlockedUsersRequest.BlockedUsersRequestBuilder() - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - -```typescript -let limit: number = 30; -let searchKeyword: string = "super"; -let blockedUsersRequest: CometChat.BlockedUsersRequest = new CometChat.BlockedUsersRequestBuilder() - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - - -### Set Direction - -* CometChat.BlockedUsersRequest.directions.BLOCKED\_BY\_ME - This will ensure that the list of blocked users only contains the users blocked by the logged in user. -* CometChat.BlockedUsersRequest.directions.HAS\_BLOCKED\_ME - This will ensure that the list of blocked users only contains the users that have blocked the logged in user. -* CometChat.BlockedUsersRequest.directions.BOTH - This will make sure the list of users includes both the above cases. This is the default value for the direction variable if it is not set. - - - -```javascript -let limit = 30; -let blockedUsersRequest = new BlockedUsersRequest.BlockedUsersRequestBuilder() - .setLimit(limit) - .setDirection(CometChat.BlockedUsersRequest.directions.BLOCKED_BY_ME) - .build(); -``` - - - - -```typescript -let limit: number = 30; -let blockedUsersRequest: CometChat.BlockedUsersRequest = new CometChat.BlockedUsersRequestBuilder() - .setLimit(limit) - .setDirection(CometChat.BlockedUsersRequest.directions.BLOCKED_BY_ME) - .build(); -``` - - - - - -Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the `BlockedUsersRequest` class. - -Once you have the object of the `BlockedUsersRequest` class, you need to call the `fetchNext()` method. Calling this method will return a list of `User` objects containing n number of blocked users where N is the limit set in the builder class. - - - -```javascript -var limit = 30; -var blockedUsersRequest = new CometChat.BlockedUsersRequestBuilder() - .setLimit(limit) - .build(); -blockedUsersRequest.fetchNext().then( -userList => { - console.log("Blocked user list received:", userList); -}, error => { - console.log("Blocked user list fetching failed with error:", error); -} -); -``` - - - - -```typescript -let limit: number = 30; -let blockedUsersRequest: CometChat.BlockedUsersRequest = new CometChat.BlockedUsersRequestBuilder() - .setLimit(limit) - .build(); - -blockedUsersRequest.fetchNext().then( - (userList: CometChat.User[]) => { - console.log("Blocked user list received:", userList); - }, (error: CometChat.CometChatException) => { - console.log("Blocked user list fetching failed with error:", error); - } -); -``` - - - - diff --git a/sdk/ionic-legacy/calling-overview.mdx b/sdk/ionic-legacy/calling-overview.mdx deleted file mode 100644 index e8a6060c6..000000000 --- a/sdk/ionic-legacy/calling-overview.mdx +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: "Calling" -sidebarTitle: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/calling-overview) which provides full compatibility with Ionic applications. - - -Calling is a core feature of CometChat. Calling allows users to connect over voice/video calls. - -## Prerequisites - -1. CometChat Core SDK installed. -2. Performed the steps mentioned in the [Setup](/sdk/ionic-legacy/setup#calling-component-configuration) guide - -**CometChat allows two mechanisms for calling:** - -1. **Direct Calling** -2. **Default Calling** - - - - - -## Direct Calling - -Direct Calling allows you to start the call/conference sessions directly with the session Id of your choice. All the users joining the same session Id are connected to the same call/conference. For more information on Direct Calling, please visit the [Direct Calling docs](/sdk/ionic-legacy/direct-call). - -## Default Calling - -The second approach that CometChat SDK allows is to implement the entire calling flow where one user initiates a call/conference. The other user/users who want to be a part of the call accept the call. All the users that accept the call are connected to the same session. The users also have an option to reject the call. For more information on Default Calling, please visit the [Default Calling docs](/sdk/ionic-legacy/default-call). diff --git a/sdk/ionic-legacy/calling-setup.mdx b/sdk/ionic-legacy/calling-setup.mdx deleted file mode 100644 index b6a9d1b76..000000000 --- a/sdk/ionic-legacy/calling-setup.mdx +++ /dev/null @@ -1,155 +0,0 @@ ---- -title: "Setup" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/calling-setup) which provides full compatibility with Ionic applications. - - -## Get your Application Keys - -[Signup for CometChat](https://app.cometchat.com) and then: - -1. Create a new app -2. Head over to the **Credentials** section and note the **App ID, Auth Key** & **Region** - -## Add the *CometChatCalls* Dependency - -Install the package as NPM module: - - - -```bash -npm install @cometchat/calls-sdk-ionic -``` - - - - -```bash -yarn add @cometchat/calls-sdk-ionic -``` - - - - - -## Configuration - -**Android** - -Goto `./android` folder and open **project-level** build Gradle file and add all repository URLs in the `repositories` block under the `allprojects` section. - - - -```java -allprojects { - repositories { - maven { - url "https://dl.cloudsmith.io/public/cometchat/cometchat-pro-android/maven/" - } - } -} -``` - - - - - -You also need to update the minimum SDK version to `24`. You can update the minSDKVersion in the `variables.gradle` file located in the `android` folder. - - - -```java -minSdkVersion = 24 -``` - - - - - -**iOS**: - -Please update the minimum target version in the Podfile. Goto **./ios/App** folder and open the Podfile. - - - -``` -platform :ios, '12.0' -``` - - - - - -Open the `ios/App` folder and run `pod install` this will create an `App.xcworkspace` open this and run the app. - -## Initialize CometChatCalls - -The `init()` method initialises the settings required for `CometChatCalls`. The `init()` method takes a single paramater, that is the instance of `CallAppSettings` class. - -The `CallAppSettingsBuilder` class allows you to configure three settings: - -1. **appID:** You CometChat App ID -2. **region**: The region where your app was created -3. **host:** This method takes the client URL as input and uses this client URL instead of the default client URL. This can be used in case of dedicated deployment of CometChat. - -You need to call init() before calling any other method from `CometChatCalls`. We suggest you call the init() method on app startup, preferably in the index.js file. - - - -```javascript -import { CometChatCalls } from '@cometchat/calls-sdk-ionic'; - -let appID = "APP_ID"; -let region = "REGION"; - -const callAppSetting = new CometChatCalls.CallAppSettingsBuilder() - .setAppId(appID) - .setRegion(region) - .build(); - -CometChatCalls.init(callAppSetting).then( - () => { - console.log("CometChatCalls initialization completed successfully"); - }, - (error) => { - console.log("CometChatCalls initialization failed with error:", error); - } -); -``` - - - - -```typescript -import { CometChatCalls } from '@cometchat/calls-sdk-ionic'; -import { CallAppSettings } from '@cometchat/calls-sdk-ionic/dist/models/CallAppSettings'; - -let appID: string = "APP_ID"; -let region: string = "REGION"; - -const callAppSetting: CallAppSettings = new CometChatCalls.CallAppSettingsBuilder() - .setAppId(appID) - .setRegion(region) - .build(); - -CometChatCalls.init(callAppSetting).then( - () => { - console.log("CometChatCalls initialization completed successfully"); - }, - (error) => { - console.log("CometChatCalls initialization failed with error:", error); - } -); -``` - - - - - -Make sure you replace the `APP_ID` with your CometChat **App ID** and `REGION` with your **App Region** in the above code. - -| Parameter | Description | -| ----------------- | ---------------------------------------- | -| `callAppSettings` | An object of the `CallAppSettings` class | diff --git a/sdk/ionic-legacy/changelog.mdx b/sdk/ionic-legacy/changelog.mdx deleted file mode 100644 index b83ae03ae..000000000 --- a/sdk/ionic-legacy/changelog.mdx +++ /dev/null @@ -1,12 +0,0 @@ ---- -title: "Changelog" -url: "https://github.com/cometchat/chat-sdk-ionic/releases" ---- - - -**Deprecation Notice (February 2026):** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility. - -The documentation URL has changed from `/sdk/ionic/` to `/sdk/ionic-legacy/`. All existing links will automatically redirect. - - -For the complete release history, visit the [GitHub Releases page](https://github.com/cometchat/chat-sdk-ionic/releases). \ No newline at end of file diff --git a/sdk/ionic-legacy/connection-behaviour.mdx b/sdk/ionic-legacy/connection-behaviour.mdx deleted file mode 100644 index dabb5c56b..000000000 --- a/sdk/ionic-legacy/connection-behaviour.mdx +++ /dev/null @@ -1,189 +0,0 @@ ---- -title: "Connection Behaviour" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/connection-status) which provides full compatibility with Ionic applications. - - -## Default SDK behaviour on login - -When the login method of the SDK is called, the SDK performs the below operations: - -1. Logs the user into the SDK -2. Saves the details of the logged in user locally. -3. Creates a web-socket connection for the logged in user. - -This makes sure that the logged in user starts receiving real-time messages sent to him or any groups that he is a part of as soon as he logs in. - -When the app is reopened, and the init() method is called, the web-socket connection to the server is established automatically. - -This is the default behaviour of the CometChat SDKs. However, if you wish to take control of the web-socket connection i.e if you wish to connect and disconnect to the web-socket server manually, you can refer to the Managing Web-socket Connection section. - -### Auto Mode - -CometChat SDK default connection behaviour is auto mode. Auto mode, the SDK automatically establishes and maintains the WebSocket connection. You do not need to explicitly call any methods to do this. - -To enable auto mode, you need to set the `autoEstablishSocketConnection()` method of AppSettings builder class to `true`. If you do not set this, the SDK will automatically apply the auto mode as the default behaviour for the WebSocket connection. - - - - - -| App State | Behaviour | -| ----------------- | --------------------------------------- | -| App in foreground | Connected with WebSocket | -| App in background | Immediately disconnected with WebSocket | - - - -### Reconnection[](#reconnection "Direct link to Reconnection") - -If the app is in the foreground and there is no internet connection, the SDK will handle the reconnection of the WebSocket in auto mode. - - - -## Manual Mode - -In manual mode, you have to explicitly establish and disconnect the WebSocket connection. To do this, you need to set the `autoEstablishSocketConnection()` method to `false` and then call the `CometChat.connect()` method to establish the connection and the `CometChat.disconnect()` method to disconnect the connection. - -By default, if manual mode is activated, the SDK will disconnect the WebSocket connection after 30 seconds if the app goes into the background. This means that the WebSocket connection will remain alive for 30 seconds after the app goes into the background, but it will be disconnected after that time if no pings are received. - -To keep the WebSocket connection alive even if your app goes in the background, you need to call the `CometChat.ping()` method from your app within 30 seconds. This method sends a ping message to the CometChat server, which tells the server that the app is still active. - -If you do not call the `CometChat.ping()` method within 30 seconds, the SDK will disconnect the WebSocket connection. This means that you will lose any messages that are sent to your app while it is in the background. - - - - - -| App State | Behaviour | -| ----------------- | ------------------------------------------------------------------------------------------------------------------ | -| App in foreground | Call CometChat.connect() to create the WebSocket connection | -| App in background | Disconnect the WebSocket connection if no ping is received within 30 seconds after the app goes in the background. | - -### Managing Manually - -The CometChat SDK also allows you to modify the above default behaviour of the SDK and take the control of the web-socket connection into your own hands. In order to achieve this, you need to follow the below steps: - -### Enable Manual Mode - -While calling the init() function on the app startup, you need to inform the SDK that you will be managing the web socket connect. You can do so by using the `autoEstablishSocketConnection()` method provided by the `AppSettingsBuilder` class. This method takes a boolean value as an input. If set to `true` , the SDK will manage the web-socket connection internally based on the default behaviour mentioned above. If set to `false` , the web socket connection can will not be managed by the SDK and you will have to handle it manually. You can refer to the below code snippet for the same: - - - -```javascript -let appID = "APP_ID"; -let region = "REGION"; -let appSetting = new CometChat.AppSettingsBuilder() - .subscribePresenceForAllUsers() - .setRegion(region) - .autoEstablishSocketConnection(false) - .build(); -CometChat.init(appID, appSetting).then( - () => { - console.log("Initialization completed successfully"); - }, error => { - console.log("Initialization failed with error:", error); - } -); -``` - - - - -```typescript -let appID: string = "APP_ID", - region: string = "APP_REGION", - appSetting: CometChat.AppSettings = new CometChat.AppSettingsBuilder() - .subscribePresenceForAllUsers() - .setRegion(region) - .autoEstablishSocketConnection(false) - .build(); -CometChat.init(appID, appSetting).then( -(initialized: boolean) => { - console.log("Initialization completed successfully", initialized); -}, (error: CometChat.CometChatException) => { - console.log("Initialization failed with error:", error); -} -); -``` - - - - - -You can manage the connection to the web-socket server using the `connect()` , `disconnect()` and `ping()` methods provided by the SDK. - -### Connect to the web-socket server - -You need to use the `connect()` method provided by the `CometChat` class to establish the connection to the web-socket server. Please make sure that the user is logged in to the SDK before calling this method. You can use the CometChat.getLoggedInUser() method to check this. Once the connection is established, you will start receiving all the real-time events for the logged in user - - - -```javascript -CometChat.connect({onSuccess?: Function, onError?: Function}); -``` - - - - -```typescript -CometChat.connect({onSuccess?: Function, onError?: Function}) -``` - - - - - -### Disconnect from the web-socket server - -You can use the `disconnect()` method provided by the `CometChat` class to break the established connection. Once the connection is broken, you will stop receiving all the real-time events for the logged in user. - - - -```javascript -CometChat.disconnect({onSuccess?: Function, onError?: Function}); -``` - - - - -```typescript -CometChat.disconnect({onSuccess?: Function, onError?: Function}) -``` - - - - - -### Maintain long-standing background connection - - - -To ensure that the WebSocket connection is always alive, you can create a service or background service that calls the `CometChat.ping()` method in a loop. This will ensure that the ping message is sent to the server every 30 seconds, even if the app is not in the foreground. - - - -You can maintain a long-standing background connection event when your app is in the background, call the `CometChat.ping()` method within 30 seconds of your app entering the background or after the previous ping() call. - - - -```javascript -CometChat.ping({onSuccess?: Function, onError?: Function}); -``` - - - - -```typescript -CometChat.ping({onSuccess?: Function, onError?: Function}) -``` - - - - - -### Reconnection - -If manual mode is enabled and the app is in the foreground, the SDK will automatically reconnect the WebSocket if the internet connection is lost. However, if the app is in the background and the WebSocket is disconnected or you called `CometChat.disconnect()`, then you will need to call the `CometChat.connect()` method to create a new WebSocket connection. diff --git a/sdk/ionic-legacy/connection-status.mdx b/sdk/ionic-legacy/connection-status.mdx deleted file mode 100644 index e71fc42bf..000000000 --- a/sdk/ionic-legacy/connection-status.mdx +++ /dev/null @@ -1,106 +0,0 @@ ---- -title: "Connection Status" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/connection-status) which provides full compatibility with Ionic applications. - - -CometChat SDK provides you with a mechanism to get real-time status of the connection to CometChat web-socket servers. - -Connection Status provides you with the below 3 methods to get the status of the connection to CometChat web-socket servers: - -| Delegate Method | Information | -| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ | -| inConnecting | This method is triggered when CometChat SDK is trying to establish a connection to the web-socket server. | -| onConnected | This method is called when CometChat SDK has successfully established a connection and is now connected. | -| onDisconnected | This method is called when the CometChat SDK gets disconnected due to any issue while maintaining the connection like network fluctuations, etc. | -| onFeatureThrottled | CometChat automatically toggles off certain features to prevent performance loss for end-users under various circumstances. | -| onConnectionError | This method is called when the CometChat SDK encounters an error while maintaining the connection, such as network fluctuations, etc. | - -Once the connection is broken, the disconnected callback is triggered, the SDK automatically tries to establish the connection again, thus going into the connecting state and triggering the `connecting` method. Once the attempt to connect is successful, the `connected` method is triggered thus letting the developer know that the connection is established and is active. - -To receive real-time connection status, you need to register `ConnectionListener` wherever you wish to receive the real-time status. You can use the `addConnectionListener()` method to do so. - - - -```javascript -var listenerID = "UNIQUE_LISTENER_ID"; -CometChat.addConnectionListener( - listenerID, - new CometChat.ConnectionListener({ - onConnected: () => { - console.log("ConnectionListener => On Connected"); - }, - inConnecting: () => { - console.log("ConnectionListener => In connecting"); - }, - onDisconnected: () => { - console.log("ConnectionListener => On Disconnected"); - }, - onFeatureThrottled: () => { - console.log("ConnectionListener => On Feature Throttled"); - }, - onConnectionError: () => { - console.log("ConnectionListener => On Connection Error"); - }, - }) -); -``` - - - - -```typescript -let listenerID: string = "UNIQUE_LISTENER_ID"; -CometChat.addConnectionListener( - listenerID, - new CometChat.ConnectionListener({ - onConnected: () => { - console.log("ConnectionListener => On Connected"); - }, - inConnecting: () => { - console.log("ConnectionListener => In connecting"); - }, - onDisconnected: () => { - console.log("ConnectionListener => On Disconnected"); - }, - }) -); -``` - - - - - - - -We recommend you to add the Connection Listener in your method on app startup, preferably in the index.js file. Once you have successfully initialized CometChat. - - - -You can also get the current connection status by using `getConnectionStatus` property provided by CometChat SDK - - - -```javascript -var connectionStatus = CometChat.getConnectionStatus(); -``` - - - - -```typescript -var connectionStatus: string = CometChat.getConnectionStatus(); -``` - - - - - -The `CometChat.getConnectionStatus` method will return either of the below 4 values: - -1. `CometChat.CONNECTION_STATUS.CONNECTED` (connected) -2. `CometChat.CONNECTION_STATUS.CONNECTING` (connecting) -3. `CometChat.CONNECTION_STATUS.DISCONNECTED` (disconnected) -4. `CometChat.CONNECTION_STATUS.FEATURE_THROTTLED `(featureThrottled) diff --git a/sdk/ionic-legacy/create-group.mdx b/sdk/ionic-legacy/create-group.mdx deleted file mode 100644 index f26eed9f9..000000000 --- a/sdk/ionic-legacy/create-group.mdx +++ /dev/null @@ -1,175 +0,0 @@ ---- -title: "Create A Group" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/create-group) which provides full compatibility with Ionic applications. - - -## Create a Group - -*In other words, as a logged-in user, how do I create a public, private or password-protected group?* - -You can create a group using `createGroup()` method. This method takes a `Group` object as input. - -To create an object of `Group` class, you can use either of the below two constructors: - -1. `new Group(String GUID, String name, String groupType, String password)` -2. `new Group(String GUID, String name, String groupType, String password, String icon, String description)` - -The `groupType` needs to be either of the below 3 values: - -1.`CometChatConstants.GROUP_TYPE_PUBLIC` (public) - -2.`CometChatConstants.GROUP_TYPE_PASSWORD` (password) - -3.`CometChatConstants.GROUP_TYPE_PRIVATE` (private) - - - -```javascript -var GUID = "GUID"; -var groupName = "Hello Group!"; -var groupType = CometChat.GROUP_TYPE.PUBLIC; -var password = ""; - -var group = new CometChat.Group(GUID, groupName, groupType, password); - -CometChat.createGroup(group).then( - group => { - console.log("Group created successfully:", group); - }, error => { - console.log("Group creation failed with exception:", error); - } -); -``` - - - - -```typescript -var GUID: string = "GUID"; -var groupName: string = "Hello Group!"; -var groupType: string = CometChat.GROUP_TYPE.PUBLIC; -var password: string = ""; - -var group: CometChat.Group = new CometChat.Group(GUID, groupName, groupType, password); - -CometChat.createGroup(group).then( - (group: CometChat.Group) => { - console.log("Group created successfully:", group); - }, (error: CometChat.CometChatException) => { - console.log("Group creation failed with exception:", error); - } -); -``` - - - - - -The createGroup() method takes the following parameters: - -| Parameter | Description | -| --------- | ---------------------------- | -| `group` | An instance of `Group` class | - -After successful creation of the group, you will receive an instance of `Group` class which contains all the information about the particular group. - - - -GUID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed. - - - -## Add members while creating a group - -You can create a group and add members at the same time using the `createGroupWithMembers()` method. This method takes the `Group` Object, Array of `Group Member` Object to be added & Array of `UIDs` to be banned. - -To create an object of `Group` class, you can use either of the below two constructors: - -1. `new Group(String GUID, String name, String groupType, String password)` -2. `new Group(String GUID, String name, String groupType, String password, String icon, String description)` - -The `groupType` needs to be either of the below 3 values: - -1. `CometChat.GROUP_TYPE.PUBLIC` -2. `CometChat.GROUP_TYPE.PASSWORD` -3. `CometChat.GROUP_TYPE.PRIVATE` - -To create an object of `Group Member` class, you can use the below constructor: - -* new CometChat.GroupMember(String UID, String scope) - - - -```javascript -let GUID = "cometchat-guid-11"; -let UID = "cometchat-uid-1"; -let groupName = "Hello Group!"; -let groupType = CometChat.GROUP_TYPE.PUBLIC; - -let group = new CometChat.Group(GUID, groupName, groupType); -let members = [ -new CometChat.GroupMember(UID, CometChat.GROUP_MEMBER_SCOPE.PARTICIPANT) -]; -let banMembers = ["cometchat-uid-2"]; - -CometChat.createGroupWithMembers(group, members, banMembers).then( - response => { - console.log("Group created successfully", response); - }, error => { - console.log("Some error occured while creating group", error) - } -); -``` - - - - -```typescript -let GUID: string = "cometchat-guid-11"; -let UID: string = "cometchat-uid-1"; -let groupName: string = "Hello Group!"; -let groupType: string = CometChat.GROUP_TYPE.PUBLIC; - -let group: CometChat.Group = new CometChat.Group(GUID, groupName, groupType); -let members: Array = [ -new CometChat.GroupMember(UID, CometChat.GROUP_MEMBER_SCOPE.PARTICIPANT) -]; -let banMembers: Array = ["cometchat-uid-2"]; - -CometChat.createGroupWithMembers(group, members, banMembers).then( - (response: Object) => { - console.log("Group created successfully", response); - }, (error: CometChat.CometChatException) => { - console.log("Some error occured while creating group", error) - } -); -``` - - - - - -This method returns an Object which has two keys: `group` & `members` . The group key has the Group Object which contains all the information of the group which is created. The members key has the `UID` of the users and the value will either be `success` or an `error` message describing why the operation to add/ban the user failed. - -## Group Class - -| Field | Editable | Information | -| ------------ | --------------------------------------------------------------- | ------------------------------------------------------------------------- | -| guid | Needs to be specified at group creation. Cannot be edited later | A unique identifier for a group | -| name | Yes | Name of the group | -| type | No | Type of the group: Can be 1. Public 2. Password 3. Private | -| password | No | Password for the group in case the group is of type password. | -| icon | Yes | An URL to group icon | -| description | Yes | Description about the group | -| owner | Yes | UID of the owner of the group. | -| metadata | Yes | Additional data for the group as JSON | -| createdAt | No | The unix timestamp of the time the group was created | -| updatedAt | No | The unix timestamp of the time the group was last updated | -| hasJoined | No | A boolean to determine if the logged in user is a member of the group. | -| joinedAt | No | The unix timestamp of the time the logged in user joined the group. | -| scope | Yes | Scope of the logged in user. Can be: 1. Admin 2. Moderator 3. Participant | -| membersCount | No | The number of members in the groups | -| tags | Yes | A list of tags to identify specific groups. | diff --git a/sdk/ionic-legacy/default-call.mdx b/sdk/ionic-legacy/default-call.mdx deleted file mode 100644 index 7878d8333..000000000 --- a/sdk/ionic-legacy/default-call.mdx +++ /dev/null @@ -1,365 +0,0 @@ ---- -title: "Default Calling" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/default-call) which provides full compatibility with Ionic applications. - - -This section will provide information on how a complete calling workflow can be set up using the CometChat SDK. We've built the complete workflow to help your users make calls, receive calls as well as accept/reject calls. - -Let us assume Alex to be the call initiator and Bob is the receiver. - -1. Alex initiates the call to Bob using the [initiateCall()](#initiate-call) method. -2. Bob now has two choices: - -* Accept the call from Alex using the [acceptCall()](#accept-the-incoming-call) method. -* Reject the call from Alex using the [rejectCall()](#reject-the-incoming-call) method passing the status as `rejected`. - -5. In the meantime, Alex has the option to cancel the call he initiated to Bob using the [rejectCall()](#cancel-the-outgoing-call) method passing the status as `cancelled`. -6. If Bob accepts the call from Alex, both Alex and Bob need to call the [startSession()](/sdk/ionic-legacy/direct-call#start-call-session) method. Alex in the **onOutgoingCallAccepted()** method of the `CallListener` and Bob in the success obtained from the **acceptCall()** method and both will be connected to each other. - -## Initiate Call - -The `initiateCall()` method sends a call request to a user or a group. - - - -```javascript -var receiverID = "UID"; -var callType = CometChat.CALL_TYPE.VIDEO; -var receiverType = CometChat.RECEIVER_TYPE.USER; - -var call = new CometChat.Call(receiverID, callType, receiverType); - -CometChat.initiateCall(call).then( - (outGoingCall) => { - console.log("Call initiated successfully:", outGoingCall); - // perform action on success. Like show your calling screen. - }, - (error) => { - console.log("Call initialization failed with exception:", error); - } -); -``` - - - - -```javascript -var receiverID = "GUID"; -var callType = CometChat.CALL_TYPE.VIDEO; -var receiverType = CometChat.RECEIVER_TYPE.GROUP; - -var call = new CometChat.Call(receiverID, callType, receiverType); - -CometChat.initiateCall(call).then( - (outGoingCall) => { - console.log("Call initiated successfully:", outGoingCall); - // perform action on success. Like show your calling screen. - }, - (error) => { - console.log("Call initialization failed with exception:", error); - } -); -``` - - - - -```typescript -var receiverID: string = "UID"; -var callType: string = CometChat.CALL_TYPE.VIDEO; -var receiverType: string = CometChat.RECEIVER_TYPE.USER; - -var call: CometChat.Call = new CometChat.Call( - receiverID, - callType, - receiverType -); - -CometChat.initiateCall(call).then( - (outGoingCall: CometChat.Call) => { - console.log("Call initiated successfully:", outGoingCall); - }, - (error: CometChat.CometChatException) => { - console.log("Call initialization failed with exception:", error); - } -); -``` - - - - -```typescript -var receiverID: string = "GUID"; -var callType: string = CometChat.CALL_TYPE.VIDEO; -var receiverType: string = CometChat.RECEIVER_TYPE.GROUP; - -var call: CometChat.Call = new CometChat.Call( - receiverID, - callType, - receiverType -); - -CometChat.initiateCall(call).then( - (outGoingCall: CometChat.Call) => { - console.log("Call initiated successfully:", outGoingCall); - }, - (error: CometChat.CometChatException) => { - console.log("Call initialization failed with exception:", error); - } -); -``` - - - - - -This method takes an object of the `Call` class. The constructor for `Call` class takes the following parameters: - -| Parameter | Description | -| ------------ | ------------------------------------------------------------------------------------------------- | -| receiverID | The UID or GUID of the recipient | -| receiverType | The type of the receiver can be, 1.CometChat.RECEIVER\_TYPE.USER 2.CometChat.RECEIVER\_TYPE.GROUP | -| callType | The type of call can be, 1.CometChat.CALL\_TYPE.AUDIO 2.CometChat.CALL\_TYPE.VIDEO | - -On successful initialization, a `Call` object is returned with the details of the call including a unique session ID for the call. - -## Receive Calls - -Wherever you wish to receive the call events in, you need to register the `CallListener` listener using the `addCallListener()` method. `onCallEndedMessageReceived()` event will receive when you trigger CometChat.endCall(sessionID). - - - -```javascript -var listnerID = "UNIQUE_LISTENER_ID"; -CometChat.addCallListener( - listnerID, - new CometChat.CallListener({ - onIncomingCallReceived: (call) => { - console.log("Incoming call:", call); - // Handle incoming call - }, - onOutgoingCallAccepted: (call) => { - console.log("Outgoing call accepted:", call); - // Outgoing Call Accepted - }, - onOutgoingCallRejected: (call) => { - console.log("Outgoing call rejected:", call); - // Outgoing Call Rejected - }, - onIncomingCallCancelled: (call) => { - console.log("Incoming call calcelled:", call); - }, - onCallEndedMessageReceived: (call) => { - console.log("CallEnded Message:", call); - }, - }) -); -``` - - - - -```typescript -var listnerID: string = "UNIQUE_LISTENER_ID"; -CometChat.addCallListener( - listnerID, - new CometChat.CallListener({ - onIncomingCallReceived: (call: CometChat.Call) => { - console.log("Incoming call:", call); - }, - onOutgoingCallAccepted: (call: CometChat.Call) => { - console.log("Outgoing call accepted:", call); - }, - onOutgoingCallRejected: (call: CometChat.Call) => { - console.log("Outgoing call rejected:", call); - }, - onIncomingCallCancelled: (call: CometChat.Call) => { - console.log("Incoming call calcelled:", call); - }, - onCallEndedMessageReceived: (call: CometChat.Call) => { - console.log("CallEnded Message:", call); - }, - }) -); -``` - - - - - -| Parameter | Description | -| ---------- | ---------------------------------------------------------------------------------------------- | -| listenerID | An ID that uniquely identifies that listener. We recommend using the activity or fragment name | - -We recommend you remove the listener once the activity or fragment is not in use. - - - -```javascript -var listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.removeCallListener(listenerID); -``` - - - - -```typescript -var listenerID: string = "UNIQUE_LISTENER_ID"; - -CometChat.removeCallListener(listenerID); -``` - - - - - -As mentioned in the [Overview](/sdk/ionic-legacy/overview) section, Once the call is initiated, there are three options that can be possible: - -1. The receiver of the call accepts the call. -2. The receiver of the call rejects the call. -3. The initiator of the call cancels the call. - -Please find below how these three scenarios can be implemented: - -### Accept the Incoming Call - -Once you have received an incoming call from a user or in any group, to accept the call using the `acceptCall()` method. - - - -```javascript -var sessionID = "SESSION_ID"; - -CometChat.acceptCall(sessionID).then( - (call) => { - console.log("Call accepted successfully:", call); - }, - (error) => { - console.log("Call acceptance failed with error", error); - } -); -``` - - - - -```typescript -var sessionID: string = "SESSION_ID"; - -CometChat.acceptCall(sessionID).then( - (call: CometChat.Call) => { - console.log("Call accepted successfully:", call); - }, - (error: CometChat.CometChatException) => { - console.log("Call acceptance failed with error", error); - } -); -``` - - - - - -| Parameter | Description | -| ----------- | ---------------------------------------------------- | -| `sessionID` | The unique session ID available in the `Call` object | - -### Reject the Incoming Call - -As the call is being rejected by the receiver of the call, you need to pass the status as `CometChat.CALL_STATUS.REJECTED` to the `rejectCall()` method. - - - -```javascript -var sessionID = "SESSION_ID"; -var status = CometChat.CALL_STATUS.REJECTED; - -CometChat.rejectCall(sessionID, status).then( - (call) => { - console.log("Call rejected successfully", call); - }, - (error) => { - console.log("Call rejection failed with error:", error); - } -); -``` - - - - -```typescript -var sessionID: string = "SESSION_ID"; -var status: string = CometChat.CALL_STATUS.REJECTED; - -CometChat.rejectCall(sessionID, status).then( - (call: CometChat.Call) => { - console.log("Call rejected successfully", call); - }, - (error: CometChat.CometChatException) => { - console.log("Call rejection failed with error:", error); - } -); -``` - - - - - -| Parameter | Description | -| ----------- | ----------------------------------------------------- | -| `sessionID` | The unique session ID available in the `Call` object. | -| `status` | Reason for rejection of the call. | - -### Cancel the Outgoing Call - -As the call is being canceled by the initiator of the call, you need to pass the status as `CometChat.CALL_STATUS.CANCELLED` to the `rejectCall()` method. - - - -```javascript -var sessionID = "SESSION_ID"; -var status = CometChat.CALL_STATUS.CANCELLED; - -CometChat.rejectCall(sessionID, status).then( - (call) => { - console.log("Call canceled successfully", call); - }, - (error) => { - console.log("Call cancelation failed with error:", error); - } -); -``` - - - - -```typescript -var sessionID: string = "SESSION_ID"; -var status: string = CometChat.CALL_STATUS.CANCELLED; - -CometChat.rejectCall(sessionID, status).then( - (call: CometChat.Call) => { - console.log("Call canceled successfully", call); - }, - (error: CometChat.CometChatException) => { - console.log("Call cancelation failed with error:", error); - } -); -``` - - - - - -| Parameter | Description | -| ----------- | ----------------------------------------------------- | -| `sessionID` | The unique session ID available in the `Call` object. | -| `status` | Reason for rejection of the call. | - -## Start a Call - -Once the call request is sent and the receiver has accepted the call, both the initiator and the receiver need to call the [startSession()](/sdk/ionic-legacy/direct-call#start-call-session) method. diff --git a/sdk/ionic-legacy/delete-conversation.mdx b/sdk/ionic-legacy/delete-conversation.mdx deleted file mode 100644 index 7ebe248b6..000000000 --- a/sdk/ionic-legacy/delete-conversation.mdx +++ /dev/null @@ -1,83 +0,0 @@ ---- -title: "Delete A Conversation" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/delete-conversation) which provides full compatibility with Ionic applications. - - -In case you want to delete a conversation, you can use the `deleteConversation()` method. - -This method takes two parameters. The unique id (UID/GUID) of the conversation to be deleted & the type (user/group) of conversation to be deleted. - - - -```javascript -let UID = "UID"; -let type = "user"; -CometChat.deleteConversation(UID, type).then( - deletedConversation => { - console.log(deletedConversation); - }, error => { - console.log('error while deleting a conversation', error); - } -); -``` - - - - -```javascript -let GUID = "GUID"; -let type = "group"; -CometChat.deleteConversation(GUID, type).then( - deletedConversation => { - console.log(deletedConversation); - }, error => { - console.log('error while deleting a conversation', error); - } -); -``` - - - - -```typescript -let UID: string = "UID"; -let type: string = "user"; -CometChat.deleteConversation(UID, type).then( - (deletedConversation: string) => { - console.log(deletedConversation); - }, (error: CometChat.CometChatException) => { - console.log('error while deleting a conversation', error); - } -); -``` - - - - -```typescript -let GUID: string = "GUID"; -let type: string = "group"; -CometChat.deleteConversation(GUID, type).then( - (deletedConversation: string) => { - console.log(deletedConversation); - }, (error: CometChat.CometChatException) => { - console.log('error while deleting a conversation', error); - } -); -``` - - - - - -This method deletes the conversation only for the logged-in user. To delete a conversation for all the users of the conversation, please refer to our REST API documentation [here](https://api-explorer.cometchat.com/reference/deletes-conversation). - -The `deleteConversation()` method takes the following parameters: - -| Parameter | Description | Required | -| ---------------- | --------------------------------------------------------------------------------- | -------- | -| conversationWith | `UID` of the user or `GUID` of the group whose conversation you want to delete. | YES | -| conversationType | The type of conversation you want to delete . It can be either `user` or `group`. | YES | diff --git a/sdk/ionic-legacy/delete-group.mdx b/sdk/ionic-legacy/delete-group.mdx deleted file mode 100644 index 454555dcc..000000000 --- a/sdk/ionic-legacy/delete-group.mdx +++ /dev/null @@ -1,50 +0,0 @@ ---- -title: "Delete A Group" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/delete-group) which provides full compatibility with Ionic applications. - - -## Delete a Group - -To delete a group you need to use the `deleteGroup()` method. The user must be an `Admin` of the group they are trying to delete. - - - -```javascript -var GUID = "GUID"; - -CometChat.deleteGroup(GUID).then( -response => { - console.log("Groups deleted successfully:", response); -}, error => { - console.log("Group delete failed with exception:", error); -} -); -``` - - - - -```typescript -var GUID: string = "GUID"; - -CometChat.deleteGroup(GUID).then( - (response: boolean) => { - console.log("Group deleted successfully:", response); - }, (error: CometChat.CometChatException) => { - console.log("Group delete failed with exception:", error); - } -); -``` - - - - - -The `deleteGroup()` method takes the following parameters: - -| Parameter | Description | -| --------- | ---------------------------------------------- | -| `GUID` | The GUID of the group you would like to delete | diff --git a/sdk/ionic-legacy/delete-message.mdx b/sdk/ionic-legacy/delete-message.mdx deleted file mode 100644 index 243d92bc1..000000000 --- a/sdk/ionic-legacy/delete-message.mdx +++ /dev/null @@ -1,122 +0,0 @@ ---- -title: "Delete A Message" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/delete-message) which provides full compatibility with Ionic applications. - - -While [deleting a message](/sdk/ionic-legacy/delete-message#delete-a-message) is straightforward, receiving events for deleted messages with CometChat has two parts: - -1. Adding a listener to receive [real-time message deletes](/sdk/ionic-legacy/delete-message#real-time-message-delete-events) when your app is running. -2. Calling a method to retrieve [missed message deletes](/sdk/ionic-legacy/delete-message#missed-message-delete-events) when your app was not running. - -## Delete a Message - -*In other words, as a sender, how do I delete a message?* - -In case you have to delete a message, you can use the `deleteMessage()` method. This method takes the message ID of the message to be deleted. - - - -```javascript -let messageId = "ID_OF_THE_MESSAGE_YOU_WANT_TO_DELETE"; - -CometChat.deleteMessage(messageId).then( -message => { - console.log("Message deleted", message); -}, error => { - console.log("Message delete failed with error:", error); -} -); -``` - - - - -```typescript -let messageId: number = 1; - -CometChat.deleteMessage(messageId).then( - (message: CometChat.BaseMessage) => { - console.log("Message deleted", message); - }, (error: CometChat.CometChatException) => { - console.log("Message delete failed with error:", error); - } -); -``` - - - - - -Once the message is deleted, In the `onSuccess()` callback, you get an object of the `BaseMessage` class, with the `deletedAt` field set with the timestamp of the time the message was deleted. Also, the `deletedBy` field is set. These two fields can be used to identify if the message is deleted while iterating through a list of messages. - -By default, CometChat allows certain roles to delete a message. - -| User Role | Conversation Type | Deletion Capabilities | -| --------------- | ----------------------- | ------------------------------ | -| Message Sender | One-on-One Conversation | Messages they have sent. | -| Message Sender | Group Conversation | Messages they have sent. | -| Group Admin | Group Conversation | All the messages in the group. | -| Group Moderator | Group Conversation | All the messages in the group. | - -## Real-time Message Delete Events - -*In other words, as a recipient, how do I know when someone deletes a message when my app is running?* - -In order to receive real-time events for a message being deleted, you need to override the `onMessageDeleted()` method of the `MessageListener` class. - - - -```javascript -var listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener( -listenerID, -new CometChat.MessageListener({ - onMessageDeleted: message => { - console.log("Deleted Message", message); - } -}) -); -``` - - - - -```typescript -let listenerID: string = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener( - listenerID, - new CometChat.MessageListener({ - onMessageDeleted: (message: CometChat.BaseMessage) => { - console.log("Deleted Message", message); - } - }) -); -``` - - - - - -## Missed Message Delete Events - -*In other words, as a recipient, how do I know if someone deleted a message when my app was not running?* - -When you retrieve the list of previous messages, for the messages that were deleted, the `deletedAt` and the `deletedBy` fields will be set. Also, for example, of the total number of messages for a conversation are 100, and the message with message ID 50 was deleted. Now the message with id 50 will have the `deletedAt` and the `deletedBy` fields set whenever it is pulled from the history. Also, the 101st message will be and Action message informing you that the message with id 50 has been deleted. - -For the message deleted event, in the `Action` object received, the following fields can help you get the relevant information- - -1. `action` - `deleted` -2. `actionOn` - Updated message object which was deleted. -3. `actionBy` - User object containing the details of the user who has deleted the message. -4. `actionFor` - User/group object having the details of the receiver to which the message was sent. - - - -In order to edit or delete a message you need to be either the sender of the message or the admin/moderator of the group in which the message was sent. - - diff --git a/sdk/ionic-legacy/delivery-read-receipts.mdx b/sdk/ionic-legacy/delivery-read-receipts.mdx deleted file mode 100644 index 86f903951..000000000 --- a/sdk/ionic-legacy/delivery-read-receipts.mdx +++ /dev/null @@ -1,637 +0,0 @@ ---- -title: "Delivery & Read Receipts" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/delivery-read-receipts) which provides full compatibility with Ionic applications. - - -## Mark Messages as Delivered - -*In other words, as a recipient, how do I inform the sender that I've received a message?* - -You can mark the messages for a particular conversation as read using the `markAsDelivered()` method. This method takes the below parameters as input: - -| Parameter | Information | -| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `messageId` | The ID of the message above which all the messages for a particular conversation are to be marked as read. | -| `receiverId` | In case of one to one conversation message's sender `UID` will be the receipt's receiver Id. In case of group conversation message's receiver Id will be the receipt's receiver Id. | -| `receiverType` | Type of the receiver. Could be either of the two values( user or group). | -| `senderId` | The `UID` of the sender of the message. | - -Messages for both user & group conversations can be marked as read using this method. - -Ideally, you would like to mark all the messages as delivered for any conversation when the user opens the chat window for that conversation. This includes two scenarios: - -1. **When the list of messages for the conversation is fetched**: In this case you need to obtain the last message in the list of messages and pass the message ID of that message to the markAsDelivered() method. -2. **When the user is on the chat window and a real-time message is received:** In this case you need to obtain the message ID of the message and pass it to the markAsDelivered() method. - - - -```javascript -var messageId = "MESSAGE_ID"; -var receiverId = "MESSAGE_RECEIVER_UID"; -var receiverType = "user"; -var senderId = "MESSAGE_SENDER_UID"; -CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId); -``` - - - - -```javascript -var messageId = "MESSAGE_ID"; -var receiverId = "MESSAGE_RECEIVER_GUID"; -var receiverType = "group"; -var senderId = "MESSAGE_SENDER_UID"; -CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId); -``` - - - - -```typescript -var messageId: string = "MESSAGE_ID"; -var receiverId: string = "MESSAGE_RECEIVER_UID"; -var receiverType: string = "user"; -var senderId: string = "MESSAGE_SENDER_UID"; -CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId); -``` - - - - -```typescript -var messageId: string = "MESSAGE_ID"; -var receiverId: string = "MESSAGE_RECEIVER_GUID"; -var receiverType: string = "group"; -var senderId: string = "MESSAGE_SENDER_UID"; -CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId); -``` - - - - - -This method will mark all the messages before the messageId specified, for the conversation with receiverId and receiverType(user/group) as delivered. - -In case you would like to be notified of an error if the receipts fail to go through you can use `.then(successCallback, failureCallback)` of the `markAsDelivered` method. - - - -```javascript -CometChat.markAsDelivered( - message.getId(), - message.getSender().getUid(), - "user", - message.getSender().getUid() -).then( - () => { - console.log("mark as delivered success."); - }, - (error) => { - console.log( - "An error occurred when marking the message as delivered.", - error - ); - } -); -``` - - - - -```javascript -CometChat.markAsDelivered( - message.getId(), - message.getReceiverUid(), - "group", - message.getSender().getUid() -).then( - () => { - console.log("mark as delivered success."); - }, - (error) => { - console.log( - "An error occurred when marking the message as delivered.", - error - ); - } -); -``` - - - - -```typescript -var messageId: string = "MESSAGE_ID"; -var receiverId: string = "MESSAGE_SENDER_UID"; -var receiverType: string = "user"; -var senderId: string = "MESSAGE_SENDER_UID"; -CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId).then( - () => { - console.log("mark as delivered success."); - }, - (error: CometChat.CometChatException) => { - console.log( - "An error occurred when marking the message as delivered.", - error - ); - } -); -``` - - - - -```typescript -var messageId: string = "MESSAGE_ID"; -var receiverId: string = "MESSAGE_RECEIVER_GUID"; -var receiverType: string = "group"; -var senderId: string = "MESSAGE_SENDER_UID"; -CometChat.markAsDelivered(messageId, receiverId, receiverType, senderId).then( - () => { - console.log("mark as delivered success."); - }, - (error: CometChat.CometChatException) => { - console.log( - "An error occurred when marking the message as delivered.", - error - ); - } -); -``` - - - - - -Another option the CometChat SDK provides is to pass the entire message object to the markAsDelivered() method. - - - -```javascript -CometChat.markAsDelivered(message); -``` - - - - -```typescript -let message: CometChat.BaseMessage; -CometChat.markAsDelivered(message); -``` - - - - - -In case you would like to be notified of an error if the receipts fail to go through you can use `.then(successCallback, failureCallback)` of the `markAsDelivered` method. - - - -```javascript -CometChat.markAsDelivered(message).then( - () => { - console.log("mark as delivered success."); - }, - (error) => { - console.log( - "An error occurred when marking the message as delivered.", - error - ); - } -); -``` - - - - -```typescript -let message: CometChat.BaseMessage; -CometChat.markAsDelivered(message).then( - () => { - console.log("mark as delivered success."); - }, - (error: CometChat.CometChatException) => { - console.log( - "An error occurred when marking the message as delivered.", - error - ); - } -); -``` - - - - - -## Mark Messages as Read - -*In other words, as a recipient, how do I inform the sender I've read a message?* - -You can mark the messages for a particular conversation as read using the `markAsRead()` method. This method takes the below parameters as input: - -| Parameter | Information | -| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `messageId` | The ID of the message above which all the messages for a particular conversation are to be marked as read. | -| `receiverId` | In case of one to one conversation message's sender `UID` will be the receipt's receiver Id. In case of group conversation message's receiver Id will be the receipt's receiver Id | -| `receiverType` | Type of the receiver. Could be either of the two values( user or group) | -| `senderId` | The `UID` of the sender of the message. | - -Messages for both user and group conversations can be marked as read using this method. - -Ideally, you would like to mark all the messages as read for any conversation when the user opens the chat window for that conversation. This includes two scenarios: - -1. **When the list of messages for the conversation is fetched**: In this case you need to obtain the last message in the list of messages and pass the message ID of that message to the markAsRead() method. -2. **When the user is on the chat window and a real-time message is received:** In this case you need to obtain the message ID of the message and pass it to the markAsRead() method - - - -```javascript -var messageId = "MESSAGE_ID"; -var receiverId = "MESSAGE_SENDER_UID"; -var receiverType = "user"; -var senderId = "MESSAGE_SENDER_UID"; -CometChat.markAsRead(messageId, receiverId, receiverType, senderId); -``` - - - - -```javascript -var messageId = "MESSAGE_ID"; -var receiverId = "MESSAGE_RECEIVER_GUID"; -var receiverType = "group"; -var senderId = "MESSAGE_SENDER_UID"; -CometChat.markAsRead(messageId, receiverId, receiverType, senderId); -``` - - - - -```typescript -var messageId: string = "MESSAGE_ID"; -var receiverId: string = "MESSAGE_SENDER_UID"; -var receiverType: string = "user"; -var senderId: string = "MESSAGE_SENDER_UID"; -CometChat.markAsRead(messageId, receiverId, receiverType, senderId); -``` - - - - -```typescript -var messageId: string = "MESSAGE_ID"; -var receiverId: string = "MESSAGE_RECEIVER_GUID"; -var receiverType: string = "group"; -var senderId: string = "MESSAGE_SENDER_UID"; -CometChat.markAsRead(messageId, receiverId, receiverType, senderId); -``` - - - - - -This method will mark all the messages before the messageId specified, for the conversation with receiverId and receiverType(user/group) as read. - -In case you would like to be notified of an error if the receipts fail to go through you can use `.then(successCallback, failureCallback)` of the `markAsDelivered` method. - - - -```javascript -CometChat.markAsRead( - message.getId(), - message.getSender().getUid(), - "user", - message.getSender().getUid() -).then( - () => { - console.log("mark as read success."); - }, - (error) => { - console.log("An error occurred when marking the message as read.", error); - } -); -``` - - - - -```javascript -CometChat.markAsRead( - message.getId(), - message.getReceiverUid(), - "group", - message.getSender().getUid() -).then( - () => { - console.log("mark as read success."); - }, - (error) => { - console.log("An error occurred when marking the message as read.", error); - } -); -``` - - - - -```typescript -var messageId: string = "MESSAGE_ID"; -var receiverId: string = "MESSAGE_SENDER_UID"; -var receiverType: string = "user"; -var senderId: string = "MESSAGE_SENDER_UID"; -CometChat.markAsRead(messageId, receiverId, receiverType, senderId).then( - () => { - console.log("mark as read success."); - }, - (error: CometChat.CometChatException) => { - console.log("An error occurred when marking the message as read.", error); - } -); -``` - - - - -```typescript -var messageId: string = "MESSAGE_ID"; -var receiverId: string = "MESSAGE_RECEIVER_GUID"; -var receiverType: string = "group"; -var senderId: string = "MESSAGE_SENDER_UID"; -CometChat.markAsRead(messageId, receiverId, receiverType, senderId).then( - () => { - console.log("mark as read success."); - }, - (error: CometChat.CometChatException) => { - console.log("An error occurred when marking the message as read.", error); - } -); -``` - - - - - -Another option the CometChat SDK provides is to pass the entire message object to the markAsRead() method.If the message object is the last message, the entire conversation will be marked as read. - - - -```javascript -CometChat.markAsRead(message); -``` - - - - -```typescript -let message: CometChat.BaseMessage; -CometChat.markAsRead(message); -``` - - - - - -In case you would like to be notified of an error if the receipts fail to go through you can use `.then(successCallback, failureCallback)` of the `markAsDelivered` method. - - - -```javascript -CometChat.markAsRead(message).then( - () => { - console.log("mark as read success."); - }, - (error) => { - console.log("An error occurred when marking the message as read.", error); - } -); -``` - - - - -```typescript -let message: CometChat.BaseMessage; -CometChat.markAsRead(message).then( - () => { - console.log("mark as read success."); - }, - (error: CometChat.CometChatException) => { - console.log("An error occurred when marking the message as read.", error); - } -); -``` - - - - - -## Mark Messages as Unread - -The Mark as Unread feature allows users to designate specific messages or conversations as unread, even if they have been previously viewed. - -This feature is valuable for users who want to revisit and respond to important messages or conversations later, ensuring they don't forget or overlook them. - -In other words, how I can mark a message as unread? - -You can mark the messages for a particular conversation as unread using the `markAsUnread()` method. This method takes the below parameters as input: - -| Parameter | Information | -| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| message | To mark a message as unread, pass a non-null `BaseMessage` instance to the `markAsUnread()` function. All messages below that message in the conversation will contribute to the unread messages count. Example: When User B sends User A a total of 10 messages, and User A invokes the `markAsUnread()` method on the fifth message, all messages located below the fifth message within the conversation list will be designated as unread. This results in a notification indicating there are 5 unread messages in the conversation list. | -| listener | The callback listener that will be called on success or error. This should be a non-null `CallbackListener` instance. | - - - -```javascript -CometChat.markAsUnread(message); -``` - - - - -```typescript -let message: CometChat.BaseMessage; -CometChat.markAsUnread(message); -``` - - - - - -In case you would like to be notified of an error if the receipts fail to go through you can use `.then(successCallback, failureCallback).` - - - -```javascript -CometChat.markAsUnread(message).then( - () => { - console.log("mark as unread success."); - }, - (error) => { - console.log("An error occurred when marking the message as unread.", error); - } -); -``` - - - - -```typescript -let message: CometChat.BaseMessage; -CometChat.markAsUnread(message).then( - () => { - console.log("mark as read success."); - }, - (error: CometChat.CometChatException) => { - console.log("An error occurred when marking the message as read.", error); - } -); -``` - - - - - -## Receive Delivery & Read Receipts - -*In other words, as a recipient, how do I know when a message I sent has been delivered or read by someone?* - -### Real-time events - -1. `onMessagesDelivered()` - This event is triggered when a message is delivered to a user. -2. `onMessagesRead()` - This event is triggered when a message is read by a user. -3. `onMessagesDeliveredToAll()` - This event is triggered when a group message is delivered to all members of the group. This event is only for Group conversations. -4. `onMessagesReadByAll()` - This event is triggered when a group message is read by all members of the group. This event is only for Group conversations. - - - -```javascript -let listenerId = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener( - "listenerId", - new CometChat.MessageListener({ - onMessagesDelivered: (messageReceipt) => { - console.log("Message is delivered to a user: ", { messageReceipt }); - }, - onMessagesRead: (messageReceipt) => { - console.log("Message is read by a user: ", { messageReceipt }); - }, - /** This event is only for Group Conversation. */ - onMessagesDeliveredToAll: (messageReceipt) => { - console.log("Message delivered to all members of group: ", { - messageReceipt, - }); - }, - /** This event is only for Group Conversation. */ - onMessagesReadByAll: (messageReceipt) => { - console.log("Message read by all members of group: ", { messageReceipt }); - }, - }) -); -``` - - - - -```typescript -let listenerId: string = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener( - listenerId, - new CometChat.MessageListener({ - onMessagesDelivered: (messageReceipt: CometChat.MessageReceipt) => { - console.log("Message is delivered to a user: ", { messageReceipt }); - }, - onMessagesRead: (messageReceipt: CometChat.MessageReceipt) => { - console.log("Message is read by a user: ", { messageReceipt }); - }, - /** This event is only for Group Conversation. */ - onMessagesDeliveredToAll: (messageReceipt: CometChat.MessageReceipt) => { - console.log("Message delivered to all members of group: ", { - messageReceipt, - }); - }, - /** This event is only for Group Conversation. */ - onMessagesReadByAll: (messageReceipt: CometChat.MessageReceipt) => { - console.log("Message read by all members of group: ", { messageReceipt }); - }, - }) -); -``` - - - - - -You will receive events in the form of `MessageReceipt` objects. The message receipt contains the below parameters: - -| Parameter | Information | -| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | -| `messageId` | The Id of the message prior to which all the messages for that particular conversation have been marked as read. | -| `sender` | User object containing the details of the user who has marked the message as read. System User for `deliveredToAll` & `readByAll` events. | -| `receiverId` | Id of the receiver whose conversation has been marked as read. | -| `receiverType` | type of the receiver (user/group) | -| `receiptType` | Type of the receipt (read/delivered) | -| `deliveredAt` | The timestamp of the time when the message was delivered. This will only be present if the receiptType is delivered. | -| `readAt` | The timestamp of the time when the message was read. This will only be present when the receiptType is read. | - -### Missed Receipts - -You will receive message receipts when you load offline messages. While fetching messages in bulk, the message object will have two fields i.e. `deliveredAt` and `readAt` which hold the timestamp for the time the message was delivered and read respectively. Using these two variables, the delivery and read status for a message can be obtained. - -However, for a group message, if you wish to fetch the `deliveredAt` and `readAt` fields of individual member of the group you can use the below-described method. - -### Receipt History for a Single Message - -To fetch the message receipts, you can use the `getMessageReceipts()` method. - - - -```javascript -let messageId = msgId; -CometChat.getMessageReceipts(messageId).then( - (receipts) => { - console.log("Message details fetched:", receipts); - }, - (error) => { - console.log("Error in getting messag details ", error); - } -); -``` - - - - -```typescript -let messageId: number = 1; -CometChat.getMessageReceipts(messageId).then( - (receipts: CometChat.MessageReceipt[]) => { - console.log("Message details fetched:", receipts); - }, - (error: CometChat.CometChatException) => { - console.log("Error in getting messag details ", error); - } -); -``` - - - - - -You will receive a list of `MessageReceipt` objects. - - - -The following features will be available only if the **Enhanced Messaging Status** feature is enabled for your app. - -* `onMessagesDeliveredToAll` event, -* `onMessagesReadByAll` event, -* `deliveredAt` field in a group message, -* `readAt` field in a group message. -* `markAsUnread` method. - - diff --git a/sdk/ionic-legacy/direct-call.mdx b/sdk/ionic-legacy/direct-call.mdx deleted file mode 100644 index 89413df55..000000000 --- a/sdk/ionic-legacy/direct-call.mdx +++ /dev/null @@ -1,279 +0,0 @@ ---- -title: "Direct Calling" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/direct-call) which provides full compatibility with Ionic applications. - - -## Overview - -This guide demonstrates how to start call using Cometchat's calling sdk. Before you begin, we strongly recommend you read the calling setup guide. - -## Generate Call Token - -Prior to starting the call session, it is necessary to have a call token. A call token can be generated using the `generateToken` method of `CometChatCalls` class. - - - -```javascript -const loggedInUser = await CometChat.getLoggedinUser(); -if (loggedInUser) { - const authToken = loggedInUser.getAuthToken(); - const sessionID = "SESSION_ID_HERE"; - - CometChatCalls.generateToken(sessionID, authToken).then( - (res) => { - console.log("Call token fetched: ", res.token); - }, - (err) => { - console.log("Generating call token failed with error: ", err); - } - ); -} -``` - - - - -```typescript -const loggedInUser: CometChat.User | null = await CometChat.getLoggedinUser(); -if (loggedInUser) { - const authToken: string = loggedInUser.getAuthToken(); - const sessionID: string = "SESSION_ID_HERE"; - - CometChatCalls.generateToken(sessionID, authToken).then( - (res: { token: string }) => { - console.log("Call token fetched: ", res.token); - }, - (err: CometChat.CometChatException) => { - console.log("Generating call token failed with error: ", err); - } - ); -} -``` - - - - - -| Parameter | Description | -| --------- | --------------------------------------------------------------------------------------------------------------------------------------- | -| sessionID | A unique random session ID. In case you are using default call then session ID is available in the `Call` object. | -| authToken | The user auth token is logged in user auth token which you can get by calling CometChat's Chat SDK method `CometChat.getLoggedinUser()` | - -| Error Code | Error Message | -| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| INVALID\_ARGUMENT\_EXCEPTION | If you pass invalid param to a function or you don't pass the required params. Example: Authtoken and session are required, Invalid callToken passed, please verify. | - -On success of `generateToken` method you will get the response object containing call token with key named `token`. - -## Start Call Session - -The most important class that will be used in the implementation is the `CallSettings` class. This class allows you to set the various parameters for the call/conference. In order to set the various parameters of the `CallSettings` class, you need to use the `CallSettingsBuilder` class. Below are the various options available with the `CallSettings` class. - -The **mandatory** parameters that are required to be present for any call/conference to work are: - -1. **callToken:** The unique token for the call/conference session. -2. **callSettings:** The object of CallSettings class. - -A basic example of how to start a call session: - - - -```javascript -import { CometChatCalls } from '@cometchat/calls-sdk-ionic'; - -let audioOnly = false; -let defaultLayout = true; - -let callListener = - new CometChatCalls.OngoingCallListener({ - onUserListUpdated: (userList) => { - console.log("user list:", userList); - }, - onCallEnded: () => { - console.log("Call ended"); - }, - onError: (error) => { - console.log("Error :", error); - }, - onMediaDeviceListUpdated: (deviceList) => { - console.log("Device List:", deviceList); - }, - onUserMuted: (event) => { - console.log("Listener => onUserMuted:", { - userMuted: event.userMuted, - userMutedBy: event.userMutedBy, - }); - }, - onCallSwitchedToVideo: (event) => { - console.log("call switched to video:", { - sessionId: event.sessionId, - callSwitchInitiatedBy: event.initiator, - callSwitchAcceptedBy: event.acceptor, - }); - }, - onUserJoined: (user) => console.log("event => onUserJoined", user), - onUserLeft: (user) => console.log("event => onUserLeft", user), - }); - -let callSettings = new CometChatCalls.CallSettingsBuilder() - .enableDefaultLayout(defaultLayout) - .setIsAudioOnlyCall(audioOnly) - .setCallEventListener(callListener) - .build(); - -CometChatCalls.startSession(callsettings, callToken); -``` - - - - -```typescript -import { CometChatCalls } from '@cometchat/calls-sdk-ionic'; -import { CallSettings } from '@cometchat/calls-sdk-ionic/dist/models/CallSettings'; -import { OngoingCallListener } from '@cometchat/calls-sdk-ionic/dist/models/Listner'; - -let audioOnly = false; -let defaultLayout = true; - -let callListener: OngoingCallListener = - new CometChatCalls.OngoingCallListener({ - onUserListUpdated: (userList) => { - console.log("user list:", userList); - }, - onCallEnded: () => { - console.log("Call ended"); - }, - onError: (error) => { - console.log("Error :", error); - }, - onMediaDeviceListUpdated: (deviceList) => { - console.log("Device List:", deviceList); - }, - onUserMuted: (event) => { - console.log("Listener => onUserMuted:", { - userMuted: event.userMuted, - userMutedBy: event.userMutedBy, - }); - }, - onCallSwitchedToVideo: (event) => { - console.log("call switched to video:", { - sessionId: event.sessionId, - callSwitchInitiatedBy: event.initiator, - callSwitchAcceptedBy: event.acceptor, - }); - }, - onUserJoined: (user) => console.log("event => onUserJoined", user), - onUserLeft: (user) => console.log("event => onUserLeft", user), - }); - -let callSettings: CallSettings = new CometChatCalls.CallSettingsBuilder() - .enableDefaultLayout(defaultLayout) - .setIsAudioOnlyCall(audioOnly) - .setCallEventListener(callListener) - .build(); - -CometChatCalls.startSession(callsettings, callToken); -``` - - - - - -The `setIsAudioOnlyCall()` method allows you to set if the call is supposed to be an audio call or an audio-video call. If set to true, the call will be an audio-only call else when set to false the call will be an audio-video call. The default is false, so if not set, the call will be an audio-video call. - -| Parameter | Description | -| -------------- | ---------------------------------------------------------------------------------------------------------------------------- | -| `callToken` | An authorization token used to start the call session, received by calling `generateToken` method of `CometChatCalls` class. | -| `callSettings` | Object of `CallSettings` class. | - -| Error Code | Error Message | -| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- | -| INVALID\_PROP\_EXCEPTION | If you pass an invalid prop to a functional component or you don't pass the required prop. Example: Component requires valid call settings. | -| API\_ERROR | If there is some error thrown by the API server. For example, unauthorized. | -| UNKNOWN\_API\_ERROR | If there is some API error but it didn't come from the server. For example, if the internet is not available and API is called. | -| AUTH\_ERR\_TOKEN\_INVALID\_SIGNATURE | If token is invalid. | - -The `OngoingCallListener` listener provides you with the below callback methods: - -| Callback Method | Description | -| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `onUserJoined(user)` | This method is called when any other user joins the call. The user details can be obtained from the `user` object provided. | -| `onUserLeft(user)` | This method is called when a user leaves the call. The details of the user can be obtained from the provided `user` object. | -| `onCallEnded()` | This method is called when the call is successfully ended. | -| `onUserListUpdated(userList)` | This method is triggered every time a participant joins or leaves the call providing the list of users active in the call. | -| `onAudioModesUpdated(audioModes)` | This callback is triggered if any new audio output source is available or becomes unavailable. | -| `onCallSwitchedToVideo(event)` | This callback is triggered when an audio call is converted into a video call. The event object contains three keys named `sessionId`, `initiator` and `responder`. | -| `onUserMuted(event)` | This callback is triggered when a user is muted in the call. | - -## Listeners - -Listeners can be added in two ways the first one is to use .setCallEventListener(listeners : OngoingCallListener) method in CallSettingsBuilder or PresenterSettingsBuilder class. The second way is to use CometChatCalls.addCallEventListener(name: string, callListener: OngoingCallListener) by this you can add multiple listeners and remove the specific listener by their name CometChatCalls.removeCallEventListener(name: string) - - - -```javascript -useEffect(() => { - CometChatCalls.addCallEventListener("UNIQUE_ID", { - onUserJoined: (user) => { - console.log("user joined:", user); - }, - onUserLeft: (user) => { - console.log("user left:", user); - }, - onUserListUpdated: (userList) => { - console.log("user list:", userList); - }, - onCallEnded: (call) => { - console.log("Call ended:", call); - }, - onCallEndButtonPressed: (call) => { - console.log("End Call button pressed:", call); - }, - onError: (error) => { - console.log("Call Error: ", error); - }, - onAudioModesUpdated: (audioModes) => { - console.log("audio modes:", audioModes); - }, - onCallSwitchedToVideo: (data) => { - console.log("call switched to video:", data); - }, - onUserMuted: (data) => { - console.log("user muted:", data); - }, - }); - return () => CometChatCalls.removeCallEventListener("UNIQUE_ID"); -}, []); -``` - - - - - -## Settings - -The `CallSettings` class is the most important class when it comes to the implementation of the Calling feature. This is the class that allows you to customize the overall calling experience. The properties for the call/conference can be set using the `CallSettingsBuilder` class. This will eventually give you and object of the `CallSettings` class which you can pass to the `startSession()` method to start the call. - -The options available for customization of calls are: - -| Setting | Description | -| ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `enableDefaultLayout(defaultLayout: boolean)` | If set to `true` enables the default layout for handling the call operations. If set to `false` it hides the button layout and just displays the Call View. **Default value = true** | -| `showEndCallButton(showEndCallButton: boolean)` | If set to `true` it displays the EndCallButton in Button Layout. if set to `false` it hides the EndCallButton in Button Layout. **Default value = true** | -| `showPauseVideoButton(showPauseVideoButton: boolean)` | If set to `true` it displays the PauseVideoButton in Button Layout. if set to `false` it hides the PauseVideoButton in Button Layout. **Default value = true** | -| `showMuteAudioButton(showMuteAudioButton: boolean)` | If set to `true` it displays the MuteAudioButton in Button Layout. if set to `false` it hides the MuteAudioButton in Button Layout. **Default value = true** | -| `showSwitchCameraButton(showSwitchCameraButton: boolean)` | If set to `true` it displays the SwitchCameraButton in Button Layout. if set to `false` it hides the SwitchCameraButton in Button Layout. **Default value = true** | -| `showAudioModeButton(showAudioModeButton: boolean)` | If set to `true` it displays the AudioModeButton in Button Layout. if set to `false` it hides the AudioModeButton in Button Layout. **Default value = true** | -| `setIsAudioOnlyCall(audioOnly: boolean)` | If set to true, the call will be strictly an audio call. If set to false, the call will be an audio-video call. **Default value = false** | -| `setMode(mode: string)` | CometChat provides 2 options for the calling UI. 1. CometChatCalls.CALL\_MODE.DEFAULT 2. CometChatCalls.CALL\_MODE.SPOTLIGHT **Default value = CometChatCalls.CALL\_MODE.DEFAULT** | -| `startWithAudioMuted(audioMuted: boolean)` | This ensures the call is started with the audio muted if set to true. **Default value = false** | -| `startWithVideoMuted(videoMuted: boolean)` | This ensures the call is started with the video paused if set to true. **Default value = false** | -| `setDefaultAudioMode(audioMode: string)` | This method can be used if you wish to start the call with a specific audio mode. The available options are
1. CometChatCalls.AUDIO\_MODE.SPEAKER = "SPEAKER"
2. CometChatCalls.AUDIO\_MODE.EARPIECE = "EARPIECE"
3. CometChatCalls.AUDIO\_MODE.BLUETOOTH = "BLUETOOTH"
4. CometChatCalls.AUDIO\_MODE.HEADPHONES = "HEADPHONES" | -| `showSwitchToVideoCallButton(switchCall: boolean)` | This method shows/hides the switch to video call button. If set to true it will display the switch to video call button. If set to false it will hide the switch to video call button. **Default value = true** | -| `setAvatarMode(avatarMode: string)` | This method sets the mode of avatar. The avatar mode can be `circle`, `square` or `fullscreen`. **Default value = circle** | -| `setMainVideoContainerSetting(containerSettings: MainVideoContainerSetting)` | This method can be used to customize the main video container. You can read more about this [here](/sdk/ionic-legacy/video-view-customisation). | -| `enableVideoTileClick(enableVideoTileClick: boolean)` | This method can be used to enable/disable video tile click functionality in **Spotlight** mode. **Default value = true** | -| `enableVideoTileDrag(enableVideoTileDrag: boolean)` | This method can be used to enable/disable video tile drag functionality in **Spotlight** mode. **Default value = true** | diff --git a/sdk/ionic-legacy/edit-message.mdx b/sdk/ionic-legacy/edit-message.mdx deleted file mode 100644 index 79f1b3ad2..000000000 --- a/sdk/ionic-legacy/edit-message.mdx +++ /dev/null @@ -1,179 +0,0 @@ ---- -title: "Edit A Message" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/edit-message) which provides full compatibility with Ionic applications. - - -While [editing a message](/sdk/ionic-legacy/edit-message#edit-a-message) is straightforward, receiving events for edited messages with CometChat has two parts: - -1. Adding a listener to receive [real-time message edits](/sdk/ionic-legacy/edit-message#real-time-message-edit-events) when your app is running -2. Calling a method to retrieve [missed message edits](/sdk/ionic-legacy/edit-message#missed-message-edit-events) when your app was not running - -## Edit a Message - -*In other words, as a sender, how do I edit a message?* - -In order to edit a message, you can use the `editMessage()` method. This method takes an object of the `BaseMessage` class. At the moment, you are only allowed to edit `TextMessage` and `CustomMessage`. Thus, the `BaseMessage` object must either be a Text or a Custom Message. - -### Add/Update Tags - -While editing a message, you can update the tags associated with the Message. You can use the `setTags()` method to do so. The tags added while editing a message will replace the tags set when the message was sent. - - - -```javascript -let tags = ["pinnedMessage"]; - -textMessage.setTags(tags); -``` - - - - -```javascript -let tags = ["pinnedMessage"]; - -customMessage.setTags(tags); -``` - - - - -```typescript -let tags: Array = ["pinnedMessage"]; - -textMessage.setTags(tags); -``` - - - - -```typescript -let tags: Array = ["pinnedMessage"]; - -customMessage.setTags(tags); -``` - - - - - -Once the message object is ready, you can use the `editMessage()` method and pass the message object to it. - - - -```javascript -let receiverID = "RECEIVER_UID"; -let messageText = "Hello world!"; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let messageId = "MESSAGE_ID_OF_THE_MESSAGE_TO_BE_EDITED"; -let textMessage = new CometChat.TextMessage(receiverID, messageText, receiverType); - -textMessage.setId(messageId); - -CometChat.editMessage(textMessage).then( -message => { - console.log("Message Edited", message); -}, error => { - console.log("Message editing failed with error:", error); -} -); -``` - - - - -```typescript -let receiverID: string = "RECEIVER_UID"; -let messageText: string = "Hello world!"; -let receiverType: string = CometChat.RECEIVER_TYPE.USER; -let messageId: number = 1; -let textMessage: CometChat.TextMessage = new CometChat.TextMessage(receiverID, messageText, receiverType); - -textMessage.setId(messageId); - -CometChat.editMessage(textMessage).then( - (message: CometChat.TextMessage) => { - console.log("Message Edited", message); - }, (error: CometChat.CometChatException) => { - console.log("Message editing failed with error:", error); - } -); -``` - - - - - -The object of the edited message will be returned in the `onSuccess()` callback method of the listener. The message object will contain the `editedAt` field set with the timestamp of the time the message was edited. This will help you identify if the message was edited while iterating through the list of messages. The `editedBy` field is also set to the UID of the user who edited the message. - -By default, CometChat allows certain roles to edit a message. - -| User Role | Conversation Type | Edit Capabilities | -| --------------- | ----------------------- | -------------------------- | -| Message Sender | One-on-One Conversation | Messages they have sent. | -| Message Sender | Group Conversation | Messages they have sent. | -| Group Owner | Group Conversation | All messages in the group. | -| Group Moderator | Group Conversation | All messages in the group. | - -## Real-time Message Edit Events - -*In other words, as a recipient, how do I know when someone has edited their message when my app is running?* - -In order to receive real-time events for message being edited, you need to override the `onMessageEdited()` method of the `MessageListener` class. - - - -```javascript -let listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener( -listenerID, -new CometChat.MessageListener({ - onMessageEdited: message => { - console.log("Edited Message", message); - } -}) -); -``` - - - - -```typescript -let listenerID: string = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener( -listenerID, -new CometChat.MessageListener({ - onMessageEdited: (message: CometChat.BaseMessage) => { - console.log("Edited Message", message); - } -}) -); -``` - - - - - -## Missed Message Edit Events - -*In other words, as a recipient, how do I know when someone edited their message when my app was not running?* - -When you retrieve the list of previous messages, for the message that was edited, the `editedAt` and the `editedBy` fields will be set. Also, for example, of the total number of messages for a conversation are 100, and the message with message ID 50 was edited. Now the message with id 50 will have the `editedAt` and the `editedBy` fields set whenever it is pulled from the history. Also, the 101st message will be and \[Action] message informing you that the message with id 50 has been edited. - -For the message edited event, in the `Action` object received, the following fields can help you get the relevant information- - -1. `action` - `edited` -2. `actionOn` - Updated message object with the edited details. -3. `actionBy` - User object containing the details of the user who has edited the message. -4. `actionFor` - User/group object having the details of the receiver to which the message was sent. - - - -In order to edit a message, you need to be either the sender of the message or the admin/moderator of the group in which the message was sent. - - diff --git a/sdk/ionic-legacy/extensions-overview.mdx b/sdk/ionic-legacy/extensions-overview.mdx deleted file mode 100644 index 29c1774bd..000000000 --- a/sdk/ionic-legacy/extensions-overview.mdx +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: "Extensions" -url: "/fundamentals/extensions-overview" ---- \ No newline at end of file diff --git a/sdk/ionic-legacy/group-add-members.mdx b/sdk/ionic-legacy/group-add-members.mdx deleted file mode 100644 index d0599433b..000000000 --- a/sdk/ionic-legacy/group-add-members.mdx +++ /dev/null @@ -1,137 +0,0 @@ ---- -title: "Add Members To A Group" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/group-add-members) which provides full compatibility with Ionic applications. - - -## Add Members to Group - -You can add members to the group using the `addMembersToGroup()` method. This method takes the below parameters: - -1. `GUID` - GUID of the group the members are to be added to. -2. `Array members` - This is a list of `GroupMember` objects. In order to add members, you need to create an object of the `GroupMember` class. The UID and the scope of the `GroupMember` are mandatory. -3. `Array bannedMembers` - This is the list of `UID's` that need to be banned from the Group. This can be set to `null` if there are no members to be banned. - - - -```javascript -let GUID = "GUID"; -let UID = "UID"; -let membersList = [ - new CometChat.GroupMember(UID, CometChat.GROUP_MEMBER_SCOPE.PARTICIPANT), -]; - -CometChat.addMembersToGroup(GUID, membersList, []).then( - (response) => { - console.log("response", response); - }, - (error) => { - console.log("Something went wrong", error); - } -); -``` - - - - -```typescript -let GUID: string = "GUID"; -let UID: string = "UID"; -let membersList: CometChat.GroupMember[] = [ - new CometChat.GroupMember(UID, CometChat.GROUP_MEMBER_SCOPE.PARTICIPANT), -]; - -CometChat.addMembersToGroup(GUID, membersList, []).then( - (response: Object) => { - console.log("response", response); - }, - (error: CometChat.CometChatException) => { - console.log("Something went wrong", error); - } -); -``` - - - - - -It will return a Array which will contain the `UID` of the users and the value will either be `success` or an error message describing why the operation to add the user to the group. - -## Real-Time Group Member Added Events - -*In other words, as a member of a group, how do I know when someone is added to the group when my app is running?* - - - -When a group member is added by another member, this event is triggered. When a user joins a group on their own, the joined event is triggered. - - - -To receive real-time events whenever a new member is added to a group, you need to implement the `onMemberAddedToGroup()` methods of the `GroupListener` class. - -`onMemberAddedToGroup()` - This method is triggered when any user is added to the group so that the logged in user is informed of the other members added to the group. - - - -```javascript -var listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.addGroupListener( - listenerID, - new CometChat.GroupListener({ - onMemberAddedToGroup: (message, userAdded, userAddedBy, userAddedIn) => { - console.log("User joined", { - message, - userAdded, - userAddedBy, - userAddedIn, - }); - }, - }) -); -``` - - - - -```typescript -var listenerID: string = "UNIQUE_LISTENER_ID"; - -CometChat.addGroupListener( - listenerID, - new CometChat.GroupListener({ - onMemberAddedToGroup: ( - message: CometChat.Action, - userAdded: CometChat.User, - userAddedBy: CometChat.User, - userAddedIn: CometChat.Group - ) => { - console.log("User joined", { - message, - userAdded, - userAddedBy, - userAddedIn, - }); - }, - }) -); -``` - - - - - -## Member Added to Group event in Message History - -*In other words, as a member of a group, how do I know when someone is added to the group when my app is not running?* - -When you retrieve the list of previous messages if a member has been added to any group that the logged-in user is a member of, the list of messages will contain an `Action` message. An `Action` message is a sub-class of `BaseMessage` class. - -For the group member added event, in the `Action` object received, the following fields can help you get the relevant information- - -1. `action` - `added` -2. `actionOn` - User object containing the details of the user who was added to the group -3. `actionBy` - User object containing the details of the user who added the member to the group -4. `actionFor` - Group object containing the details of the group to which the member was added diff --git a/sdk/ionic-legacy/group-change-member-scope.mdx b/sdk/ionic-legacy/group-change-member-scope.mdx deleted file mode 100644 index c20ac1bb5..000000000 --- a/sdk/ionic-legacy/group-change-member-scope.mdx +++ /dev/null @@ -1,143 +0,0 @@ ---- -title: "Change Member Scope" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/group-change-member-scope) which provides full compatibility with Ionic applications. - - -## Change Scope of a Group Member - -In order to change the scope of a group member, you can use the `changeGroupMemberScope()`. - - - -```javascript -var GUID = "GUID"; -var UID = "UID"; -var scope = CometChat.GROUP_MEMBER_SCOPE.ADMIN; - -CometChat.updateGroupMemberScope(GUID, UID, scope).then( - (response) => { - console.log("Group member scopped changed", response); - }, - (error) => { - console.log("Group member scopped changed failed", error); - } -); -``` - - - - -```typescript -let GUID: string = "GUID"; -let UID: string = "UID"; - -CometChat.updateGroupMemberScope( - GUID, - UID, - CometChat.GroupMemberScope.Admin -).then( - (response: boolean) => { - console.log("Group member scopped changed", response); - }, - (error: CometChat.CometChatException) => { - console.log("Group member scopped changed failed", error); - } -); -``` - - - - - -This method takes the below parameters: - -| Parameter | Description | -| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `UID` | The UID of the member whose scope you would like to change | -| `GUID` | The GUID of the group for which the member's scope needs to be changed | -| `scope` | The updated scope of the member. This can be either of the 3 values: 1.`CometChatConstants.SCOPE_ADMIN` (admin)2.`CometChatConstants.SCOPE_MODERATOR` (moderator)3.`CometChatConstants.SCOPE_PARTICIPANT` (participant) | - -The default scope of any member is `participant`. Only the **Admin** of the group can change the scope of any participant in the group. - -## Real-Time Group Member Scope Changed Events - -*In other words, as a member of a group, how do I know when someone's scope is changed when my app is running?* - -In order to receive real-time events for the change member scope event, you will need to override the `onGroupMemberScopeChanged()` method of the `GroupListener` class - - - -```javascript -let listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.addGroupListener( - listenerID, - new CometChat.GroupListener({ - onGroupMemberScopeChanged: ( - message, - changedUser, - newScope, - oldScope, - changedGroup - ) => { - console.log("User joined", { - message, - changedUser, - newScope, - oldScope, - changedGroup, - }); - }, - }) -); -``` - - - - -```typescript -let listenerID: string = "UNIQUE_LISTENER_ID"; - -CometChat.addGroupListener( - listenerID, - new CometChat.GroupListener({ - onGroupMemberScopeChanged: ( - message: CometChat.Action, - changedUser: CometChat.User, - newScope: string, - oldScope: string, - changedGroup: CometChat.Group - ) => { - console.log("User joined", { - message, - changedUser, - newScope, - oldScope, - changedGroup, - }); - }, - }) -); -``` - - - - - -## Missed Group Member Scope Changed Events - -*In other words, as a member of a group, how do I know when someone's scope is changed when my app is not running?* - -When you retrieve the list of previous messages if a member's scope has been changed for any group that the logged-in user is a member of, the list of messages will contain an `Action` message. An `Action` message is a sub-class of `BaseMessage` class. - -For the group member scope changed event, in the `Action` object received, the following fields can help you get the relevant information- - -1. `action` - `scopeChanged` -2. `actionOn` - User object containing the details of the user whose scope has been changed -3. `actionBy` - User object containing the details of the user who changed the scope of the member -4. `actionFor` - Group object containing the details of the group in which the member scope was changed -5. `oldScope` - The original scope of the member -6. `newScope` - The updated scope of the member diff --git a/sdk/ionic-legacy/group-kick-member.mdx b/sdk/ionic-legacy/group-kick-member.mdx deleted file mode 100644 index 8cf0675f0..000000000 --- a/sdk/ionic-legacy/group-kick-member.mdx +++ /dev/null @@ -1,408 +0,0 @@ ---- -title: "Kick Member From A Group" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/group-kick-ban-members) which provides full compatibility with Ionic applications. - - -There are certain actions that can be performed on the group members: - -1. Kick a member from the group -2. Ban a member from the group -3. Unban a member from the group -4. Update the scope of the member of the group - -All the above actions can only be performed by the **Admin** or the **Moderator** of the group. - -## Kick a Group Member - -The Admin or Moderator of a group can kick a member out of the group using the `kickGroupMember()` method. - - - -```javascript -var GUID = "GUID"; -var UID = "UID"; - -CometChat.kickGroupMember(GUID, UID).then( - (response) => { - console.log("Group member kicked successfully", response); - }, - (error) => { - console.log("Group member kicking failed with error", error); - } -); -``` - - - - -```typescript -let GUID: string = "GUID"; -let UID: string = "UID"; - -CometChat.kickGroupMember(GUID, UID).then( - (response: Object) => { - console.log("Group member kicked successfully", response); - }, - (error: CometChat.CometChatException) => { - console.log("Group member kicking failed with error", error); - } -); -``` - - - - - -The `kickGroupMember()` takes following parameters - -| Parameter | Description | -| --------- | ----------------------------------------------------- | -| `UID` | The UID of the user to be kicked. | -| `GUID` | The GUID of the group from which user is to be kicked | - -The kicked user will be no longer part of the group and can not perform any actions in the group, but the kicked user can rejoin the group. - -## Ban a Group Member - -The Admin or Moderator of the group can ban a member from the group using the `banGroupMember()` method. - - - -```javascript -var GUID = "GUID"; -var UID = "UID"; - -CometChat.banGroupMember(GUID, UID).then( - (response) => { - console.log("Group member banned successfully", response); - }, - (error) => { - console.log("Group member banning failed with error", error); - } -); -``` - - - - -```typescript -let GUID: string = "GUID"; -let UID: string = "UID"; - -CometChat.banGroupMember(GUID, UID).then( - (response: Object) => { - console.log("Group member banned successfully", response); - }, - (error: CometChat.CometChatException) => { - console.log("Group member banning failed with error", error); - } -); -``` - - - - - -The `banGroupMember()` method takes the following parameters: - -| Parameter | Description | -| --------- | ------------------------------------------------------ | -| `UID` | The UID of the user to be banned. | -| `GUID` | The GUID of the group from which user is to be banned. | - -The banned user will be no longer part of the group and can not perform any actions in the group. A banned user cannot rejoin the same group without being unbanned. - -## Unban a Banned Group Member from a Group - -Only Admin or Moderators of the group can unban a previously banned member from the group using the `unbanGroupMember()` method. - - - -```javascript -var GUID = "GUID"; -var UID = "UID"; - -CometChat.unbanGroupMember(GUID, UID).then( - (response) => { - console.log("Group member unbanned successfully", response); - }, - (error) => { - console.log("Group member unbanning failed with error", error); - } -); -``` - - - - -```typescript -let GUID: string = "GUID"; -let UID: string = "UID"; - -CometChat.unbanGroupMember(GUID, UID).then( - (response: Object) => { - console.log("Group member unbanned successfully", response); - }, - (error: CometChat.CometChatException) => { - console.log("Group member unbanning failed with error", error); - } -); -``` - - - - - -The `unbanGroupMember()` method takes the following parameters - -| Parameter | Description | -| --------- | ---------------------------------------------------- | -| `UID` | The UID of the user to be unbanned. | -| `GUID` | The UID of the group from which user is to be banned | - -The unbanned user can now rejoin the group. - -## Get List of Banned Members for a Group - -In order to fetch the list of banned groups members for a group, you can use the `BannedGroupMembersRequest` class. To use this class i.e to create an object of the BannedGroupMembersRequest class, you need to use the `BannedGroupMembersRequestBuilder` class. The `BannedGroupMembersRequestBuilder` class allows you to set the parameters based on which the banned group members are to be fetched. - -The `BannedGroupMembersRequestBuilder` class allows you to set the below parameters: - -The `GUID` of the group for which the banned members are to be fetched must be specified in the constructor of the `GroupMembersRequestBuilder` class. - -### Set Limit - -This method sets the limit i.e. the number of banned members that should be fetched in a single iteration. - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let bannedGroupMembersRequest = new CometChat.BannedMembersRequestBuilder(GUID) - .setLimit(limit) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID"; -let limit: number = 30; -let bannedGroupMembersRequest: CometChat.BannedMembersRequest = - new CometChat.BannedMembersRequestBuilder(GUID).setLimit(limit).build(); -``` - - - - - -### Set Search Keyword - -This method allows you to set the search string based on which the banned group members are to be fetched. - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let searchKeyword = "super"; -let bannedGroupMembersRequest = new CometChat.BannedMembersRequestBuilder(GUID) - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID"; -let limit: number = 30; -let searchKeyword: string = "super"; -let bannedGroupMembersRequest: CometChat.BannedMembersRequest = - new CometChat.BannedMembersRequestBuilder(GUID) - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - - -Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the `BannedGroupMembersRequest` class. - -Once you have the object of the `BannedGroupMembersRequest` class, you need to call the `fetchNext()` method. Calling this method will return a list of `GroupMember` objects containing n number of banned members where n is the limit set in the builder class. - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let bannedMembersRequest = new CometChat.BannedMembersRequestBuilder(GUID) - .setLimit(limit) - .build(); - -bannedMembersRequest.fetchNext().then( - (bannedMembers) => { - console.log( - "Banned Group Member list fetched successfully:", - bannedMembers - ); - }, - (error) => { - console.log( - "Banned Group Member list fetching failed with exception:", - error - ); - } -); -``` - - - - -```typescript -let GUID: string = "GUID"; -let limit: number = 30; -let bannedGroupMembersRequest: CometChat.BannedMembersRequest = - new CometChat.BannedMembersRequestBuilder(GUID).setLimit(limit).build(); - -bannedGroupMembersRequest.fetchNext().then( - (bannedMembers: CometChat.GroupMember[]) => { - console.log( - "Banned Group Member list fetched successfully:", - bannedMembers - ); - }, - (error: CometChat.CometChatException) => { - console.log( - "Banned Group Member list fetching failed with exception:", - error - ); - } -); -``` - - - - - -## Real-Time Group Member Kicked/Banned Events - -*In other words, as a member of a group, how do I know when someone is banned/kicked when my app is running?* - -In order to get real-time events for the kick/ban/unban group members you need to override the following methods of the `GroupListener` class. - -1. `onGroupMemberKicked()` - triggered when any group member has been kicked. -2. `onGroupMemberBanned()` - triggered when any group member has been banned. -3. `onGroupMemberUnbanned()` - triggered when any group member has been unbanned. - - - -```javascript -let listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.addGroupListener( - listenerID, - new CometChat.GroupListener({ - onGroupMemberKicked: (message, kickedUser, kickedBy, kickedFrom) => { - console.log("User kicked", { message, kickedUser, kickedBy, kickedFrom }); - }, - onGroupMemberBanned: (message, bannedUser, bannedBy, bannedFrom) => { - console.log("User banned", { message, bannedUser, bannedBy, bannedFrom }); - }, - onGroupMemberUnbanned: ( - message, - unbannedUser, - unbannedBy, - unbannedFrom - ) => { - console.log("User unbanned", { - message, - unbannedUser, - unbannedBy, - unbannedFrom, - }); - }, - }) -); -``` - - - - -```typescript -let listenerID: string = "UNIQUE_LISTENER_ID"; - -CometChat.addGroupListener( - listenerID, - new CometChat.GroupListener({ - onGroupMemberKicked: ( - message: CometChat.Action, - kickedUser: CometChat.User, - kickedBy: CometChat.User, - kickedFrom: CometChat.Group - ) => { - console.log("User kicked", { message, kickedUser, kickedBy, kickedFrom }); - }, - onGroupMemberBanned: ( - message: CometChat.Action, - bannedUser: CometChat.User, - bannedBy: CometChat.User, - bannedFrom: CometChat.Group - ) => { - console.log("User banned", { message, bannedUser, bannedBy, bannedFrom }); - }, - onGroupMemberUnbanned: ( - message: CometChat.Action, - unbannedUser: CometChat.User, - unbannedBy: CometChat.User, - unbannedFrom: CometChat.Group - ) => { - console.log("User unbanned", { - message, - unbannedUser, - unbannedBy, - unbannedFrom, - }); - }, - }) -); -``` - - - - - -## Missed Group Member Kicked/Banned Events - -*In other words, as a member of a group, how do I know when someone is banned/kicked when my app is not running?* - -When you retrieve the list of previous messages if a member has been kicked/banned/unbanned from any group that the logged-in user is a member of, the list of messages will contain an `Action` message. An `Action` message is a sub-class of `BaseMessage` class. - -For group member kicked event, the details can be obtained using the below fields of the `Action` class- - -1. `action` - `kicked` -2. `actionBy` - User object containing the details of the user who has kicked the member -3. `actionOn` - User object containing the details of the member that has been kicked -4. `actionFor` - Group object containing the details of the Group from which the member was kicked - -For group member banned event, the details can be obtained using the below fields of the `Action` class- - -1. `action` - `banned` -2. `actionBy` - User object containing the details of the user who has banned the member -3. `actionOn` - User object containing the details of the member that has been banned -4. `actionFor` - Group object containing the details of the Group from which the member was banned - -For group member unbanned event, the details can be obtained using the below fields of the `Action` class- - -1. `action` - `unbanned` -2. `actionBy` - User object containing the details of the user who has unbanned the member -3. `actionOn` - User object containing the details of the member that has been unbanned -4. `actionFor` - Group object containing the details of the Group from which the member was unbanned diff --git a/sdk/ionic-legacy/groups-overview.mdx b/sdk/ionic-legacy/groups-overview.mdx deleted file mode 100644 index 0140fd729..000000000 --- a/sdk/ionic-legacy/groups-overview.mdx +++ /dev/null @@ -1,12 +0,0 @@ ---- -title: "Groups" -sidebarTitle: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/groups-overview) which provides full compatibility with Ionic applications. - - -Groups help your users to converse together in a single space. You can have three types of groups- private, public and password protected. - -Each group includes three kinds of users- owner, moderator, member. diff --git a/sdk/ionic-legacy/interactive-messages.mdx b/sdk/ionic-legacy/interactive-messages.mdx deleted file mode 100644 index f749f4ad8..000000000 --- a/sdk/ionic-legacy/interactive-messages.mdx +++ /dev/null @@ -1,207 +0,0 @@ ---- -title: "Interactive Messages" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/interactive-messages) which provides full compatibility with Ionic applications. - - -An `InteractiveMessage` is a specialised object that encapsulates an interactive unit within a chat message, such as an embedded form that users can fill out directly within the chat interface. This enhances user engagement by making the chat experience more interactive and responsive to user input. - -## InteractiveMessage - -`InteractiveMessage` is a chat message with embedded interactive content. It can contain various properties: - -| Parameter | Description | | -| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -| `receiverId` | The UID or GUID of the recipient | Required | -| `receiverType` | The type of the receiver to whom the message is to be sent (e.g., `CometChatConstants.RECEIVER_TYPE_USER` for user or `CometChatConstants.RECEIVER_TYPE_GROUP` for group) | Required | -| `messageType` | The type of the message that needs to be sent | Required | -| `interactiveData` | A JSONObject holding structured data for the interactive element | Required | -| `allowSenderInteraction` | A boolean determining whether the message sender can interact with the message (default is set to false) | | -| `interactionGoal` | An InteractionGoal object encapsulating the intended outcome of interacting with the InteractiveMessage (default is set to none) | | - -## Interaction - -An Interaction represents a user action involved with an InteractiveMessage. It includes: - -* `elementId`: An identifier for a specific interactive element. -* `interactedAt`: A timestamp indicating when the interaction occurred. - -## Goal Completion - -A key feature of `InteractiveMessage` is checking whether a user's interactions with the message meet the defined `InteractionGoal` - -You would be tracking every interaction users perform on an `InteractiveMessage` (captured as Interaction objects) and comparing those with the defined `InteractionGoal`. The completion of a goal can vary depending on the goal type: - -| Goals | Description | Keys | -| -------------------------------- | ---------------------------------------------------------------------- | --------------------------------------------- | -| **Any Interaction** | The goal is considered completed if there is at least one interaction. | CometChatConstants.INTERACTION\_TYPE\_ANY | -| **Any of Specific Interactions** | The goal is achieved if any of the specified interactions occurred. | CometChatConstants.INTERACTION\_TYPE\_ANY\_OF | -| **All of Specific Interactions** | The goal is completed when all specified interactions occur. | CometChatConstants.INTERACTION\_TYPE\_All\_OF | -| **None** | The goal is never completed | CometChatConstants.INTERACTION\_TYPE\_NONE | - -This user interaction tracking mechanism provides a flexible and efficient way to monitor user engagement within an interactive chat session. By defining clear interaction goals and checking user interactions against these goals, you can manage user engagement and improve the overall chat experience in your CometChat-enabled application. - -## InteractionGoal - -The `InteractionGoal` represents the desired outcome of an interaction with an InteractiveMessage. It includes: - -* `elementIds`: A list of identifiers for the interactive elements. -* `type`: The type of interaction goal from the CometChatConstants. - -## Sending InteractiveMessages - -The `InteractiveMessage` can be sent using the `sendInteractiveMessage` method of the `CometChat` class. The method requires an `InteractiveMessage` object and a `CallbackListener` for handling the response. - -Here is an example of how to use it: - - - -```javascript -const interactiveData = { - title: "Survey", - formFields: [ - { - elementType: "textInput", - elementId: "name", - optional: false, - label: "Name", - placeholder: { - text: "Enter text here", - }, - }, - { - elementType: "textInput", - elementId: "age", - optional: true, - label: "Age", - maxLines: 1, - placeholder: { - text: "Enter text here", - }, - }, - { - elementType: "Select", - elementId: "checkBox1", - optional: true, - label: "Check box element", - defaultValue: ["chk_option_2"], - options: [ - { - label: "Option 1", - value: "chk_option_1", - }, - { - label: "Option 2", - value: "chk_option_2", - }, - ], - }, - { - elementType: "dropdown", - elementId: "gender", - optional: false, - label: "Gender", - defaultValue: "male", - options: [ - { - label: "Male", - value: "male", - }, - { - label: "Female", - value: "female", - }, - ], - }, - ], - submitElement: { - elementType: "button", - elementId: "submitButton", - buttonText: "Submit", - disableAfterInteracted: false, - action: { - actionType: "urlNavigation", - url: "https://www.cometchat.com/", - }, - }, -}; - -const interactiveMessage = new CometChat.InteractiveMessage( - receiverId, - receiverType, - "form", - interactiveData -); - -CometChat.sendInteractiveMessage(interactiveMessage) - .then((message: CometChat.InteractiveMessage) => { - // This block is executed when the InteractiveMessage is sent successfully. - }) - .catch((error: CometChat.CometChatException) => { - // This block is executed if an error occurs while sending the InteractiveMessage. - }); -``` - - - - - -## Event Listeners - -CometChat SDK provides event listeners to handle real-time events related to `InteractiveMessage`. - -### On InteractiveMessage Received - -The `onInteractiveMessageReceived` event listener is triggered when an `InteractiveMessage` is received. - -Here is an example: - - - -```javascript -CometChat.addMessageListener( - "UNIQUE_ID", - new CometChat.MessageListener({ - onInteractiveMessageReceived: (message: CometChat.InteractiveMessage) => { - // This block is executed when an InteractiveMessage is received. - // Here you can define logic to handle the received InteractiveMessage and display it in your chat interface. - }, - }) -); -``` - - - - - -### On Interaction Goal Completed - -The `onInteractionGoalCompleted` event listener is invoked when an interaction goal is achieved. - -Here is an example: - - - -```javascript -CometChat.addMessageListener( - "UNIQUE_ID", - new CometChat.MessageListener({ - onInteractionGoalCompleted: (receipt: CometChat.InteractionReceipt) => { - // This block is executed when an interaction goal is completed. - // Here you can specify the actions your application should take once an interaction goal is achieved, such as updating the UI or notifying the user. - }, - }) -); -``` - - - - - -These event listeners offer your application a way to provide real-time updates in response to incoming interactive messages and goal completions, contributing to a more dynamic and responsive user chat experience. - -## Usage - -An `InteractiveMessage` is constructed with the receiver's UID, the receiver type, the interactive type, and interactive data as a JSONObject. Once created, the `InteractiveMessage` can be sent using CometChat's `sendInteractiveMessage()` method. Incoming `InteractiveMessages` can be received and processed via CometChat's message listener framework. diff --git a/sdk/ionic-legacy/join-group.mdx b/sdk/ionic-legacy/join-group.mdx deleted file mode 100644 index 1b7419999..000000000 --- a/sdk/ionic-legacy/join-group.mdx +++ /dev/null @@ -1,109 +0,0 @@ ---- -title: "Join A Group" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/join-group) which provides full compatibility with Ionic applications. - - -## Join a Group - -In order to start participating in group conversations, you will have to join a group. You can do so using the `joinGroup()` method. - - - -```javascript -var GUID = "GUID"; -var password = ""; -var groupType = CometChat.GROUP_TYPE.PUBLIC; - -CometChat.joinGroup(GUID, groupType, password).then( -group => { - console.log("Group joined successfully:", group); -}, error => { - console.log("Group joining failed with exception:", error); -} -); -``` - - - - -```typescript -var GUID: string = "GUID"; - -CometChat.joinGroup(GUID, CometChat.GroupType.Public).then( - (group: CometChat.Group) => { - console.log("Group joined successfully:", group); - }, (error: CometChat.CometChatException) => { - console.log("Group joining failed with exception:", error); - } -); -``` - - - - - -The `joinGroup()` method takes the below parameters - -| Parameter | Description | -| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `GUID` | The GUID of the group you would like to join. | -| `groupType` | Type of the group. CometChat provides 3 types of groups viz. a. CometChatConstants.GROUP\_TYPE\_PUBLIC (public) b. CometChatConstants.GROUP\_TYPE\_\_\_PASSWORD (password) c. CometChatConstants.GROUP\_TYPE\_PRIVATE (private) | -| `password` | Password is mandatory in case of a password protected group. | - -Once you have joined a group successfully, you can send and receive messages in that group. - -CometChat keeps a track of the groups joined and you do not need to join the group every time you want to communicate in the group. - -You can identify if a group is joined using the `hasJoined` parameter in the `Group` object. - -## Real-time Group Member Joined Events - -*In other words, as a member of a group, how do I know if someone joins the group when my app is running?* - -If a user joins any group, the members of the group receive a real-time event in the `onGroupMemberJoined()` method of the `GroupListener` class. - - - -```javascript -CometChat.addGroupListener( - "UNIQUE_LISTNER_ID", - new CometChat.GroupListener({ - onGroupMemberJoined: (message, joinedUser, joinedGroup) => { - console.log("User joined", { message, joinedUser, joinedGroup }); - } - }) -); -``` - - - - -```typescript -CometChat.addGroupListener( - "UNIQUE_LISTNER_ID", - new CometChat.GroupListener({ - onGroupMemberJoined: (message: CometChat.Action, joinedUser: CometChat.User, joinedGroup: CometChat.Group) => { - console.log("User joined", { message, joinedUser, joinedGroup }); - } - }) -); -``` - - - - - -## Missed Group Member Joined Events - -*In other words, as a member of a group, how do I know if someone joins the group when my app is not running?* - -When you retrieve the list of previous messages if a member has joined any group that the logged-in user is a member of, the list of messages will contain an `Action` message. An `Action` message is a sub-class of `BaseMessage` class. - -For the group member joined event, in the `Action` object received, the following fields can help you get the relevant information- - -1. `action` - `joined` -2. `actionBy` - User object containing the details of the user who joined the group -3. `actionFor`- Group object containing the details of the group the user has joined diff --git a/sdk/ionic-legacy/key-concepts.mdx b/sdk/ionic-legacy/key-concepts.mdx deleted file mode 100644 index e145ca826..000000000 --- a/sdk/ionic-legacy/key-concepts.mdx +++ /dev/null @@ -1,129 +0,0 @@ ---- -title: "Key Concepts" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/key-concepts) which provides full compatibility with Ionic applications. - - -### CometChat Dashboard - -The CometChat Dashboard enables you to create new apps (projects) and manage your existing apps. - - -How many apps to create? - -Ideally, you should create two apps- one for development and one for production. And you should use a single app irrespective of the number of platforms. - -Do not create separate apps for every platform; if you do, your users on different platforms will not be able to communicate with each other! - - - -* For every app, a unique App ID is generated. This App ID will be required when integrating CometChat within your app. -* Along with the App ID, you will need to create an Auth Key (from the Dashboard) which can be used for user authentication. - -### Auth & Rest API Keys - -You can generate two types of keys from the dashboard. - -| Type | Privileges | Recommended Use | -| ------------ | ---------------------------------------------------------------- | --------------------------------------------- | -| Auth Key | The Auth Key can be used to create & login users. | In your client side code (during development) | -| Rest API Key | The Rest API Key can be used to perform any CometChat operation. | In your server side code | - -### Users - -A user is anyone who uses CometChat. - -### UID - -* Each user is uniquely identified using UID. -* The UID is typically the primary ID of the user from your database. - - - -UID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed. - - - -### Auth Token - -* A single user can have multiple auth tokens. The auth tokens should be per user per device. -* It should be generated by API call ideally, via server to server call. The auth token should then be given to CometChat for login. -* An Auth Token can only be deleted via dashboard or using REST API. - -### Authentication - -To allow a user to use CometChat, the user must log in to CometChat. - -**CometChat does not handle user management.** You must handle user registration and login at your end. Once the user is logged into your app/site, you can log in the user to CometChat **programmatically**. So the user does not ever directly login to CometChat. - -**CometChat does not handle friends management.** If you want to associate friends with your users, you must handle friends management in your app. Once two users are friends (i.e. they have accepted each other as friends), then you can associate them as friends in CometChat. - -### Typical Workflow - -| Your App | Your Server | CometChat | -| ----------------------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ | -| User registers in your app | You store the user information in your database (e.g. ID, name, email, phone, location etc. in `users` table) | You add the user to CometChat (only ID & name) using the Rest API | -| User logs in to your app | You verify the credentials, login the user and retrieve the user ID | You log in the user to CometChat using the same user ID programmatically | -| User sends a friend request | You display the request to the potential friend | No action required | -| User accepts a friend request | You display the users as friends | You add both the users as friends using the Rest API | - -### User Roles - -A role is a category for a group of similar users. For example, you may want to group your premium users using the role "Premium". You then use this to filter users or enable/disable features by writing conditional code. - -### User List - -* The User List can be used to build the **Contacts** or **Who's Online** view in your app. -* The list of users can be different based on the logged-in user. - -### Groups - -A group can be used for multiple users to communicate with each other on a particular topic/interest. - -### GUID - -* Each group is uniquely identified using GUID. -* The GUID is typically the primary ID of the group from your database. If you do not store group information in your database, you can generate a random string for use as GUID. - - - -GUID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed. - - - -### Types - -CometChat supports three different types of groups: - -| Type | Visibility | Participation | -| -------- | ---------------------------- | ------------------------------------------------- | -| Public | All users | Any user can choose to join | -| Password | All users | Any user with a valid password can choose to join | -| Private | Only users part of the group | Invited users will be auto-joined | - -### Members - -Once a participant joins a group, they become a member of the group. Members are part of the group indefinitely i.e. they will keep receiving messages, calls & notifications. To stop, the participant must either be kicked, banned or intentionally leave the group. - -CometChat supports three different types of member scopes in a group: - -| Member | Default | Privileges | -| ----------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Admin | Group creator is assigned Admin scope | - Change scope of Group Members to admin, moderator or participant. - Can add members to a group. - Kick & Ban Participants/Moderators/Admins - Send & Receive Messages & Calls - Update group - Delete group | -| Moderator | - | - Change scope of moderator or participant. - Update group - Kick & Ban Participants - Send & Receive Messages & Calls | -| Participant | Any other user is assigned Participant scope | - Send & Receive Messages & Calls | - -### Messaging - -Any message in CometChat can belong to either one of the below categories - -| Category | Description | -| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| message | Any message belonging to the category `message` can belong to either one of the below types: 1. text 2. image 3. video 4. audio 5. file | -| custom | Custom messages are an option available for developers to send custom data across to users/groups. To send any additional data that does not fit in the default categories and types provided by CometChat, you can use the custom messages. | -| action | Action messages are system-generated messages. These can belong to either of the below types: 1. groupMember - when the action is performed on a group member 2. message - when the action is performed on a message | -| call | These are call-related messages. These can belong to either one of the two types: 1. audio 2. video | - -For more information, you can refer to the [Message structure and hierarchy guide](/sdk/ionic-legacy/message-structure-and-hierarchy). diff --git a/sdk/ionic-legacy/leave-group.mdx b/sdk/ionic-legacy/leave-group.mdx deleted file mode 100644 index 4c88a09ed..000000000 --- a/sdk/ionic-legacy/leave-group.mdx +++ /dev/null @@ -1,99 +0,0 @@ ---- -title: "Leave A Group" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/leave-group) which provides full compatibility with Ionic applications. - - -## Leave a Group - -In order to stop receiving updates and messages for any particular joined group, you will have to leave the group using the `leaveGroup()` method. - - - -```javascript -var GUID = "GUID"; // guid of the group to join - -CometChat.leaveGroup(GUID).then( -hasLeft => { - console.log("Group left successfully:", hasLeft); -}, error => { - console.log("Group leaving failed with exception:", error); -} -); -``` - - - - -```typescript -var GUID: string = "GUID"; - -CometChat.leaveGroup(GUID).then( - (hasLeft: boolean) => { - console.log("Group left successfully:", hasLeft); - }, (error: CometChat.CometChatException) => { - console.log("Group leaving failed with exception:", error); - } -); -``` - - - - - -| Parameter | Description | -| --------- | -------------------------------------------- | -| `GUID` | The UID of the group you would like to leave | - -Once a group is left, the user will no longer receive any updates or messages pertaining to the group. - -## Real-time Group Member Left Events - -*In other words, as a member of a group, how do I know if someone has left it?* - -If a user leaves any group, The members of the group receive a real-time event in the `onGroupMemberLeft()` method of the `GroupListener` class. - - - -```javascript -CometChat.addGroupListener( - "UNIQUE_LISTENER_ID", - new CometChat.GroupListener({ - onGroupMemberLeft: (message, leavingUser, group) => { - console.log("User left", { message, leavingUser, group }); - } - }) -); -``` - - - - -```typescript -CometChat.addGroupListener( - "UNIQUE_LISTENER_ID", - new CometChat.GroupListener({ - onGroupMemberLeft: (message: CometChat.Action, leavingUser: CometChat.User, group: CometChat.Group) => { - console.log("User left", { message, leavingUser, group }); - } - }) -); -``` - - - - - -## Missed Group Member Left Events - -*In other words, as a member of a group, how do I know if someone has left it when my app is not running?* - -When you retrieve the list of previous messages if a member has left any group that the logged-in user is a member of, the list of messages will contain an `Action` message. An `Action` message is a sub-class of `BaseMessage` class. - -For the group member left event, in the `Action` object received, the following fields can help you get the relevant information- - -1. `action` - `left` -2. `actionBy` - User object containing the details of the user who left the group -3. `actionFor` - Group object containing the details of the group the user has left diff --git a/sdk/ionic-legacy/login-listeners.mdx b/sdk/ionic-legacy/login-listeners.mdx deleted file mode 100644 index 256c10979..000000000 --- a/sdk/ionic-legacy/login-listeners.mdx +++ /dev/null @@ -1,90 +0,0 @@ ---- -title: "Login Listeners" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/login-listener) which provides full compatibility with Ionic applications. - - -The CometChat SDK provides you with real-time updates for the `login` and `logout` events. This can be achieved using the `LoginListener` class provided. LoginListener consists of 4 events that can be triggered. These are as follows: - -| Callback Method | Information | -| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| loginSuccess(user) | Informs you that the login was successful and provides you with a user object containing the data for the user that logged in. | -| loginFailure(event) | Informs you about the failure while logging in the user and provides you with the reason for the failure wrapped in an object of the `CometChatException` class. | -| logoutSuccess() | Informs you about the user being logged out successfully. | -| logoutFailure(event) | Informs you about the failure while logging out the user. The reason for the failure can be obtained from the object of the `CometChatException` class. | - -To add the `LoginListener`, you need to use the `addLoginListener()` method provided by the SDK which takes a unique identifier for the listener and of the the `LoginListener` class itself. - - - -```javascript -let listenerID = "UNIQUE_LISTENER_ID"; -CometChat.addLoginListener( - listenerID, - new CometChat.LoginListener({ - loginSuccess: (e) => { - console.log("LoginListener :: loginSuccess", e); - }, - loginFailure: (e) => { - console.log("LoginListener :: loginFailure", e); - }, - logoutSuccess: () => { - console.log("LoginListener :: logoutSuccess"); - }, - logoutFailure: (e) => { - console.log("LoginListener :: logoutFailure", e); - } - }) -); -``` - - - - -```typescript -var listenerID: string = "UNIQUE_LISTENER_ID"; -CometChat.addLoginListener( - listenerID, - new CometChat.LoginListener({ - loginSuccess: (user: CometChat.User) => { - console.log("LoginListener :: loginSuccess", user); - }, - loginFailure: (error: CometChat.CometChatException) => { - console.log("LoginListener :: loginFailure", error); - }, - logoutSuccess: () => { - console.log("LoginListener :: logoutSuccess"); - }, - logoutFailure: (error: CometChat.CometChatException) => { - console.log("LoginListener :: logoutFailure", error); - } - }) -); -``` - - - - - -In order to stop receiving events related to login and logout you need to use the `removeLoginListener()` method provided by the SDK and pass the ID of the listener that needs to be removed. - - - -```javascript -let listenerID = "UNIQUE_LISTENER_ID"; -CometChat.removeLoginListener(listenerID); -``` - - - - -```typescript -var listenerID: string = "UNIQUE_LISTENER_ID"; -CometChat.removeLoginListener(listenerID); -``` - - - - diff --git a/sdk/ionic-legacy/managing-connections-manually.mdx b/sdk/ionic-legacy/managing-connections-manually.mdx deleted file mode 100644 index 7b28c12bb..000000000 --- a/sdk/ionic-legacy/managing-connections-manually.mdx +++ /dev/null @@ -1,172 +0,0 @@ ---- -title: "Managing Connections Manually" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/managing-web-sockets-connections-manually) which provides full compatibility with Ionic applications. - - -## Default SDK behaviour on login - -When the login method of the SDK is called, the SDK performs the below operations: - -1. Logs the user into the SDK -2. Saves the details of the logged in user locally. -3. Creates a web-socket connection for the logged in user. - -This makes sure that the logged in user starts receiving real-time messages sent to him or any groups that he is a part of as soon as he logs in. - -When the app is reopened, and the init() method is called, the web-socket connection to the server is established automatically. - -This is the default behaviour of the CometChat SDKs. However, if you wish to take control of the web-socket connection i.e if you wish to connect and disconnect to the web-socket server manually, you can refer to the Managing Web-socket Connection section. - -## Manual Mode SDK behaviour - -In manual mode, you have to explicitly establish and disconnect the WebSocket connection. To do this, you need to set the `autoEstablishSocketConnection()` method to `false` and then call the `CometChat.connect()` method to establish the connection and the `CometChat.disconnect()` method to disconnect the connection. - -By default, if manual mode is activated, the SDK will disconnect the WebSocket connection after 30 seconds if the app goes into the background. This means that the WebSocket connection will remain alive for 30 seconds after the app goes into the background, but it will be disconnected after that time if no pings are received. - -To keep the WebSocket connection alive even if your app goes in the background, you need to call the `CometChat.ping()` method from your app within 30 seconds. This method sends a ping message to the CometChat server, which tells the server that the app is still active. - -If you do not call the `CometChat.ping()` method within 30 seconds, the SDK will disconnect the WebSocket connection. This means that you will lose any messages that are sent to your app while it is in the background. - - - - - -| App State | Behaviour | -| ----------------- | ------------------------------------------------------------------------------------------------------------------ | -| App in foreground | Call CometChat.connect() to create the WebSocket connection | -| App in background | Disconnect the WebSocket connection if no ping is received within 30 seconds after the app goes in the background. | - -## Managing Manually - -The CometChat SDK also allows you to modify the above default behaviour of the SDK and take the control of the web-socket connection into your own hands. In order to achieve this, you need to follow the below steps: - -### Enable Manual Mode - -While calling the init() function on the app startup, you need to inform the SDK that you will be managing the web socket connect. You can do so by using the `autoEstablishSocketConnection()` method provided by the `AppSettingsBuilder` class. This method takes a boolean value as an input. If set to `true` , the SDK will manage the web-socket connection internally based on the default behaviour mentioned above. If set to `false` , the web socket connection can will not be managed by the SDK and you will have to handle it manually. You can refer to the below code snippet for the same: - - - -```javascript -let appID = "APP_ID"; -let region = "REGION"; -let appSetting = new CometChat.AppSettingsBuilder() - .subscribePresenceForAllUsers() - .setRegion(region) - .autoEstablishSocketConnection(false) //set it as false for manual mode - .build(); -CometChat.init(appID, appSetting).then( - () => { - console.log("Initialization completed successfully"); - }, - (error) => { - console.log("Initialization failed with error:", error); - } -); -``` - - - - -```typescript -let appID: string = "APP_ID", - region: string = "APP_REGION", - appSetting: CometChat.AppSettings = new CometChat.AppSettingsBuilder() - .subscribePresenceForAllUsers() - .setRegion(region) - .autoEstablishSocketConnection(false) //set it as false for manual mode - .build(); -CometChat.init(appID, appSetting).then( - (initialized: boolean) => { - console.log("Initialization completed successfully", initialized); - }, - (error: CometChat.CometChatException) => { - console.log("Initialization failed with error:", error); - } -); -``` - - - - - -You can manage the connection to the web-socket server using the `connect()` , `disconnect()` and `ping()` methods provided by the SDK. - -### Connect to the web-socket server - -You need to use the `connect()` method provided by the `CometChat` class to establish the connection to the web-socket server. Please make sure that the user is logged in to the SDK before calling this method. You can use the CometChat.getLoggedInUser() method to check this. Once the connection is established, you will start receiving all the real-time events for the logged in user - - - -```javascript -CometChat.connect({onSuccess?: Function, onError?: Function}); -``` - - - - -```typescript -CometChat.connect({ onSuccess: Function, onError: Function }); -``` - - - - - -### Disconnect from the web-socket server - -You can use the `disconnect()` method provided by the `CometChat` class to break the established connection. Once the connection is broken, you will stop receiving all the real-time events for the logged in user. - - - -```javascript -CometChat.disconnect({onSuccess?: Function, onError?: Function}); -``` - - - - -```typescript -CometChat.disconnect({ onSuccess: Function, onError: Function }); -``` - - - - - -### Maintain long-standing background connection - - - -To ensure that the WebSocket connection is always alive, you can create a service or background service that calls the `CometChat.ping()` method in a loop. This will ensure that the ping message is sent to the server every 30 seconds, even if the app is not in the foreground. - - - -You can maintain a long-standing background connection event when your app is in the background, call the `CometChat.ping()` method within 30 seconds of your app entering the background or after the previous ping() call. - - - -```javascript -CometChat.ping({onSuccess?: Function, onError?: Function}); -``` - - - - -```typescript -CometChat.ping({ onSuccess: Function, onError: Function }); -``` - - - - - -## Reconnection - - - -If manual mode is enabled and the app is in the foreground, the SDK will automatically reconnect the WebSocket if the internet connection is lost. However, if the app is in the background and the WebSocket is disconnected or you called `CometChat.disconnect()`, then you will need to call the `CometChat.connect()` method to create a new WebSocket connection. - - diff --git a/sdk/ionic-legacy/mentions.mdx b/sdk/ionic-legacy/mentions.mdx deleted file mode 100644 index 2679397c7..000000000 --- a/sdk/ionic-legacy/mentions.mdx +++ /dev/null @@ -1,371 +0,0 @@ ---- -title: "Mentions" ---- - - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/mentions) which provides full compatibility with Ionic applications. - - - -Mentions in messages enable users to refer to specific individual within a conversation. This is done by using the `<@uid:UID>` format, where `UID` represents the user’s unique identification. - -Mentions are a powerful tool for enhancing communication in messaging platforms. They streamline interaction by allowing users to easily engage and collaborate with particular individuals, especially in group conversations. - -## Send Mentioned Messages - -To send a message with a mentioned user, you must follow a specific format: `<@uid:UID>`. For example, to mention the user with UID `cometchat-uid-1` with the message "`Hello`," your text would be "`Hello, <@uid:cometchat-uid-1>`" - - - -```javascript -let receiverID = "UID"; -let messageText = "Hello, <@uid:cometchat-uid-1>"; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let textMessage = new CometChat.TextMessage( - receiverID, - messageText, - receiverType -); - -CometChat.sendMessage(textMessage).then( - (message) => { - console.log("Message sent successfully:", message); - }, - (error) => { - console.log("Message sending failed with error:", error); - } -); -``` - - - - -```javascript -let receiverID = "GUID"; -let messageText = "Hello <@uid:cometchat-uid-1>"; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; -let textMessage = new CometChat.TextMessage( - receiverID, - messageText, - receiverType -); - -CometChat.sendMessage(textMessage).then( - (message) => { - console.log("Message sent successfully:", message); - }, - (error) => { - console.log("Message sending failed with error:", error); - } -); -``` - - - - -```typescript -let receiverID: string = "UID", - messageText: string = "Hello <@uid:cometchat-uid-1>"; - receiverType: string = CometChat.RECEIVER_TYPE.USER, - textMessage: CometChat.TextMessage = new CometChat.TextMessage(receiverID, messageText, receiverType); - -CometChat.sendMessage(textMessage).then( - (message: CometChat.TextMessage) => { - console.log("Message sent successfully:", message); - }, (error: CometChat.CometChatException) => { - console.log("Message sending failed with error:", error); - } -); -``` - - - - -```typescript -let receiverID: string = "GUID", - messageText: string = "Hello world!", - receiverType: string = CometChat.RECEIVER_TYPE.GROUP, - textMessage: CometChat.TextMessage = new CometChat.TextMessage( - receiverID, - messageText, - receiverType - ); - -CometChat.sendMessage(textMessage).then( - (message: CometChat.TextMessage) => { - console.log("Message sent successfully:", message); - }, - (error: CometChat.CometChatException) => { - console.log("Message sending failed with error:", error); - } -); -``` - - - - - - - -You can mention user in text message and media messages captions - - - -## Mentioned Messages - -By default, the SDK will fetch all the messages irrespective of the fact that the logged-in user is mentioned or not in the message. The SDK has other optional filters such as tags and blocked relationships. - -| Setting | Description | -| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `mentionsWithTagInfo(boolean value)` | If set to `true`, SDK will fetch a list of messages where users are mentioned & will also fetch the tags of the mentioned users. **Default value = false.** | -| `mentionsWithBlockedInfo(boolean value)` | If set to `true`, SDK will fetch a list of messages where users are mentioned & will also fetch their blocked relationship with the logged-in user. **Default value = false.** | - -## Mentions With Tag Info - -To get a list of messages in a conversation where users are mentioned along with the user tags of the mentioned users. - - - -```javascript -let UID = "UID"; -let limit = 30; -var messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .mentionsWithTagInfo(true) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - messages.forEach((eachMessage) => { - eachMessage.getMentionedUsers().forEach((eachMentionedUser) => { - console.log(eachMentionedUser.getTags()); - }); - }); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```javascript -let GUID = "GUID"; -let limit = 30; - -var messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .mentionsWithTagInfo(true) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - messages.forEach((eachMessage) => { - eachMessage.getMentionedUsers().forEach((eachMentionedUser) => { - console.log(eachMentionedUser.getTags()); - }); - }); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .mentionsWithTagInfo(true) - .build(); - -messagesRequest.fetchPrevious().then( - (messages: CometChat.BaseMessage[]) => { - messages.forEach((eachMessage: CometChat.BaseMessage) => { - eachMessage - .getMentionedUsers() - .forEach((eachMentionedUser: CometChat.User) => { - console.log(eachMentionedUser.getTags()); - }); - }); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```typescript -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .mentionsWithTagInfo(true) - .build(); - -messagesRequest.fetchPrevious().then( - (messages: CometChat.BaseMessage[]) => { - messages.forEach((eachMessage: CometChat.BaseMessage) => { - eachMessage - .getMentionedUsers() - .forEach((eachMentionedUser: CometChat.User) => { - console.log(eachMentionedUser.getTags()); - }); - }); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -## Mentions With Blocked Info - -To get a list of messages in a conversation where users are mentioned along with the blocked relationship of the mentioned users with the logged-in user. - - - -```javascript -let UID = "UID"; -let limit = 30; - -var messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .mentionsWithBlockedInfo(true) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - messages.forEach((eachMessage) => { - eachMessage.getMentionedUsers().forEach((eachMentionedUser) => { - console.log("blockedByMe: " + eachMentionedUser.getBlockedByMe()); - console.log("hasBlockedMe: " + eachMentionedUser.getHasBlockedMe()); - }); - }); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```javascript -let GUID = "GUID"; -let limit = 30; - -var messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .mentionsWithBlockedInfo(true) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - messages.forEach((eachMessage) => { - eachMessage.getMentionedUsers().forEach((eachMentionedUser) => { - console.log("blockedByMe: " + eachMentionedUser.getBlockedByMe()); - console.log("hasBlockedMe: " + eachMentionedUser.getHasBlockedMe()); - }); - }); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .mentionsWithBlockedInfo(true) - .build(); - -messagesRequest.fetchPrevious().then( - (messages: CometChat.BaseMessage[]) => { - messages.forEach((eachMessage: CometChat.BaseMessage) => { - eachMessage - .getMentionedUsers() - .forEach((eachMentionedUser: CometChat.User) => { - console.log("blockedByMe: " + eachMentionedUser.getBlockedByMe()); - console.log("hasBlockedMe: " + eachMentionedUser.getHasBlockedMe()); - }); - }); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```typescript -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .mentionsWithBlockedInfo(true) - .build(); - -messagesRequest.fetchPrevious().then( - (messages: CometChat.BaseMessage[]) => { - messages.forEach((eachMessage: CometChat.BaseMessage) => { - eachMessage - .getMentionedUsers() - .forEach((eachMentionedUser: CometChat.User) => { - console.log("blockedByMe: " + eachMentionedUser.getBlockedByMe()); - console.log("hasBlockedMe: " + eachMentionedUser.getHasBlockedMe()); - }); - }); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -## Get Users Mentioned In a Particular Message - -To retrieve the list of users mentioned in the particular message, you can use the `message.getMentionedUsers()` method. This method will return an array containing the mentioned users, or an empty array if no users were mentioned in the message. - -```javascript -message.getMentionedUsers(); -``` diff --git a/sdk/ionic-legacy/message-structure-and-hierarchy.mdx b/sdk/ionic-legacy/message-structure-and-hierarchy.mdx deleted file mode 100644 index 84d9be4b1..000000000 --- a/sdk/ionic-legacy/message-structure-and-hierarchy.mdx +++ /dev/null @@ -1,88 +0,0 @@ ---- -title: "Message" -sidebarTitle: "Message Structure And Hierarchy" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/message-structure-and-hierarchy) which provides full compatibility with Ionic applications. - - -The below diagram helps you better understand the various message categories and types that a CometChat message can belong to. - - - - - -As you can see in the above diagram, every message belongs to a particular category. A message can belong to either one of the 4 categories - -1. Message -2. Custom -3. Action -4. Call - -Each category can be further be classified into types. - -A message belonging to the category `message` can be classified into either 1 of the below types: - -1. text - A plain text message -2. image- An image message -3. video- A video message -4. audio- An audio message -5. file- A file message - -## Custom - -In the case of messages that belong to the `custom` category, there are no predefined types. Custom messages can be used by developers to send messages that do not fit in the default category and types provided by CometChat. For messages with the category `custom`, the developers can set their own type to uniquely identify the custom message. A very good example of a custom message would be the sharing of location co-ordinates. In this case, the developer can decide to use the custom message with type set to `location`. - -## Interactive - -An `InteractiveMessage` is a specialized object that encapsulates an `interactive` unit within a chat message, such as an embedded form that users can fill out directly within the chat interface. Messages belonging to the interactive category can further be classified into one of the below types: - -1. form- for interactive form -2. card- for interactive card -3. customInteractive- for custom interaction messages - - - -to know about Interactive messages please [click here](/sdk/ionic-legacy/interactive-messages) - - - -## Action - -Action messages are system-generated messages. Messages belonging to the `action` category can further be classified into one of the below types: - -1. groupMember - action performed on a group member. -2. message - action performed on a message. - -Action messages hold another property called `action` which actually determine the action that has been performed For the type `groupMember` the action can be either one of the below: - -1. joined - when a group member joins a group -2. left - when a group member leaves a group -3. kicked - when a group member is kicked from the group -4. banned - when a group member is banned from the group -5. unbanned - when a group member is unbanned from the group -6. added - when a user is added to the group -7. scopeChanged - When the scope of a group member is changed. - -For the type `message`, the action can be either one of the below: - -1. edited - when a message is edited. -2. deleted - when a message is deleted. - -## Call - -Messages with the category `call` are Calling related messages. These can belong to either one of the 2 types - -1. audio -2. video - -The call messages have a property called status that helps you figure out the status of the call. The status can be either one of the below values: - -1. initiated - when a is initiated to a user/group -2. ongoing - when the receiver of the call has accepted the call -3. canceled - when the call has been canceled by the initiator of the call -4. rejected - when the call has been rejected by the receiver of the call -5. unanswered - when the call was not answered by the receiver. -6. busy - when the receiver of the call was busy on another call. -7. ended - when the call was successfully completed and ended by either the initiator or receiver. diff --git a/sdk/ionic-legacy/messaging-overview.mdx b/sdk/ionic-legacy/messaging-overview.mdx deleted file mode 100644 index 89632fcac..000000000 --- a/sdk/ionic-legacy/messaging-overview.mdx +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: "Messaging" -sidebarTitle: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/messaging-overview) which provides full compatibility with Ionic applications. - - -Messaging is one of the core features of CometChat. We've thoughtfully created methods to help you send, receive and fetch message history. - -At the minimum, you must add code for [sending messages](/sdk/ionic-legacy/send-message) and [receiving messages](/sdk/ionic-legacy/receive-messages) - -Once you've implemented that, you can proceed to more advanced features like [typing indicators](/sdk/ionic-legacy/typing-indicators) and [delivery & read receipts](/sdk/ionic-legacy/delivery-read-receipts). diff --git a/sdk/ionic-legacy/overview.mdx b/sdk/ionic-legacy/overview.mdx index 47d53a484..6f586124a 100644 --- a/sdk/ionic-legacy/overview.mdx +++ b/sdk/ionic-legacy/overview.mdx @@ -1,325 +1,33 @@ --- -title: "Overview" +title: "Ionic SDK (Legacy)" +description: "The Ionic/Cordova SDK documentation has moved to the legacy archive." --- -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/overview) which provides full compatibility with Ionic applications. +**Deprecated:** The Ionic Cordova SDK is no longer maintained. These docs have been moved to our legacy documentation archive. -This guide demonstrates how to add real-time Ionic chat to a Cordova/Ionic application using CometChat. +## Documentation moved -Before you begin, we strongly recommend you read the [Key Concepts](/sdk/ionic-legacy/key-concepts) guide. +The Ionic/Cordova SDK documentation is now hosted in our **Legacy Documentation Archive**. This includes all versions (v2, v3, and v4). -#### I want to integrate with my app + + View the full Ionic SDK documentation including setup guides, messaging, calling, groups, and more. + -1. [Get your application keys](overview#get-your-application-keys) -2. [Add the CometChat dependency](overview#add-the-cometchat-dependency) -3. [Initialize CometChat](overview#initialize-cometchat) -4. [Register and Login your user](overview#register-and-login-your-user) +## Quick links -### Get your Application Keys +| Section | Link | +|---------|------| +| Overview & Setup | [Ionic SDK Overview](https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/overview.html) | +| v4 (Latest Legacy) | [All v4 pages](https://assets.cometchat.io/legacy-docs/ionic-sdk.html) | +| v3.0 | [All v3 pages](https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/3.0/overview.html) | +| v2.0 | [All v2 pages](https://assets.cometchat.io/legacy-docs/sdk/ionic-legacy/2.0/overview.html) | -[Signup for CometChat](https://app.cometchat.com) and then: +## Recommended alternative -1. Create a new app -2. Head over to the **API & Auth Keys** section and note the **Auth Key**, **App ID** & **Region** +For new Ionic or Cordova applications, use the **JavaScript SDK** which provides full compatibility: -## Add the CometChat Dependency - -Install the package as NPM module: - - - -```bash -npm install @cometchat/chat-sdk-ionic -``` - - - - - - - -The Calling Component (@cometchat/calls-sdk-ionic) is a capacitor plugin so it won't work in a Cordova project. - - - -## Calling Component Configuration - -**Android** - -Goto `./android` folder and open **project-level** build Gradle file and add all repository URLs in the `repositories` block under the `allprojects` section. - - - -```java -allprojects { -repositories { - maven { - url "https://dl.cloudsmith.io/public/cometchat/cometchat/maven/" - } -} -} -``` - - - - - -You also need to update the minimum SDK version to `24`. You can update the minSDKVersion in the `variables.gradle` file located in the `android` folder. - - - -```java -minSdkVersion = 24 -``` - - - - - -For capacitor **v2**, you need to add the Calling Plugin in the Main Activity. The below changes are not required for capacitor **v3** & above. - - - -```java -package io.ionic.starter; - -import android.os.Bundle; - -import com.cometchat.calling.Calling; //Add this line - -import com.getcapacitor.BridgeActivity; -import com.getcapacitor.Plugin; - -import java.util.ArrayList; - -public class MainActivity extends BridgeActivity { -@Override -public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - this.init(savedInstanceState, new ArrayList>() {{ - add(Calling.class); - }}); -} -} -``` - - - - - -**iOS**: - -Please update the minimum target version in the Podfile. Goto **./ios/App** folder and open the Podfile. - - - -``` -platform :ios, '12.0' -``` - - - - - -Open the `ios/App` folder and run `pod install` this will create an `App.xcworkspace` open this and run the app. - -## Initialize CometChat - -The `init()` method initialises the settings required for CometChat. The `init()` method takes the below parameters: - -1. appId - Your CometChat App ID -2. appSettings - An object of the AppSettings class can be created using the AppSettingsBuilder class. The region field is mandatory and can be set using the `setRegion()` method. - -The `AppSettings` class allows you to configure two settings: - -* **Region**: The region where you app was created. -* [Presence Subscription](/sdk/ionic-legacy/user-presence): Represents the subscription type for user presence (real-time online/offline status) -* **autoEstablishSocketConnection(boolean value)**: This property takes a boolean value which when set to `true` informs the SDK to manage the web-socket connection internally. If set to `false` , it informs the SDK that the web-socket connection will be managed manually. The default value for this parameter is true. For more information on this, please check the [Managing connections manually](/sdk/ionic-legacy/managing-connections-manually)section. The default value for this property is **true.** -* **overrideAdminHost(adminHost: string)**: This method takes the admin URL as input and uses this admin URL instead of the default admin URL. This can be used in case of dedicated deployment of CometChat. -* **overrideClientHost(clientHost: string)**: This method takes the client URL as input and uses this client URL instead of the default client URL. This can be used in case of dedicated deployment of CometChat. - -You need to call `init()` before calling any other method from 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) - .autoEstablishSocketConnection(true) - .build(); -CometChat.init(appID, appSetting).then( - () => { - console.log("Initialization completed successfully"); - }, - (error) => { - console.log("Initialization failed with error:", error); - } -); -``` - - - - -```typescript -let appID: string = "APP_ID", - region: string = "APP_REGION", - appSetting: CometChat.AppSettings = new CometChat.AppSettingsBuilder() - .subscribePresenceForAllUsers() - .setRegion(region) - .autoEstablishSocketConnection(true) - .build(); -CometChat.init(appID, appSetting).then( - (initialized: boolean) => { - console.log("Initialization completed successfully", initialized); - }, - (error: CometChat.CometChatException) => { - console.log("Initialization failed with error:", error); - } -); -``` - - - - - -Make sure you replace the `APP_ID` with your CometChat **App ID** and `REGION` with your **App Region** in the above code. - -## Register and Login your user - -Once initialization is successful, you will need to create a user. To create users on the fly, you can use the `createUser()` method. This method takes a `User` object and the `Auth Key` as input parameters and returns the created `User` object if the request is successful. - - - -```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); - } -); -``` - - - - -```typescript -let authKey: string = "AUTH_KEY", - UID: string = "user1", - name: string = "Kevin"; - -var user = new CometChat.User(UID); - -user.setName(name); - -CometChat.createUser(user, authKey).then( - (user: CometChat.User) => { - console.log("user created", user); - }, - (error: CometChat.CometChatException) => { - console.log("error", error); - } -); -``` - - - - - -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. - -We recommend you call the CometChat `login()` method once your user logs into your app. The `login()` method needs to be called only once. - - - -This straightforward authentication method is ideal for proof-of-concept (POC) development or during the early stages of application development. For production environments, however, we strongly recommend using an [Auth Token](/sdk/ionic-legacy/authentication#login-using-auth-token) instead of an Auth Key to ensure enhanced security. - - - - - -```javascript -var UID = "cometchat-uid-1"; -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 }); - } - ); - } - }, - (error) => { - console.log("Some Error Occured", { error }); - } -); -``` - - - - -```typescript -var UID: string = "cometchat-uid-1", - authKey: string = "AUTH_KEY"; - -CometChat.getLoggedinUser().then( - (user: CometChat.User) => { - if (!user) { - CometChat.login(UID, authKey).then( - (user: CometChat.User) => { - console.log("Login Successful:", { user }); - }, - (error: CometChat.CometChatException) => { - console.log("Login failed with exception:", { error }); - } - ); - } - }, - (error: CometChat.CometChatException) => { - console.log("Some Error Occured", { error }); - } -); -``` - - - - - -Make sure you replace the `AUTH_KEY` with your CometChat **Auth Key** in the above code. - - -Sample Users - -We have set-up 5 users for testing having UIDs: `cometchat-uid-1`, `cometchat-uid-2`, `cometchat-uid-3`, `cometchat-uid-4` and `cometchat-uid-5`. - - - -The `login()` method returns the `User` object containing all the information of the logged-in user. - - - -UID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed. - - + + The JavaScript SDK works with Ionic, Cordova, and all web-based frameworks. + diff --git a/sdk/ionic-legacy/presenter-mode.mdx b/sdk/ionic-legacy/presenter-mode.mdx deleted file mode 100644 index 614ac366e..000000000 --- a/sdk/ionic-legacy/presenter-mode.mdx +++ /dev/null @@ -1,144 +0,0 @@ ---- -title: "Presenter Mode" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/presenter-mode) which provides full compatibility with Ionic applications. - - -## Overview - -The Presenter Mode feature allows developers to create a calling service experience in which: - -1. There are one or more users who are presenting their video, audio and/or screen (Maximum 5) -2. Viewers who are consumers of that presentation. (They cannot send their audio, video or screen streams out). -3. The total number of presenters and viewers can go up to 100. -4. Features such as mute/unmute audio, show/hide camera capture, recording, etc. will be enabled only for the Presenter in this mode. -5. Other call participants will not get these features. Hence they act like passive viewers in the call. - -Using this feature developers can create experiences such as: - -1. All hands calls -2. Keynote speeches -3. Webinars -4. Talk shows -5. Online classes -6. and many more... - -### About this guide - -This guide demonstrates how to start a presentation into an React Native application. Before you begin, we strongly recommend you read the calling setup guide. - -Before starting a call session you have to generate a call token. You need to call this method for the call token. - -### Start Presentation Session - -The most important class that will be used in the implementation is the `PresentationSettings` class. This class allows you to set the various parameters for the Presentation Mode. In order to set the various parameters of the `PresentationSettings` class, you need to use the `PresentationSettingsBuilder` class. Below are the various options available with the `PresentationSettings` class. - -You will need to set the User Type, There are 2 type of users in Presenter Mode, `Presenter` & `Participant` , You can set this `PresentationSettingsBuilder` by using the following method `setIsPresenter(true/false)` - -A basic example of how to start a Presentation: - - - -```javascript -let presenterSettings = new CometChatCalls.PresenterSettingsBuilder() - .setIsPresenter(isPresenter) - .enableDefaultLayout(defaultLayout) - .setCallEventListener(callListener) - .build(); - -CometChatCalls.joinPresentation(presenterSettings, callToken); -``` - - - - - -## **Listeners** - -Listeners can be added in two ways the first one is to use `.setCallEventListener(listeners : OngoingCallListener)` method in `CallSettingsBuilder` or `PresenterSettingsBuilder` class. The second way is to use `CometChatCalls.addCallEventListener(name: string, callListener: OngoingCallListener)` by this you can add multiple listeners and remove the specific listener by their name `CometChatCalls.removeCallEventListener(name: string)` - - - -```javascript -useEffect(() => { - CometChatCalls.addCallEventListener("UNIQUE_ID", { - onUserJoined: (user) => { - console.log("user joined:", user); - }, - onUserLeft: (user) => { - console.log("user left:", user); - }, - onUserListUpdated: (userList) => { - console.log("user list:", userList); - }, - onCallEnded: () => { - console.log("Call ended"); - }, - onCallEndButtonPressed: () => { - console.log("End Call button pressed"); - }, - onError: (error) => { - console.log("Call Error: ", error); - }, - onAudioModesUpdated: (audioModes) => { - console.log("audio modes:", audioModes); - }, - onUserMuted: (event) => { - console.log("user muted:", event); - }, - }); - return () => CometChatCalls.removeCallEventListener("UNIQUE_ID"); -}, []); -``` - - - - - -The `CometChatCallsEventsListener` listener provides you with the below callback methods: - -| Callback Method | Description | -| ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | -| onCallEnded() | This method is called when the call is successfully ended. The call details can be obtained from the `Call` object provided. | -| onCallEndButtonPressed() | This method is called when the user press end call button. | -| onUserJoined(user: RTCUser) | This method is called when any other user joins the call. The user details can be obtained from the `User` object provided. | -| onUserLeft(user: RTCUser) | This method is called when a user leaves the call. The details of the user can be obtained from the provided `User` object. | -| onUserListUpdated(users: Array\) | This method is triggered every time a participant joins or leaves the call providing the list of users active in the call | -| onAudioModesUpdated(devices: Array\) | This callback is triggered if any new audio output source is available or becomes unavailable. | -| onUserMuted(muteObj: RTCMutedUser) | This method is triggered when a user is muted in the ongoing call. | -| onRecordingStarted(user: RTCUser) | This method is triggered when a recording starts. | -| onRecordingStopped(user: RTCUser) | This method is triggered when a recording stops. | -| onError(e: CometChatException) | This method is called when there is some error in establishing the call. | - -## Settings - -The `PresentationSettings` class is the most important class when it comes to the implementation of the Calling feature. This is the class that allows you to customize the overall calling experience. The properties for the call/conference can be set using the `PresentationSettingsBuilder` class. This will eventually give you and object of the `PresentationSettings` class which you can pass to the `joinPresentation()` method to start the call. - -The **mandatory** parameters that are required to be present for any call/conference to work are: - -1. Context - context of the activity/application -2. RelativeLayout - A RelativeLayout object in which the calling UI is loaded. - -The options available for customization of calls are: - -| Parameter | Description | -| ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `setIsPresenter(isPresenter: boolean)` | If set to `true` user will join as the presenter. If set to `false` user will join as the viewer. | -| `enableDefaultLayout(defaultLayout: boolean)` | If set to `true` enables the default layout for handling the call operations. If set to `false` it hides the button layout and just displays the Call View. **Default value = true** | -| `showEndCallButton(showEndCallButton: boolean)` | If set to `true` it displays the EndCallButton in Button Layout. If set to `false` it hides the EndCallButton in Button Layout. **Default value = true** | -| `showPauseVideoButton(showPauseVideoButton: boolean)` | If set to `true` it displays the PauseVideoButton in Button Layout. If set to `false` it hides the PauseVideoButton in Button Layout. **Default value = true** | -| `showMuteAudioButton`(showMuteAudioButton: boolean)\`\` | If set to `true` it displays the MuteAudioButton in Button Layout. If set to `false` it hides the MuteAudioButton in Button Layout. **Default value = true** | -| `showSwitchCameraButton`(showSwitchCameraButton: boolean)\`\` | If set to `true` it displays the SwitchCameraButton in Button Layout. If set to `false` it hides the SwitchCameraButton in Button Layout. **Default value = true** | -| `showAudioModeButton`(showAudioModeButton: boolean)\`\` | If set to `true` it displays the AudioModeButton in Button Layout. If set to `false` it hides the AudioModeButton in Button Layout. **Default value = true** | -| `setIsAudioOnlyCall(audioOnly: boolean)` | If set to `true`, the call will be strictly an audio call. If set to `false`, the call will be an audio-video call.**Default value = false** | -| `startWithAudioMuted(audioMuted: boolean)` | This ensures the call is started with the audio muted if set to true. **Default value = false** | -| `startWithVideoMuted(videoMuted: boolean)` | This ensures the call is started with the video paused if set to true. **Default value = false** | -| `startWithVideoMuted(videoMuted: boolean)` | If set to true it displays the Recording in Button Layout. if set to false it hides the Recording in Button Layout. **Default value = false** | -| `setDefaultAudioMode(audioMode: string)` | This method can be used if you wish to start the call with a specific audio mode. The available options are 1. CometChatCalls.AUDIO\_MODE.SPEAKER = "SPEAKER" 2. CometChatCalls.AUDIO\_MODE.EARPIECE = "EARPIECE" 3. CometChatCalls.AUDIO\_MODE.BLUETOOTH = "BLUETOOTH" 4. CometChatCalls.AUDIO\_MODE.HEADPHONES = "HEADPHONES" | -| `setEventListener(new CometChatCallsEventsListener())` | The `CometChatCallsEventsListener` listener provides you callbacks | - -In case you wish to achieve a completely customised UI for the Calling experience, you can do so by embedding default android buttons to the screen as per your requirement and then use the below methods to achieve different functionalities for the embedded buttons. - -For the use case where you wish to align your own custom buttons and not use the default layout provided by CometChat you can embed the buttons in your layout and use the below methods to perform the corresponding operations: diff --git a/sdk/ionic-legacy/rate-limits.mdx b/sdk/ionic-legacy/rate-limits.mdx deleted file mode 100644 index 2db6d57c0..000000000 --- a/sdk/ionic-legacy/rate-limits.mdx +++ /dev/null @@ -1,36 +0,0 @@ ---- -title: "Rate Limits" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/rate-limits) which provides full compatibility with Ionic applications. - - -### CometChat REST API Rate Limits - - - -The rate limits below are for general applications. Rate limits can be adjusted on a per need basis, depending on your use-case and plan. The rate limits are cumulative. For example: If the rate limit for core operations is 100 requests per minute, then you can either login a user, add user to a group, remove a user from a group, etc for total 100 requests per minute. - - - -1. **Core Operations:** Core operations are rate limited to `10,000` requests per minute. Core operations include user login, create/delete user, create/join group cumulatively. -2. **Standard Operations:** Standard operations are rate limited to `20,000` requests per minute. Standard operations include all other operations cumulatively. - -## What happens when rate limit is reached ? - -The request isn't processed and a response is sent containing a 429 response code. Along with the response code there will be couple of headers sent which specifies the time in seconds that you must wait before you can try request again. - -`Retry-After: 15` - -`X-Rate-Limit-Reset: 1625143246` - -## Is there any endpoint that returns rate limit of all resources ? - -No, we don't provide a rate-limit endpoint. - -However, we do provide the following response headers that you can use to confirm the app's current rate limit and monitor the number of requests remaining in the current minute: - -`X-Rate-Limit: 700` - -`X-Rate-Limit-Remaining: 699` diff --git a/sdk/ionic-legacy/reactions.mdx b/sdk/ionic-legacy/reactions.mdx deleted file mode 100644 index 68d05616f..000000000 --- a/sdk/ionic-legacy/reactions.mdx +++ /dev/null @@ -1,363 +0,0 @@ ---- -title: "Reactions" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/reactions) which provides full compatibility with Ionic applications. - - -Enhance user engagement in your chat application with message reactions. Users can express their emotions using reactions to messages. This feature allows users to add or remove reactions, and to fetch all reactions on a message. You can also listen to reaction events in real-time. Let's see how to work with reactions in CometChat's SDK. - -## Add a Reaction - -Users can add a reaction to a message by calling `addReaction` with the message ID and the reaction emoji. - - - -```javascript -let messageId = "1"; -let emoji = "😊"; - -CometChat.addReaction(messageId, emoji) -.then((res) => { - console.log('response', res); -}).catch(err => { - console.log('err', err); -}) -``` - - - - -```typescript -let messageId:string = "1"; -let emoji:string = "😊"; - -CometChat.addReaction(messageId, emoji) -.then((res:CometChat.BaseMessage) => { - console.log('response', res); -}).catch((err:CometChat.CometChatException) => { - console.log('err', err); -}) -``` - - - - - - - -You can react on text message, media message and custom message - - - -## Remove a Reaction - -Removing a reaction from a message can be done using the `removeReaction` method. - - - -```javascript -let messageId = "1"; -let emoji = "😊"; - -CometChat.removeReaction(messageId, emoji) -.then((res) => { - console.log('response', res); -}).catch(err => { - console.log('err', err); -}) -``` - - - - -```typescript -let messageId:string = "1"; -let emoji:string = "😊"; - -CometChat.removeReaction(messageId, emoji) -.then((res:CometChat.BaseMessage) => { - console.log('response', res); -}).catch((err:CometChat.CometChatException) => { - console.log('err', err); -}) -``` - - - - - -## Fetch Reactions for a Message - -To get all reactions for a specific message, first create a `ReactionRequest` using `ReactionRequestBuilder`. You can specify the number of reactions to fetch with `setLimit` with max limit 100. For this, you will require the ID of the message. This ID needs to be passed to the `setMessageId()` method of the builder class. The `setReaction()` will allow you to fetch details for specific reaction or emoji. - -| Setting | Description | -| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `setMessageId(value)` | Specifies the unique identifier of the message for which you want to fetch reactions. This parameter is mandatory as it tells the SDK which message's reactions are being requested. | -| `setReaction(value)` | Filters the reactions fetched by the specified reaction type (e.g., "😊", "😂", "👍"). When set, this method will cause the ReactionRequest to only retrieve details of the provided reaction for the given message. | - -## Fetch Next - -The `fetchNext()` method fetches the next set of reactions for the message. - - - -```javascript -let limit = 10; -let messageId = 1; - -let reactionRequest = new CometChat.ReactionRequestBuilder() -.setMessageId(messageId) -.setLimit(limit) -.build(); - -reactionRequest.fetchNext().then( - messages => { - console.log("list fetched:", messages); - }, - error => {a - console.log('list fetching failed with error:', error); - }, - ); -``` - - - - -```typescript -let limit:number = 10; -let messageId:number = 1; - -let reactionRequest = new CometChat.ReactionRequestBuilder() -.setMessageId(messageId) -.setLimit(limit) -.build(); - -reactionRequest.fetchNext().then( - (messages: MessageReaction[]) => { - console.log("list fetched:", messages); - }, - (error: CometChat.CometChatException) => { - console.log('list fetching failed with error:', error); - }, - ); -``` - - - - - -## Fetch Previous - -The `fetchPrevious()` method fetches the previous set of reactions for the message. - - - -```javascript -let limit = 10; -let messageId = 1; - -let reactionRequest = new CometChat.ReactionRequestBuilder() -.setMessageId(messageId) -.setLimit(limit) -.build(); - -reactionRequest.fetchPrevious().then( - messages => { - console.log("list fetched:", messages); - }, - error => {a - console.log('list fetching failed with error:', error); - }, - ); -``` - - - - -```typescript -let limit:number = 10; -let messageId:number = 1; - -let reactionRequest = new CometChat.ReactionRequestBuilder() -.setMessageId(messageId) -.setLimit(limit) -.build(); - -reactionRequest.fetchPrevious().then( - (messages: MessageReaction[]) => { - console.log("list fetched:", messages); - }, - (error: CometChat.CometChatException) => { - console.log('list fetching failed with error:', error); - }, - ); -``` - - - - - -## Real-time Reaction Events - -Keep the chat interactive with real-time updates for reactions. Register a listener for these events and make your UI responsive. - - - -```javascript -let listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener(listenerID, { - onMessageReactionAdded:(message) => { - console.log("Reaction added", message); - }, - onMessageReactionRemoved:(message) => { - console.log("Reaction removed", message); - } - }) -``` - - - - -```typescript -let listenerID:string = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener(listenerID, { - onMessageReactionAdded:(message: Object) => { - console.log("Reaction added", message); - }, - onMessageReactionRemoved:(message: Object) => { - console.log("Reaction removed", message); - } - }) -``` - - - - - -## Removing a Reaction Listener - -To stop listening for reaction events, remove the listener as follows: - - - -```javascript -let listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.removeMessageListener(listenerID); -``` - - - - -```typescript -let listenerID:string = "UNIQUE_LISTENER_ID"; - -CometChat.removeMessageReactionListener(listenerID); -``` - - - - - -## Get Reactions List - -To retrieve the list of reactions reacted on particular message, you can use the `message.getReactions()` method. This method will return an array containing the reactions, or an empty array if no one reacted on the message. - - - -```javascript -message.getReactions() -``` - - - - -```typescript -message.getReactions() -``` - - - - - -## Check if Logged-in User has Reacted on Message - -To check if the logged-in user has reacted on a particular message or not, You can use the `getReactedByMe()` method on any `ReactionCount` object instance. This method will return a boolean value, `true` if the logged-in user has reacted on that message, otherwise `false`. - - - -```javascript -let reactions = message.getReactions(); -reactions.forEach((reaction) => { -reaction.getReactedByMe(); //Return true is logged-in user reacted on that message, otherwise false -}) -``` - - - - -```typescript -let reactions:CometChat.ReactionCount[] = message.getReactions(); -reactions.forEach((reaction:CometChat.ReactionCount) => { -reaction.getReactedByMe(); //Return true is logged-in user reacted on that message, otherwise false -}) -``` - - - - - -## Update Message With Reaction Info - -When a user adds or removes a reaction, you will receive a real-time event. Once you receive the real time event you would want to update the message with the latest reaction information. To do so you can use the `updateMessageWithReactionInfo()` method. - -The `updateMessageWithReactionInfo()` method provides a seamless way to update the reactions on a message instance (`BaseMessage`) in real-time. This method ensures that when a reaction is added or removed from a message, the `BaseMessage` object's `getReactions()` property reflects this change immediately. - -When you receive a real-time reaction event (`MessageReaction`), call the `updateMessageWithReactionInfo()` method, passing the `BaseMessage` instance (`message`), event data (`MessageReaction`) and reaction event action type (`CometChat.REACTION_ACTION.REACTION_ADDED` or `CometChat.REACTION_ACTION.REACTION_REMOVED`) that corresponds to the message being reacted to. - - - -```javascript -// The message to which the reaction is related -let message = ...; - -// The reaction event data received in real-time -let messageReaction = ...; - -// The recieved reaction event real-time action type. Can be CometChatConstants.REACTION_ADDED or CometChatConstants.REACTION_REMOVED -let action = CometChat.REACTION_ACTION.REACTION_ADDED; - -let modifiedBaseMessage = CometChat.CometChatHelper.updateMessageWithReactionInfo( -baseMessage, -messageReaction, -action -); -``` - - - - -```typescript -// The message to which the reaction is related -let message: CometChat.BaseMessage = ...; - -// The reaction event data received in real-time -let messageReaction: CometChat.MessageReaction = ...; - -// The recieved reaction event real-time action type. Can be CometChatConstants.REACTION_ADDED or CometChatConstants.REACTION_REMOVED -let action: CometChat.REACTION_ACTION = CometChat.REACTION_ACTION.REACTION_ADDED; - -let modifiedBaseMessage = CometChat.CometChatHelper.updateMessageWithReactionInfo( -baseMessage, -messageReaction, -action -); -``` - - - - diff --git a/sdk/ionic-legacy/real-time-listeners.mdx b/sdk/ionic-legacy/real-time-listeners.mdx deleted file mode 100644 index e53ced7e7..000000000 --- a/sdk/ionic-legacy/real-time-listeners.mdx +++ /dev/null @@ -1,528 +0,0 @@ ---- -title: "All Real Time Listeners" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/all-real-time-listeners) which provides full compatibility with Ionic applications. - - -CometChat provides 4 listeners viz. - -1. [User Listener](#user-listener) -2. [Group Listener](#group-listener) -3. [Message Listener](#message-listener) -4. [Call Listener](#call-listener) - -## User Listener - -The `UserListener` class provides you with live events related to users. Below are the callback methods provided by the `UserListener` class. - -| Method | Information | -| --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **onUserOnline(user: CometChat.User)** | This method is triggered when a user comes online and is available to chat. The details of the user can be obtained from the user object received as the method parameter. | -| **onUserOffline(user: CometChat.User)** | This method is triggered when a user goes offline. The details of the user can be obtained from the User object received as the parameter. | - -To add the `UserListener`, you need to use the `addUserListener()` method provided by the `CometChat` class. - - - -```javascript -var listenerID = "UNIQUE_LISTENER_ID"; -CometChat.addUserListener( - listenerID, - new CometChat.UserListener({ - onUserOnline: (onlineUser) => { - console.log("On User Online:", { onlineUser }); - }, - onUserOffline: (offlineUser) => { - console.log("On User Offline:", { offlineUser }); - }, - }) -); -``` - - - - -```typescript -var listenerID: string = "UNIQUE_LISTENER_ID"; -CometChat.addUserListener( - listenerID, - new CometChat.UserListener({ - onUserOnline: (onlineUser: CometChat.User) => { - /* when someuser/friend comes online, user will be received here */ - console.log("On User Online:", { onlineUser }); - }, - onUserOffline: (offlineUser: CometChat.User) => { - /* when someuser/friend went offline, user will be received here */ - console.log("On User Offline:", { offlineUser }); - }, - }) -); -``` - - - - - -where `UNIQUE_LISTENER_ID` is the unique identifier for the listener. Please make sure that no two listeners are added with the same listener id as this could lead to unexpected behavior resulting in loss of events. - -Once the `UserListener` is not in use, you need to remove the listener using the `removeUserListener()` method which takes the id of the listener to be removed as the parameter. - - - -```javascript -CometChat.removeUserListener(UNIQUE_LISTENER_ID); -``` - - - - -```typescript -let listenerID: string = "UNIQUE_LISTENER_ID"; -CometChat.removeUserListener(listenerID); -``` - - - - - -## Group Listener - -The `GroupListener` class provides you with all the real-time events related to groups. Below are the callback methods provided by the `GroupListener` class. - -| Method | Information | -| ------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| **onGroupMemberJoined(action: CometChat.Action, joinedUser: CometChat.User, joinedGroup: CometChat.Group)** | This method is triggered when a user joins any group. All the members present in the group will receive this event. | -| **onGroupMemberLeft(action: CometChat.Action, leftUser: CometChat.User, leftGroup: CometChat.Group)** | This method is triggered when a user who was a member of any group leaves the group. All the members of the group receive this event. | -| **onGroupMemberKicked(action: CometChat.Action, kickedUser: CometChat.User, kickedBy: CometChat.User, kickedFrom: CometChat.Group)** | This method is triggered when a user is kicked from a group. All the members including the user receive this event | -| **onGroupMemberBanned(action: CometChat.Action, bannedUser: CometChat.User, bannedBy: CometChat.User, bannedFrom: CometChat.Group)** | This method is triggered when a user is banned from a group. All the members including the user receive this event | -| **onGroupMemberUnbanned(action: CometChat.Action, unbannedUser: CometChat.User, unbannedBy: CometChat.User, unbannedFrom: CometChat.Group)** | This method is triggered when a user is banned from a group. All the members of the group receive this event. | -| **onGroupMemberScopeChanged(action: CometChat.Action, changedUser: CometChat.User, newScope: string, oldScope: string, changedGroup: CometChat.Group)** | This method is triggered when the scope of any Group Member has been changed. All the members that are a part of that group receive this event | -| **onMemberAddedToGroup(action: CometChat.Action, userAdded: CometChat.User, addedBy: CometChat.User, addedTo: CometChat.Group)** | This method is triggered when a user is added to any group. All the members including the user himself receive this event. | - -To add the `GroupListener`, you need to use the `addGroupListener()` method provided by the `CometChat` class. - - - -```javascript -CometChat.addGroupListener( - "UNIQUE_LISTENER_ID", - new CometChat.GroupListener({ - onGroupMemberJoined: (message, joinedUser, joinedGroup) => { - console.log("onGroupMemberJoined", { message, joinedUser, joinedGroup }); - }, - onGroupMemberLeft: (message, leftUser, leftGroup) => { - console.log("onGroupMemberLeft", { message, leftUser, leftGroup }); - }, - onGroupMemberKicked: (message, kickedUser, kickedBy, kickedFrom) => { - console.log("onGroupMemberKicked", { - message, - kickedUser, - kickedBy, - kickedFrom, - }); - }, - onGroupMemberBanned: (message, bannedUser, bannedBy, bannedFrom) => { - console.log("onGroupMemberBanned", { - message, - bannedUser, - bannedBy, - bannedFrom, - }); - }, - onGroupMemberUnbanned: ( - message, - unbannedUser, - unbannedBy, - unbannedFrom - ) => { - console.log("onGroupMemberUnbanned", { - message, - unbannedUser, - unbannedBy, - unbannedFrom, - }); - }, - onGroupMemberScopeChanged: ( - message, - changedUser, - newScope, - oldScope, - changedGroup - ) => { - console.log("onGroupMemberScopeChanged", { - message, - changedUser, - newScope, - oldScope, - changedGroup, - }); - }, - onMemberAddedToGroup: (message, userAdded, addedby, addedTo) => { - console.log("onMemberAddedToGroup", { - message, - userAdded, - addedby, - addedTo, - }); - }, - }) -); -``` - - - - -```typescript -CometChat.addGroupListener( - "UNIQUE_LISTENER_ID", - new CometChat.GroupListener({ - onGroupMemberJoined: ( - message: CometChat.Action, - joinedUser: CometChat.User, - joinedGroup: CometChat.Group - ) => { - console.log("onGroupMemberJoined", { message, joinedUser, joinedGroup }); - }, - onGroupMemberLeft: ( - message: CometChat.Action, - leftUser: CometChat.User, - leftGroup: CometChat.Group - ) => { - console.log("onGroupMemberLeft", { message, leftUser, leftGroup }); - }, - onGroupMemberKicked: ( - message: CometChat.Action, - kickedUser: CometChat.User, - kickedBy: CometChat.User, - kickedFrom: CometChat.Group - ) => { - console.log("onGroupMemberKicked", { - message, - kickedUser, - kickedBy, - kickedFrom, - }); - }, - onGroupMemberBanned: ( - message: CometChat.Action, - bannedUser: CometChat.User, - bannedBy: CometChat.User, - bannedFrom: CometChat.Group - ) => { - console.log("onGroupMemberBanned", { - message, - bannedUser, - bannedBy, - bannedFrom, - }); - }, - onGroupMemberUnbanned: ( - message: CometChat.Action, - unbannedUser: CometChat.User, - unbannedBy: CometChat.User, - unbannedFrom: CometChat.Group - ) => { - console.log("onGroupMemberUnbanned", { - message, - unbannedUser, - unbannedBy, - unbannedFrom, - }); - }, - onGroupMemberScopeChanged: ( - message: CometChat.Action, - changedUser: CometChat.User, - newScope: string, - oldScope: string, - changedGroup: CometChat.Group - ) => { - console.log("onGroupMemberScopeChanged", { - message, - changedUser, - newScope, - oldScope, - changedGroup, - }); - }, - onMemberAddedToGroup: ( - message: CometChat.Action, - userAdded: CometChat.User, - addedby: CometChat.User, - addedTo: CometChat.Group - ) => { - console.log("onMemberAddedToGroup", { - message, - userAdded, - addedby, - addedTo, - }); - }, - }) -); -``` - - - - - -where `UNIQUE_LISTENER_ID` is the unique identifier for the listener. Please make sure that no two listeners are added with the same listener id as this could lead to unexpected behavior resulting in loss of events. - -Once the `GroupListener` is not in use, you need to remove the listener using the `removeGroupListener()` method which takes the id of the listener to be removed as the parameter. - - - -```javascript -CometChat.removeGroupListener(UNIQUE_LISTENER_ID); -``` - - - - -```typescript -let listenerID: string = "UNIQUE_LISTENER_ID"; -CometChat.removeGroupListener(listenerID); -``` - - - - - -## Message Listener - -The `MessageListener` class provides you with live events related to messages. Below are the callback methods provided by the `MessageListener` class. - -| Method | Information | -| ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | -| **onTextMessageReceived(message: CometChat.TextMessage)** | This event is triggered when a Text Message is received. | -| **onMediaMessageReceived(message: CometChat.MediaMessage)** | This event is triggered when a Media Message is received. | -| **onCustomMessageReceived(message: CometChat.CustomMessage)** | This event is triggered when a Custom Message is received. | -| **onTypingStarted(typingIndicator: CometChat.TypingIndicator)** | This event is triggered when a user starts typing in a user/group conversation | -| **onTypingEnded(typingIndicator: CometChat.TypingIndicator)** | This event is triggered when a user stops typing in a user/group conversation. | -| **onMessagesDelivered(messageReceipt: CometChat.MessageReceipt)** | This event is triggered when a set of messages are marked as delivered for any particular conversation. | -| **onMessagesRead(messageReceipt: CometChat.MessageReceipt)** | This event is triggered when a set of messages are marked as read for any particular conversation. | -| **onMessageEdited(message: CometChat.BaseMessage)** | This method is triggered when a particular message has been edited in a user/group conversation. | -| **onMessageDeleted(message: CometChat.BaseMessage)** | This event is triggered when a particular message is deleted in a user/group conversation. | -| **onInteractiveMessageReceived(message: CometChat.InteractiveMessage)** | This event is triggered when an Interactive Message is received. | -| **onInteractionGoalCompleted(receipt: CometChat.InteractionReceipt)** | This event is triggered when an interaction Goal is achieved. | -| **onTransientMessageReceived(receipt: CometChat.TransientMessage)** | This event is triggered when a Transient Message is received. | -| **onMessageReactionAdded(receipt: CometChat.ReactionEvent)** | This event is triggered when a reaction is added to a message in a user/group conversation. | -| **onMessageReactionRemoved(receipt: CometChat.ReactionEvent)** | This event is triggered when a reaction is remove from a message in a user/group conversation. | - -To add the `MessageListener`, you need to use the `addMessageListener()` method provided by the `CometChat` class. - - - -```javascript -CometChat.addMessageListener( - "UNIQUE_LISTENER_ID", - new CometChat.MessageListener({ - onTextMessageReceived: (textMessage) => { - console.log("Text message received successfully", textMessage); - }, - onMediaMessageReceived: (mediaMessage) => { - console.log("Media message received successfully", mediaMessage); - }, - onCustomMessageReceived: (customMessage) => { - console.log("Custom message received successfully", customMessage); - }, - onMessagesDelivered: (messageReceipt) => { - console.log("Message Delivered", messageReceipt); - }, - onMessagesRead: (messageReceipt) => { - console.log("Message Read", messageReceipt); - }, - onTypingStarted: (typingIndicator) => { - console.log("Typing Started", typingIndicator); - }, - onTypingEnded: (typingIndicator) => { - console.log("Typing Ended", typingIndicator); - }, - onMessageDeleted: (message) => { - console.log("Message Delted", message); - }, - onMessageEdited: (message) => { - console.log("Message Edited", message); - }, - onInteractiveMessageReceived: (message) => { - console.log("interactive Message received", message); - }, - onInteractionGoalCompleted: (message) => { - console.log("Message interaction goal completed", message); - }, - onTransientMessageReceived: (message) => { - console.log("Transient Message received", message); - }, - onMessageReactionAdded: (reaction) => { - console.log("Message Reaction added", reaction); - }, - onMessageReactionRemoved: (reaction) => { - console.log("Message Reaction removed", reaction); - }, - }) -); -``` - - - - -```typescript -CometChat.addMessageListener( - "UNIQUE_LISTENER_ID", - new CometChat.MessageListener({ - onTextMessageReceived: (textMessage: CometChat.TextMessage) => { - console.log("Text message received successfully", textMessage); - }, - onMediaMessageReceived: (mediaMessage: CometChat.MediaMessage) => { - console.log("Media message received successfully", mediaMessage); - }, - onCustomMessageReceived: (customMessage: CometChat.CustomMessage) => { - console.log("Custom message received successfully", customMessage); - }, - onMessagesDelivered: (messageReceipt: CometChat.MessageReceipt) => { - console.log("Message Delivered", messageReceipt); - }, - onMessagesRead: (messageReceipt: CometChat.MessageReceipt) => { - console.log("Message Read", messageReceipt); - }, - onTypingStarted: (typingIndicator: CometChat.TypingIndicator) => { - console.log("Typing Started", typingIndicator); - }, - onTypingEnded: (typingIndicator: CometChat.TypingIndicator) => { - console.log("Typing Ended", typingIndicator); - }, - onMessageDeleted: (message: CometChat.BaseMessage) => { - console.log("Message Delted", message); - }, - onMessageEdited: (message: CometChat.BaseMessage) => { - console.log("Message Edited", message); - }, - onInteractiveMessageReceived: (message: CometChat.InteractiveMessage) => { - console.log("interactive Message received", message); - }, - onInteractionGoalCompleted: (receipt: CometChat.InteractionReceipt) => { - console.log("Message interaction goal completed", message); - }, - onTransientMessageReceived: (message: CometChat.TransientMessage) => { - console.log("Transient Message received", message); - }, - onMessageReactionAdded: (reaction: CometChat.ReactionEvent) => { - console.log("Message Reaction added", reaction); - }, - onMessageReactionRemoved: (reaction: CometChat.ReactionEvent) => { - console.log("Message Reaction removed", reaction); - }, - }) -); -``` - - - - - -where `UNIQUE_LISTENER_ID` is the unique identifier for the listener. Please make sure that no two listeners are added with the same listener id as this could lead to unexpected behavior resulting in loss of events. - -Once the `MessageListener` is not in use, you need to remove the listener using the `removeMessageListener()` method which takes the id of the listener to be removed as the parameter. - - - -```javascript -CometChat.removeMessageListener(UNIQUE_LISTENER_ID); -``` - - - - -```typescript -let listenerID: string = "UNIQUE_LISTENER_ID"; -CometChat.removeMessageListener(listenerID); -``` - - - - - -## Call Listener - -The `CallListener` class provides you with live events related to calls. Below are the callback methods provided by the `CallListener` class. - -| Method | Information | -| ------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **onIncomingCallReceived(call: CometChat.Call)** | This event is triggered when the logged-in user receives an incoming call. The details of the call can be obtained from the Call object received as the method parameter. | -| **onOutgoingCallAccepted(call: CometChat.Call)** | This event is triggered when the call initiated by the logged-in user is accepted by the recipient. The details of the call can be obtained from the Call object received as the method parameter. | -| **onOutgoingCallRejected(call: CometChat.Call)** | This event is triggered when the call initiated by the logged-in user is rejected by the recipient. The details of the call can be obtained from the Call object received as the method parameter | -| **onIncomingCallCancelled(call: CometChat.Call)** | This event is triggered when an incoming call is canceled by the initiator of the call. The details of the call can be obtained from the Call object received as the method parameter | - -To add the `CallListener`, you need to use the `addCallListener()` method provided by the `CometChat` class. - - - -```javascript -CometChat.addCallListener( - "UNIQUE_LISTENER_ID", - new CometChat.CallListener({ - onIncomingCallReceived(call) { - console.log("Incoming call:", call); - }, - onOutgoingCallAccepted(call) { - console.log("Outgoing call accepted:", call); - }, - onOutgoingCallRejected(call) { - console.log("Outgoing call rejected:", call); - }, - onIncomingCallCancelled(call) { - console.log("Incoming call canceled:", call); - }, - }) -); -``` - - - - -```typescript -CometChat.addCallListener( - "UNIQUE_LISTENER_ID", - new CometChat.CallListener({ - onIncomingCallReceived: (call: CometChat.Call) => { - console.log("Incoming call:", call); - }, - onOutgoingCallAccepted: (call: CometChat.Call) => { - console.log("Outgoing call accepted:", call); - }, - onOutgoingCallRejected: (call: CometChat.Call) => { - console.log("Outgoing call rejected:", call); - }, - onIncomingCallCancelled: (call: CometChat.Call) => { - console.log("Incoming call canceled:", call); - }, - }) -); -``` - - - - - -where `UNIQUE_LISTENER_ID` is the unique identifier for the listener. Please make sure that no two listeners are added with the same listener id as this could lead to unexpected behavior resulting in loss of events. - -Once the `CallListener` is not in use, you need to remove the listener using the `removeCallListener()` method which takes the id of the listener to be removed as the parameter. - - - -```javascript -CometChat.removeCallListener(UNIQUE_LISTENER_ID); -``` - - - - -```typescript -let listenerID: string = "UNIQUE_LISTENER_ID"; -CometChat.removeCallListener(listenerID); -``` - - - - diff --git a/sdk/ionic-legacy/receive-messages.mdx b/sdk/ionic-legacy/receive-messages.mdx deleted file mode 100644 index 2e655e99c..000000000 --- a/sdk/ionic-legacy/receive-messages.mdx +++ /dev/null @@ -1,960 +0,0 @@ ---- -title: "Receive A Message" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/receive-message) which provides full compatibility with Ionic applications. - - -Receiving messages with CometChat has two parts: - -1. Adding a listener to receive [real-time messages](/sdk/ionic-legacy/receive-messages#real-time-messages) when your app is running. -2. Calling a method to retrieve [missed messages](/sdk/ionic-legacy/receive-messages#missed-messages) when your app was not running. - -## Real-Time Messages - -*In other words, as a recipient, how do I receive messages when my app is running?* - -To receive real-time incoming messages, you need to register the `MessageListener` wherever you wish to receive the incoming messages. You can use the `addMessageListener()` method to do so. - - - -```javascript -let listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener( - listenerID, - new CometChat.MessageListener({ - onTextMessageReceived: (textMessage) => { - console.log("Text message received successfully", textMessage); - }, - onMediaMessageReceived: (mediaMessage) => { - console.log("Media message received successfully", mediaMessage); - }, - onCustomMessageReceived: (customMessage) => { - console.log("Custom message received successfully", customMessage); - }, - }) -); -``` - - - - -```typescript -let listenerID: string = "UNIQUE_LISTENER_ID"; - -CometChat.addMessageListener( - listenerID, - new CometChat.MessageListener({ - onTextMessageReceived: (textMessage: CometChat.TextMessage) => { - console.log("Text message received successfully", textMessage); - }, - onMediaMessageReceived: (mediaMessage: CometChat.MediaMessage) => { - console.log("Media message received successfully", mediaMessage); - }, - onCustomMessageReceived: (customMessage: CometChat.CustomMessage) => { - console.log("Custom message received successfully", customMessage); - }, - }) -); -``` - - - - - -| Parameter | Description | -| -------------- | --------------------------------------------- | -| **listenerId** | An ID that uniquely identifies that listener. | - -We recommend you remove the listener once you don't want to receive a message for particular listener. - - - -```javascript -let listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.removeMessageListener(listenerID); -``` - - - - -```typescript -let listenerID: string = "UNIQUE_LISTENER_ID"; - -CometChat.removeMessageListener(listenerID); -``` - - - - - - - -As a sender, you will not receive your own message in a real-time message event. However, if a user is logged-in using multiple devices, they will receive an event for their own message in other devices. - - - -## Missed Messages - -*In other words, as a recipient, how do I receive messages that I missed when my app was not running?* - -For most use cases, you will need to add functionality to load missed messages. If you're building an on-demand or live streaming app, you may choose to skip this and fetch message history instead. - -Using the same `MessagesRequest` class and the filters provided by the `MessagesRequestBuilder` class, you can fetch the message that we sent to the logged-in user but were not delivered to him as he was offline. For this, you will require the ID of the last message received. You can either maintain it at your end or use the `getLastDeliveredMessageId()` method provided by the CometChat class. This ID needs to be passed to the `setMessageId()` method of the builder class. - -Now using the `fetchNext()` method, you can fetch all the messages that were sent to the user when he/she was offline. - -Calling the `fetchNext()` method on the same object repeatedly allows you to fetch all the offline messages for the logged in user. - -### Fetch Missed Messages of a particular one-on-one conversation - - - -```javascript -let UID = "UID"; -let limit = 30; -let latestId = await CometChat.getLastDeliveredMessageId(); - -var messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setMessageId(latestId) - .setLimit(limit) - .build(); - -messagesRequest.fetchNext().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - latestId: number = await CometChat.getLastDeliveredMessageId(), - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setMessageId(latestId) - .setLimit(limit) - .build(); - -messagesRequest.fetchNext().then( - (messages: CometChat.BaseMessage[]) => { - console.log("Message list fetched:", messages); - }, - (error: CometChat.CometChatException) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -### Fetch Missed Messages of a particular group conversation - - - -```javascript -let GUID = "GUID"; -var limit = 30; -let latestId = await CometChat.getLastDeliveredMessageId(); - -var messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setMessageId(latestId) - .setLimit(limit) - .build(); - -messagesRequest.fetchNext().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```typescript -let GUID: string = "GUID", - limit: number = 30, - latestId: number = await CometChat.getLastDeliveredMessageId(), - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setMessageId(latestId) - .setLimit(limit) - .build(); - -messagesRequest.fetchNext().then( - (messages: CometChat.BaseMessage[]) => { - console.log("Message list fetched:", messages); - }, - (error: CometChat.CometChatException) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -## Unread Messages - -*In other words, as a logged-in user, how do I fetch the messages I've not read?* - -Using the `MessagesRequest` class described above, you can fetch the unread messages for the logged in user. In order to achieve this, you need to set the `unread` variable in the builder to `true` using the `setUnread()` method so that only the unread messages are fetched. - -### Fetch Unread Messages of a particular one-on-one conversation - - - -```javascript -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setUnread(true) - .setLimit(limit) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setUnread(true) - .setLimit(limit) - .build(); - -messagesRequest.fetchPrevious().then( - (messages: CometChat.BaseMessage[]) => { - console.log("Message list fetched:", messages); - }, - (error: CometChat.CometChatException) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -### Fetch Unread Messages of a particular group conversation - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setUnread(true) - .setLimit(limit) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```typescript -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setUnread(true) - .setLimit(limit) - .build(); - -messagesRequest.fetchPrevious().then( - (messages: CometChat.BaseMessage[]) => { - console.log("Message list fetched:", messages); - }, - (error: CometChat.CometChatException) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - - -Base Message - -The list of messages received is in the form of objects of `BaseMessage` class. A BaseMessage can either be an object of the `TextMessage`, `MediaMessage`, `CustomMessage`, `Action` or `Call` class. You can use the `instanceOf` operator to check the type of object. - - - -## Message History - -*In other words, as a logged-in user, how do I fetch the complete message history?* - -### Fetch Message History of a particular one-on-one conversation - -Using the `MessagesRequest` class and the filters for the `MessagesRequestBuilder` class as shown in the below code snippet, you can fetch the entire conversation between the logged in user and any particular user. For this use case, it is mandatory to set the UID parameter using the `setUID()` method of the builder. This UID is the unique id of the user for which the conversation needs to be fetched. - - - -```javascript -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder().setUID(UID).setLimit(limit).build(); - -messagesRequest.fetchPrevious().then( - (messages: CometChat.BaseMessage[]) => { - console.log("Message list fetched:", messages); - }, - (error: CometChat.CometChatException) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -Calling the `fetchPrevious()` method on the same object repeatedly allows you to fetch the entire conversation between the logged in user and the specified user. This can be implemented with upward scrolling to display the entire conversation. - -### Fetch Message History of a particular group conversation - -Using the `MessagesRequest` class and the filters for the `MessagesRequestBuilder` class as shown in the below code snippet, you can fetch the entire conversation for any group provided you have joined the group. For this use case, it is mandatory to set the GUID parameter using the `setGUID()` method of the builder. This GUID is the unique identifier of the Group for which the messages are to be fetched. - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```typescript -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .build(); - -messagesRequest.fetchPrevious().then( - (messages: CometChat.BaseMessage[]) => { - console.log("Message list fetched:", messages); - }, - (error: CometChat.CometChatException) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -Calling the `fetchPrevious()` method on the same object repeatedly allows you to fetch the entire conversation for the group. This can be implemented with upward scrolling to display the entire conversation. - -## Search Messages - -In other words, as a logged-in user, how do I search a message? - -In order to do this, you can use the `setSearchKeyword()` method. This method accepts string as input. When set, the SDK will fetch messages which match the `searchKeyword`. - - - -By default, the searchKey is searched only in message text. However, if you enable `Conversation & Advanced Search`, the searchKey will be searched in message text, file name, mentions & mime type of the file. - -The `Conversation & Advanced Search` is only available in `Advanced` & `Custom` [plans](https://www.cometchat.com/pricing). If you're already on one of these plans, please enable the `Conversation & Advanced Search` from [CometChat Dashboard](https://app.cometchat.com) (Open your app, navigate to Chats -> Settings -> General Configuration) - - - -| Feature | Basic Search | Advance Search | -| ---------------- | ------------ | -------------- | -| Text search | ✅ | ✅ | -| File name search | ❌ | ✅ | -| Mentions search | ❌ | ✅ | -| Mime type search | ❌ | ✅ | - -### Search Messages in a particular one-on-one conversation - - - -```javascript -let UID = "UID"; -let limit = 30; -let searchKeyword = "Hello"; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - searchKeyword: string = "Hello", - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); - -messagesRequest.fetchPrevious().then( - (messages: CometChat.BaseMessage[]) => { - console.log("Message list fetched:", messages); - }, - (error: CometChat.CometChatException) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -### Search Messages in a particular group conversation - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let searchKeyword = "Hello"; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); - -messagesRequest.fetchPrevious().then( - (messages) => { - console.log("Message list fetched:", messages); - }, - (error) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```typescript -let GUID: string = "GUID", - limit: number = 30, - searchKeyword: string = "Hello", - messagesRequest: CometChat.MessagesRequest = - new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); - -messagesRequest.fetchPrevious().then( - (messages: CometChat.BaseMessage[]) => { - console.log("Message list fetched:", messages); - }, - (error: CometChat.CometChatException) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -## Unread Message Count - -*In other words, as a logged-in user, how do I find out the number of unread messages that I have?* - -### Fetch Unread Message Count of a particular one-on-one conversation - -*In other words, how do I find out the number of unread messages I have from a particular user?* - -In order to get the unread message count for a particular user, you can use the `getUnreadMessageCountForUser()`. - -This method has the below two variants: - - - -```javascript -CometChat.getUnreadMessageCountForUser(UID); -``` - - - - -```typescript -let UID: string = "UID"; -CometChat.getUnreadMessageCountForUser(UID); -``` - - - - - -If you wish to ignore the messages from blocked users you can use the below syntax setting the boolean parameter to true: - - - -```javascript -CometChat.getUnreadMessageCountForUser(UID, hideMessagesFromBlockedUsers); -``` - - - - -```typescript -let UID: string = "UID", - hideMessagesFromBlockedUsers: boolean = true; -CometChat.getUnreadMessageCountForUser(UID, hideMessagesFromBlockedUsers); -``` - - - - - - - -```javascript -let UID = "UID"; - -CometChat.getUnreadMessageCountForUser(UID).then( - (unreadMessageCountObject) => { - console.log("Unread message count fetched", unreadMessageCountObject); - }, - (error) => { - console.log("Error in getting unread message count", error); - } -); -``` - - - - -```typescript -let UID: string = "UID"; - -CometChat.getUnreadMessageCountForUser(UID).then( - (unreadMessageCount: Object) => { - console.log("Unread message count fetched", unreadMessageCount); - }, - (error: CometChat.CometChatException) => { - console.log("Error in getting unread message count", error); - } -); -``` - - - - - -It will return an object which will contain the UID as the key and the unread message count as the value. - -### Fetch Unread Message Count of a particular group conversation - -*In other words, how do I find out the number of unread messages I have in a single group?* - -In order to get the unread message count for a particular group, you can use the `getUnreadMessageCountForGroup()`. - -This method has the below two variants: - - - -```javascript -CometChat.getUnreadMessageCountForGroup(GUID); -``` - - - - -```typescript -let GUID: string = "GUID"; -CometChat.getUnreadMessageCountForGroup(GUID); -``` - - - - - -If you wish to ignore the messages from blocked users you can use the below syntax setting the boolean parameter to true: - - - -```javascript -CometChat.getUnreadMessageCountForGroup(GUID, hideMessagesFromBlockedUsers); -``` - - - - -```typescript -let GUID: string = "GUID", - hideMessagesFromBlockedUsers: boolean = true; -CometChat.getUnreadMessageCountForGroup(GUID, hideMessagesFromBlockedUsers); -``` - - - - - - - -```javascript -let GUID = "GUID"; - -CometChat.getUnreadMessageCountForGroup(GUID).then( - (unreadMessageCountObject) => { - console.log("Unread message count fetched", unreadMessageCountObject); - }, - (error) => { - console.log("Error in getting unread message count", error); - } -); -``` - - - - -```typescript -let GUID: string = "GUID"; - -CometChat.getUnreadMessageCountForGroup(GUID).then( - (unreadMessageCount: Object) => { - console.log("Unread message count fetched", unreadMessageCount); - }, - (error: CometChat.CometChatException) => { - console.log("Error in getting unread message count", error); - } -); -``` - - - - - -It will return an object which will contain the GUID as the key and the unread message count as the value. - -### Fetch Unread Message Count of all one-on-one & group conversations - -*In other words, how do I find out the number of unread messages for every one-on-one and group conversation?* - -In order to get all the unread message count combined i.e unread message counts for all the users and groups, you can use the `getUnreadMessageCount()` method. - -This method has two variants: - - - -```javascript -CometChat.getUnreadMessageCount(); -``` - - - - -```typescript -CometChat.getUnreadMessageCount(); -``` - - - - - -If you wish to ignore the messages from blocked users you can use the below syntax setting the boolean parameter to true: - - - -```javascript -CometChat.getUnreadMessageCount(hideMessagesFromBlockedUsers); -``` - - - - -```typescript -let hideMessagesFromBlockedUsers: boolean = true; -CometChat.getUnreadMessageCount(hideMessagesFromBlockedUsers); -``` - - - - - - - -```javascript -CometChat.getUnreadMessageCount().then( - (unreadMessageCountObject) => { - console.log("Unread message count fetched", unreadMessageCountObject); - }, - (error) => { - console.log("Error in getting unread message count", error); - } -); -``` - - - - -```typescript -CometChat.getUnreadMessageCount().then( - (unreadMessageCount: Object) => { - console.log("Unread message count fetched", unreadMessageCount); - }, - (error: CometChat.CometChatException) => { - console.log("Error in getting unread message count", error); - } -); -``` - - - - - -It returns an object having two keys: - -1. users - The value for this key holds another object that holds the UID as key and their corresponding unread message count as value. -2. groups - The value for this key holds another object that holds the GUID as key and their corresponding unread message count as value. - -### Fetch Unread Message Count of all one-on-one conversations - -In order to fetch the unread message counts for just the users, you can use the `getUnreadMessageCountForAllUsers()` method. This method just like others has two variants: - - - -```javascript -CometChat.getUnreadMessageCountForAllUsers(); -``` - - - - -```typescript -CometChat.getUnreadMessageCountForAllUsers(); -``` - - - - - -If you wish to ignore the messages from blocked users you can use the below syntax setting the boolean parameter to true: - - - -```javascript -CometChat.getUnreadMessageCountForAllUsers(hideMessagesFromBlockedUsers); -``` - - - - -```typescript -let hideMessagesFromBlockedUsers: boolean = true; -CometChat.getUnreadMessageCountForAllUsers(hideMessagesFromBlockedUsers); -``` - - - - - - - -```javascript -CometChat.getUnreadMessageCountForAllUsers().then( - (unreadMessageCountObject) => { - console.log("Unread message count fetched", unreadMessageCountObject); - }, - (error) => { - console.log("Error in getting unread message count", error); - } -); -``` - - - - -```typescript -CometChat.getUnreadMessageCountForAllUsers().then( - (unreadMessageCount: Object) => { - console.log("Unread message count fetched", unreadMessageCount); - }, - (error: CometChat.CometChatException) => { - console.log("Error in getting unread message count", error); - } -); -``` - - - - - -It returns an object which will contain the UID as the key and the unread message count as the value. - -### Fetch Unread Message Count of all group conversations - -In order to fetch the unread message counts for just the groups, you can use the `getUnreadMessageCountForAllGroups()` method. This method just like others has two variants: - - - -```javascript -CometChat.getUnreadMessageCountForAllGroups(); -``` - - - - -```typescript -CometChat.getUnreadMessageCountForAllGroups(); -``` - - - - - -If you wish to ignore the messages from blocked users you can use the below syntax setting the boolean parameter to true: - - - -```javascript -CometChat.getUnreadMessageCountForAllGroups(hideMessagesFromBlockedUsers); -``` - - - - -```typescript -let hideMessagesFromBlockedUsers: boolean = true; -CometChat.getUnreadMessageCountForAllGroups(hideMessagesFromBlockedUsers); -``` - - - - - - - -```javascript -CometChat.getUnreadMessageCountForAllGroups().then( - (unreadMessageCountObject) => { - console.log("Unread message count fetched", unreadMessageCountObject); - }, - (error) => { - console.log("Error in getting unread message count", error); - } -); -``` - - - - -```typescript -CometChat.getUnreadMessageCountForAllGroups().then( - (unreadMessageCount: Object) => { - console.log("Unread message count fetched", unreadMessageCount); - }, - (error: CometChat.CometChatException) => { - console.log("Error in getting unread message count", error); - } -); -``` - - - - - -It returns an object which will contain the GUID as the key and the unread message count as the value. diff --git a/sdk/ionic-legacy/recording.mdx b/sdk/ionic-legacy/recording.mdx deleted file mode 100644 index 6d40e9a9a..000000000 --- a/sdk/ionic-legacy/recording.mdx +++ /dev/null @@ -1,107 +0,0 @@ ---- -title: "Recording(Beta)" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/recording) which provides full compatibility with Ionic applications. - - -This section will guide you to implement call recording feature for the voice and video calls. - -## Implementation - -Once you have decided to implement [Direct Calling](/sdk/ionic-legacy/direct-call) followed the steps to implement them. Just few additional listeners and methods will help you quickly implement call recording in your app. - -You need to make changes in the `CometChatCalls.startSession()` method and add the required listeners for recording. Please make sure your callSettings is configured accordingly for [Direct Calling](/sdk/ionic-legacy/direct-call). - -A basic example of how to make changes to implement recording for a direct call/ a default call: - - - -```javascript -import { CometChatCalls } from '@cometchat/calls-sdk-ionic'; - -const audioOnly = false; -const defaultLayout = true; -const showRecordingButton = true; - -const callListener = new CometChatCalls.OngoingCallListener({ - onRecordingStarted: (event) => { - console.log("Call recording started:", event); - }, - onRecordingStopped: (event) => { - console.log("Call recording stopped:", event); - } -}); - -const callSettings = new CometChatCalls.CallSettingsBuilder() - .enableDefaultLayout(defaultLayout) - .setIsAudioOnlyCall(audioOnly) - .showRecordingButton(showRecordingButton) - .setCallEventListener(callListener) - .build(); - -// Start the call using `startSession` method of `CometChatCalls` -``` - - - - -```typescript -import { CometChatCalls } from '@cometchat/calls-sdk-ionic'; -import { CallSettings } from '@cometchat/calls-sdk-ionic/dist/models/CallSettings'; -import { OngoingCallListener } from '@cometchat/calls-sdk-ionic/dist/models/Listner'; - -const audioOnly = false; -const defaultLayout = true; -const showRecordingButton = true; - -const callListener: OngoingCallListener = new CometChatCalls.OngoingCallListener({ - onRecordingStarted: (event) => { - console.log("Call recording started:", event); - }, - onRecordingStopped: (event) => { - console.log("Call recording stopped:", event); - } -}); - -const callSettings: CallSettings = new CometChatCalls.CallSettingsBuilder() - .enableDefaultLayout(defaultLayout) - .setIsAudioOnlyCall(audioOnly) - .showRecordingButton(showRecordingButton) - .setCallEventListener(callListener) - .build(); - -// Start the call using `startSession` method of `CometChatCalls` -``` - - - - - -## Settings for call recording - -The `CallSettings` class allows you to customise the overall calling experience. The properties for the call/conference can be set using the `CallSettingsBuilder` class. This will eventually give you an object of the `CallSettings` class which you can pass to the `startSession()` method to start the call. - -The options available for recording of calls are: - -| Setting | Description | -| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `showRecordingButton(showRecordingButton: boolean)` | If set to `true` it displays the Recording button in the button Layout. If set to `false` it hides the Recording button in the button Layout. **Default value = false** | -| `startRecordingOnCallStart(startRecordingOnCallStart: boolean)` | If set to `true` call recording will start as soon as the call is started. If set to `false` call recording will not start as soon as the call is started. **Default value = false** | - -## Downloading Recording - -Currently, the call recordings are available on the [CometChat Dashboard](https://app.cometchat.com) under the Calls Section. You can refer to the below screenshot. - - - - - - - - - - - - diff --git a/sdk/ionic-legacy/resources-overview.mdx b/sdk/ionic-legacy/resources-overview.mdx deleted file mode 100644 index fd54f25b9..000000000 --- a/sdk/ionic-legacy/resources-overview.mdx +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: "Resources" -sidebarTitle: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/resources-overview) which provides full compatibility with Ionic applications. - - -We have a number of resources that will help you while integrating CometChat in your app. - -You can begin with the [all real-time listeners](/sdk/ionic-legacy/real-time-listeners) guide. - -If you're upgrading from v1, we recommend reading our [upgrading from v3](/sdk/ionic-legacy/upgrading-from-v3-guide) guide. diff --git a/sdk/ionic-legacy/retrieve-conversations.mdx b/sdk/ionic-legacy/retrieve-conversations.mdx deleted file mode 100644 index 069cb1063..000000000 --- a/sdk/ionic-legacy/retrieve-conversations.mdx +++ /dev/null @@ -1,555 +0,0 @@ ---- -title: "Retrieve Conversations" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/retrieve-conversations) which provides full compatibility with Ionic applications. - - -Conversations provide the last messages for every one-on-one and group conversation the logged-in user is a part of. This makes it easy for you to build a **Recent Chat** list. - -## Retrieve List of Conversations - -*In other words, as a logged-in user, how do I retrieve the latest conversations that I've been a part of?* - -To fetch the list of conversations, you can use the `ConversationsRequest` class. To use this class i.e. to create an object of the `ConversationsRequest` class, you need to use the `ConversationsRequestBuilder` class. The `ConversationsRequestBuilder` class allows you to set the parameters based on which the conversations are to be fetched. - -The `ConversationsRequestBuilder` class allows you to set the below parameters: - -### Set Limit - -This method sets the limit i.e. the number of conversations that should be fetched in a single iteration. - - - -```javascript -let limit = 30; -let conversationRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .build(); -``` - - - - -```typescript -let limit: number = 30, - conversationRequest: CometChat.ConversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .build(); -``` - - - - - -### Set Conversation Type - -This method can be used to fetch user or group conversations specifically. The `conversationType` variable can hold one of the below two values: - -* user - Only fetches user conversation. -* group - Only fetches group conversations. - -If none is set, the list of conversations will include both user and group conversations. - - - -```javascript -let limit = 30; -let conversationType = "group"; -let conversationRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setConversationType(conversationType) - .build(); -``` - - - - -```typescript -let limit: number = 30, - conversationType: string = "group", - conversationRequest: CometChat.ConversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setConversationType(conversationType) - .build(); -``` - - - - - -### With User and Group Tags - -This method can be used to fetch the user/group tags in the `Conversation` Object. By default the value is false. - - - -```javascript -let limit = 30; -let conversationRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .withUserAndGroupTags(true) - .build(); -``` - - - - -```typescript -let limit: number = 30, - conversationRequest: CometChat.ConversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .withUserAndGroupTags(true) - .build(); -``` - - - - - -### Set User Tags - -This method fetches user conversations that have the specified tags. - - - -```javascript -let limit = 30; -let userTags = ["tag1"]; -let conversationRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setUserTags(userTags) - .build(); -``` - - - - -```typescript -let limit: number = 30, - userTags: Array = ["tag1"], - conversationRequest: CometChat.ConversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setUserTags(userTags) - .build(); -``` - - - - - -### Set Group Tags - -This method fetches group conversations that have the specified tags. - - - -```javascript -let limit = 30; -let groupTags = ["tag1"]; -let conversationRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setGroupTags(groupTags) - .build(); -``` - - - - -```typescript -let limit: number = 30, - groupTags: Array = ["tag1"], - conversationRequest: CometChat.ConversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setGroupTags(groupTags) - .build(); -``` - - - - - -### With Tags - -This method makes sure that the tags associated with the conversations are returned along with the other details of the conversations. The default value for this parameter is `false` - - - -```javascript -let limit = 30; -let conversationRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .withTags(true) - .build(); -``` - - - - -```typescript -let limit: number = 30, - conversationRequest: CometChat.ConversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .withTags(true) - .build(); -``` - - - - - -### Set Tags - -This method helps you fetch the conversations based on the specified tags. - - - -```javascript -let limit = 30; -let tags = ["archivedChat"]; -let conversationRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setTags(tags) - .build(); -``` - - - - -```typescript -let limit: number = 30, - tags: Array = ["archivedChat"], - conversationRequest: CometChat.ConversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setTags(tags) - .build(); -``` - - - - - -### Include Blocked Users - -This method helps you fetch the conversations of users whom the logged-in user has blocked. - - - -```javascript -let limit = 30; -let conversationRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setIncludeBlockedUsers(true) - .build(); -``` - - - - -```typescript -let limit: number = 30, - conversationRequest: CometChat.ConversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setIncludeBlockedUsers(true) - .build(); -``` - - - - - -### With Blocked Info - -This method can be used to fetch the blocked information of the blocked user in the `ConversationWith` object. - - - -```javascript -let limit = 30; -let conversationRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setWithBlockedInfo(true) - .build(); -``` - - - - -```typescript -let limit: number = 30, - conversationRequest: CometChat.ConversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setWithBlockedInfo(true) - .build(); -``` - - - - - -### Search Conversations - -This method helps you search a conversation based on User or Group name. - - - -This feature is only available with `Conversation & Advanced Search`. The `Conversation & Advanced Search` is only available in `Advanced` & `Custom` [plans](https://www.cometchat.com/pricing). If you're already on one of these plans, please enable the `Conversation & Advanced Search` from [CometChat Dashboard](https://app.cometchat.com) (Open your app, navigate to Chats -> Settings -> General Configuration) - - - - - -```javascript -let limit = 30; -let conversationRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setSearchKeyword("Hiking") - .build(); -``` - - - - -```typescript -let limit: number = 30, - conversationRequest: CometChat.ConversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setSearchKeyword("Hiking") - .build(); -``` - - - - - -### Unread Conversations - -This method helps you fetch unread conversations. - - - -This feature is only available with `Conversation & Advanced Search`. The `Conversation & Advanced Search` is only available in `Advanced` & `Custom` [plans](https://www.cometchat.com/pricing). If you're already on one of these plans, please enable the `Conversation & Advanced Search` from [CometChat Dashboard](https://app.cometchat.com) (Open your app, navigate to Chats -> Settings -> General Configuration) - - - - - -```javascript -let limit = 30; -let conversationRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setUnread(true) - .build(); -``` - - - - -```typescript -let limit: number = 30, - conversationRequest: CometChat.ConversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .setUnread(true) - .build(); -``` - - - - - -Finally, once all the parameters are set to the builder class, you need to call the `build()` method to get the object of the `ConversationsRequest` class. - -Once you have the object of the `ConversationsRequest` class, you need to call the `fetchNext()` method. Calling this method will return a list of `Conversation` objects containing X number of users depending on the limit set. - -A Maximum of only 50 Conversations can be fetched at once. - - - -```javascript -let limit = 30; -let conversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .build(); - -conversationsRequest.fetchNext().then( - conversationList => { - console.log("Conversations list received:", conversationList); - }, error => { - console.log("Conversations list fetching failed with error:", error); - } -); -``` - - - - -```typescript -let limit: number = 30, - conversationsRequest: CometChat.ConversationsRequest = new CometChat.ConversationsRequestBuilder() - .setLimit(limit) - .build(); - -conversationsRequest.fetchNext().then( - (conversationList: CometChat.Conversation[]) => { - console.log("Conversations list received:", conversationList); - }, (error: CometChat.CometChatException) => { - console.log("Conversations list fetching failed with error:", error); - } -); -``` - - - - - -The `Conversation` Object consists of the following fields: - -| Field | Information | -| ------------------ | ----------------------------------------------------------------- | -| conversationId | ID of the conversation. | -| conversationType | Type of conversation. (user/group) | -| lastMessage | Last message the conversation. | -| conversationWith | User or Group object containing the details of the user or group. | -| unreadMessageCount | Unread message count for the conversation. | - -## Tag Conversation - -*In other words, as a logged-in user, how do I tag a conversation?* - -To tag a specific conversation, you can use the `tagConversation()` method. The `tagConversation()` method accepts three parameters. - -1. `conversationWith`: UID/GUID of the user/group whose conversation you want to fetch. - -2. `conversationType`: The `conversationType` variable can hold one of the below two values: - - 1. user - Only fetches user conversation. - 2. group - Only fetches group conversations. - -3. `tags`: The `tags` variable will be a list of tags you want to add to a conversation. - - - -```javascript -let tags = ["archivedChat"]; - -CometChat.tagConversation('conversationWith', 'conversationType', tags).then( - conversation => { - console.log('conversation', conversation); - }, error => { - console.log('error while fetching a conversation', error); - } -); -``` - - - - -```typescript -let conversationWith: string = "UID", - tags: Array = ["archivedChat"], - conversationType: string = "user"; - -CometChat.tagConversation(conversationWith, conversationType, tags).then( - (conversation: CometChat.Conversation) => { - console.log('conversation', conversation); - }, (error: CometChat.CometChatException) => { - console.log('error while fetching a conversation', error); - } -); -``` - - - - - - - -The tags for conversations are one-way. This means that if user A tags a conversation with user B, that tag will be applied to that conversation only for user A. - - - -## Retrieve Single Conversation - -*In other words, as a logged-in user, how do I retrieve a specific conversation?* - -To fetch a specific conversation, you can use the `getConversation` method. The `getConversation` method accepts two parameters. - -1. `conversationWith`: UID/GUID of the user/group whose conversation you want to fetch. -2. `conversationType`: The `conversationType` variable can hold one of the below two values: - -* user - Only fetches user conversation. -* group - Only fetches group conversations. - - - -```javascript -CometChat.getConversation('conversationWith', 'conversationType').then( - conversation => { - console.log('conversation', conversation); - }, error => { - console.log('error while fetching a conversation', error); - } -); -``` - - - - -```typescript -let conversationWith: string = "UID", - conversationType: string = "user"; - -CometChat.getConversation(conversationWith, conversationType).then( - (conversation: CometChat.Conversation) => { - console.log('conversation', conversation); - }, (error: CometChat.CometChatException) => { - console.log('error while fetching a conversation', error); - } -); -``` - - - - - -## Convert Messages to Conversations - -As per our [receive messages](/sdk/ionic-legacy/receive-messages) guide, for real-time messages, you will always receive `Message` objects and not `Conversation` objects. Thus, you will need a mechanism to convert the Message object to the `Conversation` object. You can use the `getConversationFromMessage(BaseMessage message)` of the `CometChatHelper` class. - - - -```javascript -CometChat.CometChatHelper.getConversationFromMessage(message).then( - conversation => { - console.log("Conversation Object", conversation); - }, error => { - console.log("Error while converting message object", error); - } -); -``` - - - - -```typescript -let message: CometChat.TextMessage | CometChat.MediaMessage | CometChat.CustomMessage; - -CometChat.CometChatHelper.getConversationFromMessage(message).then( - (conversation: CometChat.Conversation) => { - console.log("Conversation Object", conversation); - }, (error: CometChat.CometChatException) => { - console.log("Error while converting message object", error); - } -); -``` - - - - - - - -While converting the `Message` object to the `Conversation` object, the `unreadMessageCount` & `tags` will not be available in the `Conversation` object. The unread message count needs to be managed in your client-side code. - - diff --git a/sdk/ionic-legacy/retrieve-group-members.mdx b/sdk/ionic-legacy/retrieve-group-members.mdx deleted file mode 100644 index 2124a941f..000000000 --- a/sdk/ionic-legacy/retrieve-group-members.mdx +++ /dev/null @@ -1,155 +0,0 @@ ---- -title: "Retrieve Group Members" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/retrieve-group-members) which provides full compatibility with Ionic applications. - - -## Retrieve the List of Group Members - -In order to fetch the list of groups members for a group, you can use the `GroupMembersRequest` class. To use this class i.e to create an object of the GroupMembersRequest class, you need to use the `GroupMembersRequestBuilder` class. The `GroupMembersRequestBuilder` class allows you to set the parameters based on which the groups are to be fetched. - -The `GroupMembersRequestBuilder` class allows you to set the below parameters: - -The GUID of the group for which the members are to be fetched must be specified in the constructor of the `GroupMembersRequestBuilder` class. - -### Set Limit - -This method sets the limit i.e. the number of members that should be fetched in a single iteration. - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let groupMembersRequest = new CometChat.GroupMembersRequestBuilder(GUID) - .setLimit(limit) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID"; -let limit: number = 30; -let groupMembersRequest: CometChat.GroupMembersRequest = new CometChat.GroupMembersRequestBuilder(GUID) - .setLimit(limit) - .build(); -``` - - - - - -### Set Search Keyword - -This method allows you to set the search string based on which the group members are to be fetched. - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let searchKeyword = "super"; -let groupMembersRequest = new CometChat.GroupMembersRequestBuilder(GUID) - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID"; -let limit: number = 30; -let searchKeyword: string = "super"; -let groupMembersRequest: CometChat.GroupMembersRequest = new CometChat.GroupMembersRequestBuilder(GUID) - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - - -### Set Scopes - -This method allows you to fetch group members based on multiple scopes. - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let scopes = ["admin", "moderator"]; -let groupMembersRequest = new CometChat.GroupMembersRequestBuilder(GUID) - .setLimit(limit) - .setScopes(scopes) - .build(); -``` - - - - -```typescript -let GUID: string = "GUID"; -let limit: number = 30; -let scopes: Array = ["admin", "moderator"]; -let groupMembersRequest: CometChat.GroupMembersRequest = new CometChat.GroupMembersRequestBuilder(GUID) - .setLimit(limit) - .setScopes(scopes) - .build(); -``` - - - - - -Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the `GroupMembersRequest` class. - -Once you have the object of the `GroupMembersRequest` class, you need to call the `fetchNext()` method. Calling this method will return a list of `GroupMember` objects containing n number of members where n is the limit set in the builder class. - - - -```javascript -let GUID = "GUID"; -let limit = 30; -lett groupMemberRequest = new CometChat.GroupMembersRequestBuilder(GUID) - .setLimit(limit) - .build(); - -groupMemberRequest.fetchNext().then( -groupMembers => { - console.log("Group Member list fetched successfully:", groupMembers); -}, error => { - console.log("Group Member list fetching failed with exception:", error); -} -); -``` - - - - -```typescript -let GUID: string = "GUID"; -let limit: number = 30; -let groupMembersRequest: CometChat.GroupMembersRequest = new CometChat.GroupMembersRequestBuilder(GUID) - .setLimit(limit) - .build(); - -groupMembersRequest.fetchNext().then( - (groupMembers: CometChat.GroupMember[]) => { - console.log("Group Member list fetched successfully:", groupMembers); - }, (error: CometChat.CometChatException) => { - console.log("Group Member list fetching failed with exception:", error); - } -); -``` - - - - diff --git a/sdk/ionic-legacy/retrieve-groups.mdx b/sdk/ionic-legacy/retrieve-groups.mdx deleted file mode 100644 index 51e183f5a..000000000 --- a/sdk/ionic-legacy/retrieve-groups.mdx +++ /dev/null @@ -1,287 +0,0 @@ ---- -title: "Retrieve Groups" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/retrieve-groups) which provides full compatibility with Ionic applications. - - -## Retrieve List of Groups - -*In other words, as a logged-in user, how do I retrieve the list of groups I've joined and groups that are available?* - -In order to fetch the list of groups, you can use the `GroupsRequest` class. To use this class i.e to create an object of the `GroupsRequest` class, you need to use the `GroupsRequestBuilder` class. The `GroupsRequestBuilder` class allows you to set the parameters based on which the groups are to be fetched. - -The `GroupsRequestBuilder` class allows you to set the below parameters: - -### Set Limit - -This method sets the limit i.e. the number of groups that should be fetched in a single iteration. - - - -```javascript -let limit = 30; -let groupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .build(); -``` - - - - -```typescript -let limit: number = 30; -let groupsRequest: CometChat.GroupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .build(); -``` - - - - - -### Set Search Keyword - -This method allows you to set the search string based on which the groups are to be fetched. - - - -```javascript -let limit = 30; -let searchKeyword = "group"; -let groupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - -```typescript -let limit: number = 30; -let searchKeyword: string = "group"; -let groupsRequest: CometChat.GroupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - - -### Joined Only - -This method when used, will ask the SDK to only return the groups that the user has joined or is a part of. - - - -```javascript -let limit = 30; -let groupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .joinedOnly(true) - .build(); -``` - - - - -```typescript -let limit: number = 30; -let groupsRequest: CometChat.GroupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .joinedOnly(true) - .build(); -``` - - - - - -### Set Tags - -This method accepts a list of tags based on which the list of groups is to be fetched. The list fetched will only contain the groups that have been tagged with the specified tags. - - - -```javascript -let limit = 30; -let tags = ["tag1", "tag2"]; -let groupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .setTags(tags) - .build(); -``` - - - - -```typescript -let limit: number = 30; -let tags: Array = ["tag1", "tag2"]; -let groupsRequest: CometChat.GroupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .setTags(tags) - .build(); -``` - - - - - -### With Tags - -This property when set to true will fetch tags data along with the list of groups. - - - -```javascript -let limit = 30; -let groupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .withTags(true) - .build(); -``` - - - - -```typescript -let limit: number = 30; -let groupsRequest: CometChat.GroupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .withTags(true) - .build(); -``` - - - - - -Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the `GroupsRequest` class. - -Once you have the object of the `GroupsRequest` class, you need to call the `fetchNext()` method. Calling this method will return a list of `Group` objects containing n number of groups where n is the limit set in the builder class. - -The list of groups fetched will only have the public and password type groups. The private groups will only be available if the user is a member of the group. - - - -```javascript -let limit = 30; -let groupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .build(); - -groupsRequest.fetchNext().then( -groupList => { - console.log("Groups list fetched successfully", groupList); -}, error => { - console.log("Groups list fetching failed with error", error); -} -); -``` - - - - -```typescript -let limit: number = 30; -let groupsRequest: CometChat.GroupsRequest = new CometChat.GroupsRequestBuilder() - .setLimit(limit) - .build(); - -groupsRequest.fetchNext().then( - (groupList: CometChat.Group[]) => { - console.log("Groups list fetched successfully", groupList); - }, (error: CometChat.CometChatException) => { - console.log("Groups list fetching failed with error", error); - } -); -``` - - - - - -## Retrieve Particular Group Details - -*In other words, as a logged-in user, how do I retrieve information for a specific group?* - -To get the information of a group, you can use the `getGroup()` method. - - - -```javascript -var GUID = "GUID"; -CometChat.getGroup(GUID).then( -group => { - console.log("Group details fetched successfully:", group); -}, error => { - console.log("Group details fetching failed with exception:", error); -} -); -``` - - - - -```typescript -var GUID: string = "GUID"; -CometChat.getGroup(GUID).then( - (group: CometChat.Group) => { - console.log("Group details fetched successfully:", group); - }, (error: CometChat.CometChatException) => { - console.log("Group details fetching failed with exception:", error); - } -); -``` - - - - - -| Parameter | Description | -| --------- | ------------------------------------------------------------ | -| `GUID` | The GUID of the group for whom the details are to be fetched | - -It returns `Group` object containing the details of the group. - -## Get online group member count - -To get the total count of online users in particular groups, you can use the `getOnlineGroupMemberCount()` method. - - - -```javascript -let guids = ["cometchat-guid-1"]; -CometChat.getOnlineGroupMemberCount(guids).then( -groupMemberCount => { - console.log("Total online user for specified groups:", groupMemberCount); -}, error => { - console.log("Online group member count fetching failed with error:", error); -} -); -``` - - - - -```typescript -let guids: String[] = ["cometchat-guid-1"]; -CometChat.getOnlineGroupMemberCount(guids).then( - (groupMemberCount: number) => { - console.log("Total online user for specified groups:", groupMemberCount); - }, (error: CometChat.CometChatException) => { - console.log("Online group member count fetching failed with error:", error); - } -); -``` - - - - - -This method returns a JSON Object with the GUID as the key and the online member count for that group as the value. diff --git a/sdk/ionic-legacy/retrieve-users.mdx b/sdk/ionic-legacy/retrieve-users.mdx deleted file mode 100644 index bae70e0ca..000000000 --- a/sdk/ionic-legacy/retrieve-users.mdx +++ /dev/null @@ -1,539 +0,0 @@ ---- -title: "Retrieve Users" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/retrieve-users) which provides full compatibility with Ionic applications. - - -## Retrieve Logged In User Details - -You can get the details of the logged-in user using the `getLoggedInUser()` method. This method can also be used to check if the user is logged in or not. If the method returns `Promise` with reject callback, it indicates that the user is not logged in and you need to log the user into CometChat SDK. - - - -```javascript -var user = CometChat.getLoggedinUser().then( -user => { - console.log("user details:", { user }); -}, error => { - console.log("error getting details:", { error }); -} -); -``` - - - - -```typescript -CometChat.getLoggedinUser().then( - (user: CometChat.User) => { - console.log("user details:", { user }); - }, (error: CometChat.CometChatException) => { - console.log("error getting details:", { error }); - } -); -``` - - - - - -This method will return a `User` object containing all the information related to the logged-in user. - -## Retrieve List of Users - -In order to fetch the list of users, you can use the `UsersRequest` class. To use this class i.e to create an object of the `UsersRequest` class, you need to use the `UsersRequestBuilder` class. The `UsersRequestBuilder` class allows you to set the parameters based on which the users are to be fetched. - -The `UsersRequestBuilder` class allows you to set the below parameters: - -### Set Limit - -This method sets the limit i.e. the number of users that should be fetched in a single iteration. - - - -```javascript -let limit = 30; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .build(); -``` - - - - -```typescript -let limit: number = 30; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .build(); -``` - - - - - -### Set Search Keyword - -This method allows you to set the search string based on which the users are to be fetched. - - - -```javascript -let limit = 30; -let searchKeyword = "super"; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - -```typescript -let limit: number = 30; -let searchKeyword: string = "super"; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .build(); -``` - - - - - -### Search In - -This method allows you to define in which user property should the searchKeyword be searched. This method only works in combination with `setSearchKeyword()`. By default the keyword is searched in both UID & Name. - - - -```javascript -let limit = 30; -let searchKeyword = "super"; -let searchIn = ["uid", "name"]; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .searchIn(searchIn) - .build(); -``` - - - - -```typescript -let limit: number = 30; -let searchKeyword: string = "super"; -let searchIn: Array = ["uid", "name"]; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setSearchKeyword(searchKeyword) - .searchIn(searchIn) - .build(); -``` - - - - - -### Set Status - -The status based on which the users are to be fetched. The status parameter can contain one of the below two values: - -* CometChat.USER\_STATUS.ONLINE - will return the list of only online users. -* CometChat.USER\_STATUS.OFFLINE - will return the list of only offline users. - -If this parameter is not set, will return all the available users. - - - -```javascript -let limit = 30; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setStatus(CometChat.USER_STATUS.ONLINE) - .build() -``` - - - - -```typescript -let limit: number = 30; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setStatus(CometChat.USER_STATUS.ONLINE) - .build(); -``` - - - - - -### Hide Blocked Users - -This method is used to determine if the blocked users should be returned as a part of the user list. If set to true, the user list will not contain the users blocked by the logged in user. - - - -```javascript -let limit = 30; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .hideBlockedUsers(true) - .build(); -``` - - - - -```typescript -let limit: number = 30; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .hideBlockedUsers(true) - .build(); -``` - - - - - -### Set Roles - -This method allows you to fetch the users based on multiple roles. - - - -```javascript -let limit = 30; -let roles = ["default", "dev"]; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setRoles(roles) - .build(); -``` - - - - -```typescript -let limit: number = 30; -let roles: Array = ["default", "dev"]; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setRoles(roles) - .build(); -``` - - - - - -### Friends Only - -This property when set to true will return only the friends of the logged-in user. - - - -```javascript -let limit = 30; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .friendsOnly(true) - .build(); -``` - - - - -```typescript -let limit: number = 30; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .friendsOnly(true) - .build(); -``` - - - - - -### Set Tags - -This method accepts a list of tags based on which the list of users is to be fetched. The list fetched will only contain the users that have been tagged with the specified tags. - - - -```javascript -let limit = 30; -let tags = ["tag1", "tag2"]; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setTags(tags) - .build(); -``` - - - - -```typescript -let limit: number = 30; -let tags: Array = ["tag1", "tag2"]; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setTags(tags) - .build(); -``` - - - - - -### With Tags - -This property when set to true will fetch tags data along with the list of users. - - - -```javascript -let limit = 30; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .withTags(true) - .build(); -``` - - - - -```typescript -let limit: number = 30; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .withTags(true) - .build(); -``` - - - - - -### Set UIDs - -This method accepts a list of UIDs based on which the list of users is fetched. A maximum of `25` users can be fetched. - - - -```javascript -let limit = 30; -let UIDs = ["cometchat-uid-1", "cometchat-uid-2"]; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setUIDs(UIDs) - .build(); -``` - - - - -```typescript -let limit: number = 30; -let UIDs: Array = ["cometchat-uid-1", "cometchat-uid-2"]; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .setUIDs(UIDs) - .build(); -``` - - - - - -### Sort By - -This method allows you to sort the User List by a specific property of User. By default the User List is sorted by `status => name => UID` . If `name` is pass to the `sortBy()` method the user list will be sorted by `name => UID`. - - - -```javascript -let limit = 30; -let UIDs = ["cometchat-uid-1", "cometchat-uid-2"]; -let sortBy = "name"; -let usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .sortBy(sortBy) - .build(); -``` - - - - -```typescript -let limit: number = 30; -let sortBy: string = "name"; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .sortBy(sortBy) - .build(); -``` - - - - - -### Sort By Order - -This method allows you to sort the User List in a specific order. By default the user list is sorted in ascending order. - - - -```javascript -let limit = 30; -let sortByOrder = "desc"; -let usersReques = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .sortByOrder(sortOrder) - .build(); -``` - - - - -```typescript -let limit: number = 30; -let sortOrder: string = "desc"; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .sortOrder(sortOrder) - .build(); -``` - - - - - -Finally, once all the parameters are set to the builder class, you need to call the build() method to get the object of the UsersRequest class. - -Once you have the object of the UsersRequest class, you need to call the fetchNext() method. Calling this method will return a list of User objects containing n number of users where n is the limit set in the builder class. - - - -```javascript -var limit = 30; -var usersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .build(); - -usersRequest.fetchNext().then( -userList => { - console.log("User list received:", userList); -}, error => { - console.log("User list fetching failed with error:", error); -} -); -``` - - - - -```typescript -let limit: number = 30; -let usersRequest: CometChat.UsersRequest = new CometChat.UsersRequestBuilder() - .setLimit(limit) - .build(); - -usersRequest.fetchNext().then( - (userList: CometChat.User[]) => { - console.log("User list received:", userList); - }, (error: CometChat.CometChatException) => { - console.log("User list fetching failed with error:", error); - } -); -``` - - - - - -## Retrieve Particular User Details - -To get the information of a user, you can use the `getUser()` method. - - - -```javascript -let UID = "UID"; -CometChat.getUser(UID).then( -user => { - console.log("User details fetched for user:", user); -}, error => { - console.log("User details fetching failed with error:", error); -} -); -``` - - - - -```typescript -let UID: string = "UID"; -CometChat.getUser(UID).then( - (user: CometChat.User) => { - console.log("User details fetched for user:", user); - }, (error: CometChat.CometChatException) => { - console.log("User details fetching failed with error:", error); - } -); -``` - - - - - -The `getUser()` method takes the following parameters: - -| Parameter | Description | -| --------- | ---------------------------------------------------------- | -| UID | The UID of the user for whom the details are to be fetched | - -It returns the `User` object containing the details of the user. - -## Get online user count - -To get the total count of online users for your app, you can use the `getOnlineUserCount()` method. - - - -```javascript -CometChat.getOnlineUserCount().then( -userCount => { - console.log("Total online user count:", userCount); -}, error => { - console.log("Online user count fetching failed with error:", error); -} -); -``` - - - - -```typescript -CometChat.getOnlineUserCount().then( - (userCount: number) => { - console.log("Total online user count:", userCount); - }, (error: CometChat.CometChatException) => { - console.log("Online user count fetching failed with error:", error); - } -); -``` - - - - - -This method returns the total online user count for your app. diff --git a/sdk/ionic-legacy/send-message.mdx b/sdk/ionic-legacy/send-message.mdx deleted file mode 100644 index b11cd0582..000000000 --- a/sdk/ionic-legacy/send-message.mdx +++ /dev/null @@ -1,1373 +0,0 @@ ---- -title: "Send A Message" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/send-message) which provides full compatibility with Ionic applications. - - -Using CometChat, you can send three types of messages: - -1. [Text Message](/sdk/ionic-legacy/send-message#text-message) is the most common and standard message type. -2. [Media Message](/sdk/ionic-legacy/send-message#media-message), for sending photos, videos and files. -3. [Custom Message](/sdk/ionic-legacy/send-message#custom-message), for sending completely custom data using JSON structures. -4. [Interactive Messages](/sdk/ionic-legacy/interactive-messages), for sending end-user interactive messages of type form, card and custom Interactive - -You can also send metadata along with a text, media or custom message. Think, for example, if you'd want to share the user's location with every message, you can use the metadata field - -## Text Message - -*In other words, as a sender, how do I send a text message?* - -To send a text message to a single user or group, you need to use the `sendMessage()` method and pass a `TextMessage` object to it. - -### Add Metadata - -To send custom data along with a text message, you can use the `setMetadata` method and pass a `JSON Object` to it. - - - -```javascript -let metadata = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002", -}; - -textMessage.setMetadata(metadata); -``` - - - - -```typescript -let metadata: Object = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002", -}; - -textMessage.setMetadata(metadata); -``` - - - - - -### Add Tags - -To add a tag to a message you can use the `setTags()` method of the TextMessage Class. The `setTags()` method accepts a list of tags. - - - -```javascript -let tags = ["starredMessage"]; - -textMessage.setTags(tags); -``` - - - - -```typescript -let tags: Array = ["starredMessage"]; - -textMessage.setTags(tags); -``` - - - - - -Once the text message object is ready, you need to use the `sendMessage()` method to send the text message to the recipient. - - - -```javascript -let receiverID = "UID"; -let messageText = "Hello world!"; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let textMessage = new CometChat.TextMessage( - receiverID, - messageText, - receiverType -); - -CometChat.sendMessage(textMessage).then( - (message) => { - console.log("Message sent successfully:", message); - }, - (error) => { - console.log("Message sending failed with error:", error); - } -); -``` - - - - -```javascript -let receiverID = "GUID"; -let messageText = "Hello world!"; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; -let textMessage = new CometChat.TextMessage( - receiverID, - messageText, - receiverType -); - -CometChat.sendMessage(textMessage).then( - (message) => { - console.log("Message sent successfully:", message); - }, - (error) => { - console.log("Message sending failed with error:", error); - } -); -``` - - - - -```typescript -let receiverID: string = "UID", - messageText: string = "Hello world!", - receiverType: string = CometChat.RECEIVER_TYPE.USER, - textMessage: CometChat.TextMessage = new CometChat.TextMessage( - receiverID, - messageText, - receiverType - ); - -CometChat.sendMessage(textMessage).then( - (message: CometChat.TextMessage) => { - console.log("Message sent successfully:", message); - }, - (error: CometChat.CometChatException) => { - console.log("Message sending failed with error:", error); - } -); -``` - - - - -```typescript -let receiverID: string = "GUID", - messageText: string = "Hello world!", - receiverType: string = CometChat.RECEIVER_TYPE.GROUP, - textMessage: CometChat.TextMessage = new CometChat.TextMessage( - receiverID, - messageText, - receiverType - ); - -CometChat.sendMessage(textMessage).then( - (message: CometChat.TextMessage) => { - console.log("Message sent successfully:", message); - }, - (error: CometChat.CometChatException) => { - console.log("Message sending failed with error:", error); - } -); -``` - - - - - -The `TextMessage` class constructor takes the following parameters: - -| Parameter | Description | | -| ---------------- | ------------------------------------------------------------------------------------------------------------- | -------- | -| **receiverID** | `UID` of the user or `GUID` of the group receiving the message | Required | -| **messageText** | The text message | Required | -| **receiverType** | The type of the receiver- `CometChatConstants.RECEIVER_TYPE_USER` or `CometChatConstants.RECEIVER_TYPE_GROUP` | Required | - -When a text message is sent successfully, the response will include a `TextMessage` object which includes all information related to the sent message. - -## Media Message - -*In other words, as a sender, how do I send a media message like photos, videos & files?* - -To send a media message to any user or group, you need to use the `sendMediaMessage()` method and pass a `MediaMessage` object to it. - -### Add Metadata - -To send custom data along with a media message, you can use the `setMetadata` method and pass a `JSON Object` to it. - - - -```javascript -let metadata = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002", -}; - -mediaMessage.setMetadata(metadata); -``` - - - - -```typescript -let metadata = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002", -}; - -mediaMessage.setMetadata(metadata); -``` - - - - - -### Add Caption(Text along with Media Message) - -To send a caption with a media message, you can use the `setCaption` method and pass text to it. - - - -```javascript -let tags = ["starredMessage"]; - -mediaMessage.setTags(tags); -``` - - - - -```typescript -let caption: string = "Random Caption"; - -mediaMessage.setCaption(caption); -``` - - - - - -### Add Tags - -To add a tag to a message you can use the `setTags()` method of the MediaMessage Class. The `setTags()` method accepts a list of tags. - - - -```javascript -let tags = ["starredMessage"]; - -mediaMessage.setTags(tags); -``` - - - - -```typescript -let tags: Array = ["starredMessage"]; - -mediaMessage.setTags(tags); -``` - - - - - -There are 2 ways you can send Media Messages using the CometChat SDK: - -1. **By providing the File:** You can directly share the file object while creating an object of the MediaMessage class. When the media message is sent using the `sendMediaMessage()` method, this file is then uploaded to CometChat servers and the URL of the file is sent in the success response of the `sendMediaMessage()` function. - -Getting file Object: You can use different ionic packages for sending media messages. We demonstrate how to send images using CometChat. - - - -```javascript -const options = { -outputType: 1 -}; -this.imagePicker.getPictures(options) -.then((results) => { - results[0] = 'data:image/jpeg;base64,' + results[0]; - const blob_nw = this.dataURItoBlob(results[0]); - const date = new Date(); - const file = { - file: blob_nw, - type: 'image/jpeg', - name: 'temp_img' + date.getTime() - }; - - this.sendMediaMessage(file); -}, (err) => { - console.log(err); -}); - -dataURItoBlob(dataURI) { - const byteString = atob(dataURI.split(',')[1]); - const mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; - const ab = new ArrayBuffer(byteString.length); - const ia = new Uint8Array(ab); - for (let i = 0; i < byteString.length; i++) { - ia[i] = byteString.charCodeAt(i); - } - const bb = new Blob([ab], {type: mimeString}); - return bb; -} -``` - - - - - - - -```javascript -let receiverID = "UID"; -let file = "FILE_OBJECT"; -let messageType = CometChat.MESSAGE_TYPE.FILE; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let mediaMessage = new CometChat.MediaMessage( - receiverID, - file, - messageType, - receiverType -); - -CometChat.sendMediaMessage(mediaMessage).then( - (message) => { - console.log("Media message sent successfully", message); - }, - (error) => { - console.log("Media message sending failed with error", error); - } -); -``` - - - - -```javascript -let receiverID = "GUID"; -let file = "FILE_OBJECT"; -let messageType = CometChat.MESSAGE_TYPE.FILE; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; -let mediaMessage = new CometChat.MediaMessage( - receiverID, - file, - messageType, - receiverType -); - -CometChat.sendMediaMessage(mediaMessage).then( - (message) => { - console.log("Media message sent successfully", message); - }, - (error) => { - console.log("Media message sending failed with error", error); - } -); -``` - - - - -```typescript -let receiverID: string = "UID", - messageType: string = CometChat.MESSAGE_TYPE.FILE, - receiverType: string = CometChat.RECEIVER_TYPE.USER, - mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage( - receiverID, - `INPUT FILE OBJECT`, - messageType, - receiverType - ); - -CometChat.sendMediaMessage(mediaMessage).then( - (message: CometChat.MediaMessage) => { - console.log("Media message sent successfully", message); - }, - (error: CometChat.CometChatException) => { - console.log("Media message sending failed with error", error); - } -); -``` - - - - -```typescript -let receiverID: string = "GUID", - messageType: string = CometChat.MESSAGE_TYPE.FILE, - receiverType: string = CometChat.RECEIVER_TYPE.GROUP, - mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage( - receiverID, - `INPUT FILE OBJECT`, - messageType, - receiverType - ); - -CometChat.sendMediaMessage(mediaMessage).then( - (message: CometChat.MediaMessage) => { - console.log("Media message sent successfully", message); - }, - (error: CometChat.CometChatException) => { - console.log("Media message sending failed with error", error); - } -); -``` - - - - - -The `MediaMessage` class constructor takes the following parameters: - -| Parameter | Description | -| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **receiverId** | The `UID` or `GUID` of the recipient. | -| **file** | The file object to be sent | -| **messageType** | The type of the message that needs to be sent which in this case can be:
`1. CometChat.MESSAGE_TYPE.IMAGE`
`2. CometChat.MESSAGE_TYPE.VIDEO`
`3. CometChat.MESSAGE_TYPE.AUDIO`
`4. CometChat.MESSAGE_TYPE.FILE` | -| **receiverType** | The type of the receiver to whom the message is to be sent.
`1. CometChat.RECEIVER_TYPE.USER`
`2. CometChat.RECEIVER_TYPE.GROUP` | - -2. **By providing the URL of the File:** The second way to send media messages using the CometChat SDK is to provide the SDK with the URL of any file that is hosted on your servers or any cloud storage. To achieve this you will have to make use of the Attachment class. For more information, you can refer to the below code snippet: - - - -```javascript -let receiverID = "cometchat-uid-2"; -let messageType = CometChat.MESSAGE_TYPE.IMAGE; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let mediaMessage = new CometChat.MediaMessage( - receiverID, - "", - messageType, - receiverType -); - -let file = { - name: "mario", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/mario/mario_PNG125.png", -}; - -let attachment = new CometChat.Attachment(file); - -mediaMessage.setAttachment(attachment); - -CometChat.sendMediaMessage(mediaMessage).then( - (mediaMessage) => { - console.log("message", mediaMessage); - }, - (error) => { - console.log("error in sending message", error); - } -); -``` - - - - -```javascript -let receiverID = "cometchat-guid-1"; -let messageType = CometChat.MESSAGE_TYPE.IMAGE; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; -let mediaMessage = new CometChat.MediaMessage( - receiverID, - "", - messageType, - receiverType -); - -let file = { - name: "mario", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/mario/mario_PNG125.png", -}; - -let attachment = new CometChat.Attachment(file); - -mediaMessage.setAttachment(attachment); - -CometChat.sendMediaMessage(mediaMessage).then( - (mediaMessage) => { - console.log("message", mediaMessage); - }, - (error) => { - console.log("error in sending message", error); - } -); -``` - - - - -```typescript -let receiverID: string = "cometchat-uid-2", - messageType: string = CometChat.MESSAGE_TYPE.IMAGE, - receiverType: string = CometChat.RECEIVER_TYPE.USER, - mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage( - receiverID, - "", - messageType, - receiverType - ); - -let file: Object = { - name: "mario", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/mario/mario_PNG125.png", -}; - -let attachment: CometChat.Attachment = new CometChat.Attachment(file); - -mediaMessage.setAttachment(attachment); - -CometChat.sendMediaMessage(mediaMessage).then( - (mediaMessage: CometChat.MediaMessage) => { - console.log("message", mediaMessage); - }, - (error: CometChat.CometChatException) => { - console.log("error in sending message", error); - } -); -``` - - - - -```typescript -let receiverID: string = "cometchat-guid-1", - messageType: string = CometChat.MESSAGE_TYPE.IMAGE, - receiverType: string = CometChat.RECEIVER_TYPE.GROUP, - mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage( - receiverID, - "", - messageType, - receiverType - ); - -let file: Object = { - name: "mario", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/mario/mario_PNG125.png", -}; - -let attachment: CometChat.Attachment = new CometChat.Attachment(file); - -mediaMessage.setAttachment(attachment); - -CometChat.sendMediaMessage(mediaMessage).then( - (mediaMessage: CometChat.MediaMessage) => { - console.log("message", mediaMessage); - }, - (error: CometChat.CometChatException) => { - console.log("error in sending message", error); - } -); -``` - - - - - -When a media message is sent successfully, the response will include a `MediaMessage` object which includes all information related to the sent message. - -## Multiple Attachments in a Media Message - -Starting version 3.0.9 & above the SDK supports sending multiple attachments in a single media message. As in the case of a single attachment in a media message, there are two ways you can send Media Messages using the CometChat SDK: - -1. **By providing an array of files:** You can now share an array of files while creating an object of the MediaMessage class. When the media message is sent using the `sendMediaMessage()` method, the files are uploaded to the CometChat servers & the URL of the files is sent in the success response of the `sendMediaMessage()` method. - -Getting the file Object: You can use different ionic packages for sending media messages. We demonstrate how to send images using CometChat. - - - -```javascript -const options = { -outputType: 1 -}; -this.imagePicker.getPictures(options) -.then((results) => { - if(results.length > 1){ - let files = []; - for(var i = 0;i { - console.log(err); -}); - -dataURItoBlob(dataURI) { - const byteString = atob(dataURI.split(',')[1]); - const mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; - const ab = new ArrayBuffer(byteString.length); - const ia = new Uint8Array(ab); - for (let i = 0; i < byteString.length; i++) { - ia[i] = byteString.charCodeAt(i); - } - const bb = new Blob([ab], {type: mimeString}); - return bb; -} -``` - - - - - - - -```javascript -let receiverID = "UID"; -let messageType = CometChat.MESSAGE_TYPE.FILE; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let mediaMessage = new CometChat.MediaMessage( - receiverID, - files, - messageType, - receiverType -); - -CometChat.sendMediaMessage(mediaMessage).then( - (message) => { - console.log("Media message sent successfully", message); - }, - (error) => { - console.log("Media message sending failed with error", error); - } -); -``` - - - - -```javascript -let receiverID = "GUID"; -let messageType = CometChat.MESSAGE_TYPE.FILE; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; -let mediaMessage = new CometChat.MediaMessage( - receiverID, - file, - messageType, - receiverType -); - -CometChat.sendMediaMessage(mediaMessage).then( - (message) => { - console.log("Media message sent successfully", message); - }, - (error) => { - console.log("Media message sending failed with error", error); - } -); -``` - - - - -```typescript -let receiverID: string = "UID", - messageType: string = CometChat.MESSAGE_TYPE.FILE, - receiverType: string = CometChat.RECEIVER_TYPE.USER, - mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage( - receiverID, - files, - messageType, - receiverType - ); - -CometChat.sendMediaMessage(mediaMessage).then( - (message: CometChat.MediaMessage) => { - console.log("Media message sent successfully", message); - }, - (error: CometChat.CometChatException) => { - console.log("Media message sending failed with error", error); - } -); -``` - - - - -```typescript -let receiverID: string = "GUID", - messageType: string = CometChat.MESSAGE_TYPE.FILE, - receiverType: string = CometChat.RECEIVER_TYPE.GROUP, - mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage( - receiverID, - files, - messageType, - receiverType - ); - -CometChat.sendMediaMessage(mediaMessage).then( - (message: CometChat.MediaMessage) => { - console.log("Media message sent successfully", message); - }, - (error: CometChat.CometChatException) => { - console.log("Media message sending failed with error", error); - } -); -``` - - - - - -The `MediaMessage` class constructor takes the following parameters: - -| Parameter | Description | -| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **receiverId** | The `UID` or `GUID` of the recipient. | -| **files** | An array of files. | -| **messageType** | The type of the message that needs to be sent which in this case can be:
1.`CometChat.MESSAGE_TYPE.IMAGE`
2.`CometChat.MESSAGE_TYPE.VIDEO`
3.`CometChat.MESSAGE_TYPE.AUDIO`
4.`CometChat.MESSAGE_TYPE.FILE` | -| **receiverType** | The type of the receiver to whom the message is to be sent.
`1. CometChat.RECEIVER_TYPE.USER`
`2. CometChat.RECEIVER_TYPE.GROUP` | - -2. **By providing the URL of the multiple files:** The second way to send multiple attachments in a single media message using the CometChat SDK is to provide the SDK with the URL of multiple files that are hosted on your servers or any cloud storage. To achieve this you will have to make use of the Attachment class. For more information, you can refer to the below code snippet: - - - -```javascript -let receiverID = "cometchat-uid-2"; -let messageType = CometChat.MESSAGE_TYPE.IMAGE; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let mediaMessage = new CometChat.MediaMessage( - receiverID, - "", - messageType, - receiverType -); - -let attachment1 = { - name: "mario", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/mario/mario_PNG125.png", -}; - -let attachment2 = { - name: "jaguar", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/jaguar/jaguar_PNG20759.png", -}; - -let attachments = []; -attachments.push(new CometChat.Attachment(attachment1)); -attachments.push(new CometChat.Attachment(attachment2)); - -mediaMessage.setAttachments(attachments); - -CometChat.sendMediaMessage(mediaMessage).then( - (mediaMessage) => { - console.log("message", mediaMessage); - }, - (error) => { - console.log("error in sending message", error); - } -); -``` - - - - -```javascript -let receiverID = "cometchat-guid-1"; -let messageType = CometChat.MESSAGE_TYPE.IMAGE; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; -let mediaMessage = new CometChat.MediaMessage( - receiverID, - "", - messageType, - receiverType -); - -let attachment1 = { - name: "mario", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/mario/mario_PNG125.png", -}; - -let attachment2 = { - name: "jaguar", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/jaguar/jaguar_PNG20759.png", -}; - -let attachments = []; -attachments.push(new CometChat.Attachment(attachment1)); -attachments.push(new CometChat.Attachment(attachment2)); - -mediaMessage.setAttachments(attachments); - -CometChat.sendMediaMessage(mediaMessage).then( - (mediaMessage) => { - console.log("message", mediaMessage); - }, - (error) => { - console.log("error in sending message", error); - } -); -``` - - - - -```typescript -let receiverID: string = "cometchat-uid-2", - messageType: string = CometChat.MESSAGE_TYPE.IMAGE, - receiverType: string = CometChat.RECEIVER_TYPE.USER, - mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage( - receiverID, - "", - messageType, - receiverType - ); - -let attachment1: Object = { - name: "mario", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/mario/mario_PNG125.png", -}; - -let attachment2: Object = { - name: "jaguar", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/jaguar/jaguar_PNG20759.png", -}; - -let attachments: Array = []; -attachments.push(new CometChat.Attachment(attachment1)); -attachments.push(new CometChat.Attachment(attachment2)); - -mediaMessage.setAttachments(attachments); - -CometChat.sendMediaMessage(mediaMessage).then( - (mediaMessage: CometChat.MediaMessage) => { - console.log("message", mediaMessage); - }, - (error: CometChat.CometChatException) => { - console.log("error in sending message", error); - } -); -``` - - - - -```typescript -let receiverID: string = "cometchat-guid-1", - messageType: string = CometChat.MESSAGE_TYPE.IMAGE, - receiverType: string = CometChat.RECEIVER_TYPE.GROUP, - mediaMessage: CometChat.MediaMessage = new CometChat.MediaMessage( - receiverID, - "", - messageType, - receiverType - ); - -let attachment1: Object = { - name: "mario", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/mario/mario_PNG125.png", -}; - -let attachment2: Object = { - name: "jaguar", - extension: "png", - mimeType: "image/png", - url: "https://pngimg.com/uploads/jaguar/jaguar_PNG20759.png", -}; - -let attachments: Array = []; -attachments.push(new CometChat.Attachment(attachment1)); -attachments.push(new CometChat.Attachment(attachment2)); - -mediaMessage.setAttachments(attachments); - -CometChat.sendMediaMessage(mediaMessage).then( - (mediaMessage: CometChat.MediaMessage) => { - console.log("message", mediaMessage); - }, - (error: CometChat.CometChatException) => { - console.log("error in sending message", error); - } -); -``` - - - - - -When a media message is sent successfully, the response will include a `MediaMessage` object which includes all information related to the sent message. - -You can use the `setMetadata()`, `setCaption()` & `setTags()` methods to add metadata, caption and tags respectively in exactly the same way as it is done while sending a single file or attachment in a Media Message. - -## Custom Message - -*In other words, as a sender, how do I send a custom message like location coordinates?* - -CometChat allows you to send custom messages which are neither text nor media messages. To send a custom message, you need to use the `sendCustomMessage()` method. - -The `sendCustomMessage()` method takes an object of the `CustomMessage` which can be obtained using the below constructor. - - - -```javascript -var customMessage = new CometChat.CustomMessage( - receiverID, - receiverType, - customType, - customData -); -``` - - - - -```typescript -let customMessage: CometChat.CustomMessage = new CometChat.CustomMessage( - receiverID, - receiverType, - customType, - customData -); -``` - - - - - -The above constructor, helps you create a custom message with the message type set to whatever is passed to the constructor and the category set to `custom`. - -The parameters involved are: - -1. `receiverId` - The unique ID of the user or group to which the message is to be sent. -2. `receiverType` - Type of the receiver i.e user or group -3. `customType` - custom message type that you need to set -4. `customData` - The data to be passed as the message in the form of a JSON Object. - -You can also use the subType field of the `CustomMessage` class to set a specific type for the custom message. This can be achieved using the `setSubtype()` method. - -### Add Tags - -To add a tag to a message you can use the `setTags()` method of the CustomMessage Class. The `setTags()` method accepts a list of tags. - - - -```javascript -let tags = ["starredMessage"]; - -customMessage.setTags(tags); -``` - - - - -```typescript -let tags: Array = ["starredMessage"]; - -customMessage.setTags(tags); -``` - - - - - -Once the object of `CustomMessage` class is ready you can send the custom message using the `sendCustomMessage()` method. - - - -```javascript -let receiverID = "UID"; -let customData = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002", -}; -let customType = "location"; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let customMessage = new CometChat.CustomMessage( - receiverID, - receiverType, - customType, - customData -); - -CometChat.sendCustomMessage(customMessage).then( - (message) => { - console.log("custom message sent successfully", message); - }, - (error) => { - console.log("custom message sending failed with error", error); - } -); -``` - - - - -```javascript -let receiverID = "GUID"; -let customData = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002", -}; -let customType = "location"; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; - -let customMessage = new CometChat.CustomMessage( - receiverID, - receiverType, - customType, - customData -); - -CometChat.sendCustomMessage(customMessage).then( - (message) => { - console.log("custom message sent successfully", message); - }, - (error) => { - console.log("custom message sending failed with error", error); - } -); -``` - - - - -```typescript -let receiverID: string = "UID", - customData: Object = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002", - }, - customType: string = "location", - receiverType: string = CometChat.RECEIVER_TYPE.USER, - customMessage: CometChat.CustomMessage = new CometChat.CustomMessage( - receiverID, - receiverType, - customType, - customData - ); - -CometChat.sendCustomMessage(customMessage).then( - (message: CometChat.CustomMessage) => { - console.log("custom message sent successfully", message); - }, - (error: CometChat.CometChatException) => { - console.log("custom message sending failed with error", error); - } -); -``` - - - - -```typescript -let receiverID: string = "GUID", - customData: Object = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002", - }, - customType: string = "location", - receiverType: string = CometChat.RECEIVER_TYPE.GROUP, - customMessage: CometChat.CustomMessage = new CometChat.CustomMessage( - receiverID, - receiverType, - customType, - customData - ); - -CometChat.sendCustomMessage(customMessage).then( - (message: CometChat.CustomMessage) => { - console.log("custom message sent successfully", message); - }, - (error: CometChat.CometChatException) => { - console.log("custom message sending failed with error", error); - } -); -``` - - - - - -The above sample explains how custom messages can be used to share the location with a user. The same can be achieved for groups. - -On success, you will receive an object of the `CustomMessage` class. - -### Update Conversation - -*How can I decide whether the custom message should update the last message of a conversation?* - -By default, a custom message will update the last message of a conversation. If you wish to not update the last message of the conversation when a custom message is sent, please use `shouldUpdateConversation(value: boolean)` method of the Custom Message. - - - -```javascript -let receiverID = "UID"; -let customData = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002", -}; -let customType = "location"; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let customMessage = new CometChat.CustomMessage( - receiverID, - receiverType, - customType, - customData -); - -customMessage.shouldUpdateConversation(false); -CometChat.sendCustomMessage(customMessage).then( - (message) => { - console.log("custom message sent successfully", message); - }, - (error) => { - console.log("custom message sending failed with error", error); - } -); -``` - - - - -```javascript -let receiverID = "GUID"; -let customData = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002", -}; -let customType = "location"; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; -let customMessage = new CometChat.CustomMessage( - receiverID, - receiverType, - customType, - customData -); - -customMessage.shouldUpdateConversation(false); -CometChat.sendCustomMessage(customMessage).then( - (message) => { - console.log("custom message sent successfully", message); - }, - (error) => { - console.log("custom message sending failed with error", error); - } -); -``` - - - - -```typescript -let receiverID: string = "UID", - customData: Object = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002", - }, - customType: string = "location", - receiverType: string = CometChat.RECEIVER_TYPE.USER, - customMessage: CometChat.CustomMessage = new CometChat.CustomMessage( - receiverID, - receiverType, - customType, - customData - ); - -customMessage.shouldUpdateConversation(false); -CometChat.sendCustomMessage(customMessage).then( - (message: CometChat.CustomMessage) => { - console.log("custom message sent successfully", message); - }, - (error: CometChat.CometChatException) => { - console.log("custom message sending failed with error", error); - } -); -``` - - - - -```typescript -let receiverID: string = "GUID", - customData: Object = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002", - }, - customType: string = "location", - receiverType: string = CometChat.RECEIVER_TYPE.GROUP, - customMessage: CometChat.CustomMessage = new CometChat.CustomMessage( - receiverID, - receiverType, - customType, - customData - ); - -customMessage.shouldUpdateConversation(false); -CometChat.sendCustomMessage(customMessage).then( - (message: CometChat.CustomMessage) => { - console.log("custom message sent successfully", message); - }, - (error: CometChat.CometChatException) => { - console.log("custom message sending failed with error", error); - } -); -``` - - - - - -### Custom Notification Body - -*How can i customise the notification body of custom message?* - -To add a custom notification body for `Push, Email & SMS` notification of a custom message you can use the `setConversationText(text: string)` method of Custom Message class. - - - -```javascript -let receiverID = "UID"; -let customData = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002", -}; -let customType = "location"; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let customMessage = new CometChat.CustomMessage( - receiverID, - receiverType, - customType, - customData -); - -customMessage.setConversationText("Custom notification body"); -CometChat.sendCustomMessage(customMessage).then( - (message) => { - console.log("custom message sent successfully", message); - }, - (error) => { - console.log("custom message sending failed with error", error); - } -); -``` - - - - -```javascript -let receiverID = "GUID"; -let customData = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002", -}; -let customType = "location"; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; -let customMessage = new CometChat.CustomMessage( - receiverID, - receiverType, - customType, - customData -); - -customMessage.setConversationText("Custom notificatoin body"); -CometChat.sendCustomMessage(customMessage).then( - (message) => { - console.log("custom message sent successfully", message); - }, - (error) => { - console.log("custom message sending failed with error", error); - } -); -``` - - - - -```typescript -let receiverID: string = "UID", - customData: Object = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002", - }, - customType: string = "location", - receiverType: string = CometChat.RECEIVER_TYPE.USER, - customMessage: CometChat.CustomMessage = new CometChat.CustomMessage( - receiverID, - receiverType, - customType, - customData - ); - -customMessage.setConversationText("Custom notification body"); -CometChat.sendCustomMessage(customMessage).then( - (message: CometChat.CustomMessage) => { - console.log("custom message sent successfully", message); - }, - (error: CometChat.CometChatException) => { - console.log("custom message sending failed with error", error); - } -); -``` - - - - -```typescript -let receiverID: string = "GUID", - customData: Object = { - latitude: "50.6192171633316", - longitude: "-72.68182268750002", - }, - customType: string = "location", - receiverType: string = CometChat.RECEIVER_TYPE.GROUP, - customMessage: CometChat.CustomMessage = new CometChat.CustomMessage( - receiverID, - receiverType, - customType, - customData - ); - -customMessage.setConversationText("Custom notification body"); -CometChat.sendCustomMessage(customMessage).then( - (message: CometChat.CustomMessage) => { - console.log("custom message sent successfully", message); - }, - (error: CometChat.CometChatException) => { - console.log("custom message sending failed with error", error); - } -); -``` - - - - - - - -It is also possible to send interactive messages from CometChat, to know more [click here](/sdk/ionic-legacy/interactive-messages) - - diff --git a/sdk/ionic-legacy/setup.mdx b/sdk/ionic-legacy/setup.mdx deleted file mode 100644 index 754b88623..000000000 --- a/sdk/ionic-legacy/setup.mdx +++ /dev/null @@ -1,110 +0,0 @@ ---- -title: "Setup" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/setup-sdk) which provides full compatibility with Ionic applications. - - - -Migrating app version from v2 to v3 ? - -Skip the create new app step. Your existing v2 app can be migrated to v3. Follow steps mentioned in **Add the CometChat dependency** section below to upgrade to latest version of v3 - - - -## Get your Application Keys - -[Signup for CometChat](https://app.cometchat.com) and then: - -1. Create a new app -2. Head over to the **API & Auth Keys** section and note the **Auth Key**, **App ID** & **Region** - -## Add the CometChat Dependency - -Install the package as NPM module: - - - -```js -npm install @cometchat/chat-sdk-ionic -``` - - - - - -## Initialize CometChat - -The `init()` method initialises the settings required for CometChat. The `init()` method takes the below parameters: - -1. appId - Your CometChat App ID -2. appSettings - An object of the AppSettings class can be created using the AppSettingsBuilder class. The region field is mandatory and can be set using the `setRegion()` method. - -The `AppSettings` class allows you to configure two settings: - -* **Region**: The region where you app was created. -* [Presence Subscription](/sdk/ionic-legacy/user-presence): Represents the subscription type for user presence (real-time online/offline status) -* **autoEstablishSocketConnection(boolean value)**: This property takes a boolean value which when set to true informs the SDK to manage the web-socket connection internally. If set to false, it informs the SDK that the web-socket connection will be managed manually. The default value for this parameter is true. For more information on this, please check the [Managing Web-Socket connections manually](/sdk/ionic-legacy/managing-connections-manually) section. The default value for this property is **true.** -* **overrideAdminHost(adminHost: string)**: This method takes the admin URL as input and uses this admin URL instead of the default admin URL. This can be used in case of dedicated deployment of CometChat. -* **overrideClientHost(clientHost: string)**: This method takes the client URL as input and uses this client URL instead of the default client URL. This can be used in case of dedicated deployment of CometChat. - -You need to call `init()` before calling any other method from CometChat. We suggest you call the `init()` method on app startup, preferably in the `index.js` file. - - - -```js -import { CometChat } from "@cometchat/chat-sdk-ionic"; - -let appID = "APP_ID", - region = "REGION", - appSetting = new CometChat.AppSettingsBuilder() - .subscribePresenceForAllUsers() - .setRegion(region) - .autoEstablishSocketConnection(true) - .build(); - -CometChat.init(appID, appSetting).then( - () => { - console.log("Initialization completed successfully"); - }, - (error) => { - console.log("Initialization failed with error:", error); - } -); -``` - - - - -```ts -import { CometChat } from "@cometchat/chat-sdk-ionic"; - -let appID: string = "APP_ID", - region: string = "APP_REGION", - appSetting: CometChat.AppSettings = new CometChat.AppSettingsBuilder() - .subscribePresenceForAllUsers() - .setRegion(region) - .autoEstablishSocketConnection(true) - .build(); - -CometChat.init(appID, appSetting).then( - (initialized: boolean) => { - console.log("Initialization completed successfully", initialized); - }, - (error: CometChat.CometChatException) => { - console.log("Initialization failed with error:", error); - } -); -``` - - - - - -Make sure you replace the `APP_ID` with your CometChat **App ID** and `REGION` with your **App Region** in the above code. - -| Parameter | Description | -| ---------- | ----------------------------------- | -| appID | CometChat App ID | -| appSetting | An object of the AppSettings class. | diff --git a/sdk/ionic-legacy/threaded-messages.mdx b/sdk/ionic-legacy/threaded-messages.mdx deleted file mode 100644 index db986c623..000000000 --- a/sdk/ionic-legacy/threaded-messages.mdx +++ /dev/null @@ -1,274 +0,0 @@ ---- -title: "Threaded Messages" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/threaded-messages) which provides full compatibility with Ionic applications. - - -Messages that are started from a particular message are called Threaded messages or simply threads. Each Thread is attached to a message which is the Parent message for that thread. - -## Send Message in a Thread - -As mentioned in the [Send a Message](/sdk/ionic-legacy/send-message) section. You can either send a message to a User or a Group based on the `receiverType` and the UID/GUID specified for the message. A message can belong to either of the below types: - -1. Text Message -2. Media Message -3. Custom Message. - -Any of the above messages can be sent in a thread. As mentioned, a thread is identified based on the Parent message. So while sending a message the `parentMessageId` must be set for the message to indicate that the message to be sent needs to be a part of the thread with the specified `parentMessageId`. - -This can be achieved using the `setParentMessageId()` method provided by the object of the `TextMessage`, `MediaMessage` and `CustomMessage` class. The id specified in the `setParentMessageId()` method maps the message sent to the particular thread. - -**Example to Send a Text Message in a thread in a user conversation.** - - - -```javascript -let textMessage = new CometChat.TextMessage(UID, "Hello", CometChat.RECEIVER_TYPE.USER); -textMessage.setParentMessageId(100); - -CometChat.sendMessage(textMessage).then( - message => { - console.log('Message sent successfully', message); - }, err => { - console.log('err', err); - } -) -``` - - - - -```typescript -let receiverId = "UID", - receiverType: string = CometChat.RECEIVER_TYPE.USER, - textMessage: CometChat.TextMessage = new CometChat.TextMessage(receiverId, "Hello", receiverType), - messageId: number = 100; - -textMessage.setParentMessageId(messageId); - -CometChat.sendMessage(textMessage).then( - (message: CometChat.TextMessage) => { - console.log('Message sent successfully', message); - }, (error: CometChat.CometChatException) => { - console.log('Message sending failed', error); - } -); -``` - - - - - -The above snippet shows how a message with the text "Hello" can be sent in the thread with `parentMessageId` 100. - -Similarly, using the `setparentMessageId()` method, Media and Custom Messages can be sent in threads too. - -### Receiving Real-Time Messages - -The procedure to receive real-time messages is exactly the same as mentioned in the [Receive Messages](/sdk/ionic-legacy/receive-messages). This can be achieved using the `MessageListener` class provided by the SDK. - -To add a MessageListener, you can use the `addMessageListener()` method of the SDK. The only thing that needs to be checked is if the received message belongs to the active thread. This can be done using the `parentMessageId` field of the message object. - - - -```javascript -var listenerID = "UNIQUE_LISTENER_ID"; -var activeThreadId = 100; - -CometChat.addMessageListener( -listenerID, -new CometChat.MessageListener({ - onTextMessageReceived: textMessage => { - if(textMessage.getParentMessageId() == activeThreadId) { - console.log("Text message received for active thread.", textMessage); - } - }, - onMediaMessageReceived: mediaMessage => { - if(mediaMessage.getParentMessageId() == activeThreadId) { - console.log("Media message received for active thread.", textMessage); - } - }, - onCustomMessageReceived: customMessage => { - if(customMessage.getParentMessageId() == activeThreadId) { - console.log("Custom message received for active thread.", textMessage); - } - } -}) -); -``` - - - - -```typescript -var listenerID: string = "UNIQUE_LISTENER_ID", - activeThreadId: number = 100; - -CometChat.addMessageListener( - listenerID, - new CometChat.MessageListener({ - onTextMessageReceived: (textMessage: CometChat.TextMessage) => { - if (textMessage.getParentMessageId() == activeThreadId) { - console.log("Text message received for active thread.", textMessage); - } - }, - onMediaMessageReceived: (mediaMessage: CometChat.MediaMessage) => { - if (mediaMessage.getParentMessageId() == activeThreadId) { - console.log("Media message received for active thread.", mediaMessage); - } - }, - onCustomMessageReceived: (customMessage: CometChat.CustomMessage) => { - if (customMessage.getParentMessageId() == activeThreadId) { - console.log("Custom message received for active thread.", customMessage); - } - } - }) -); -``` - - - - - -### Fetch all the messages for any particular thread. - -You can fetch all the messages belonging to a particular thread by using the `MessagesRequest` class. In order to get an object of the `MessagesRequest` class, you need to use the `MessagesRequestBuilder` class. and use the `setParentMessageId()` method of the `MessagesRequestBuilder` to inform the SDK that you only need the messages belonging to the thread with the specified parentMessageId. - -Once you have the object of the `MessagesRequest` class, you need to call the `fetchPrevious()` method to get the latest messages in the thread. In one integration, a maximum of 100 messages can be fetched. If you wish to fetch the next set of messages, you need to call the `fetchPrevious()` method again on the same object. - - - -```javascript -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setLimit(30) - .setParentMessageId(100) - .build(); - -messagesRequest.fetchPrevious().then( - messages => { - console.log("Messages for thread fetched successfully", messages); - }, - error => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```typescript -let limit: number = 30, - parentMessageId: number = 1, - messagesRequest: CometChat.MessagesRequest = new CometChat.MessagesRequestBuilder() - .setLimit(limit) - .setParentMessageId(parentMessageId) - .build(); - -messagesRequest.fetchPrevious().then( - (messages: CometChat.BaseMessage[]) => { - console.log("Messages for thread fetched successfully", messages); - }, (error: CometChat.CometChatException) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -## Avoid Threaded Messages in User/Group Conversations - -While fetching messages for normal user/group conversations using the `MessagesRequest`, the threaded messages by default will be a part of the list of messages received. In order to exclude the threaded messages from the list of user/group messages, you need to use the `hideReplies()` method of the `MessagesRequestBuilder` class. This method takes a boolean argument which when set to true excludes the messages belonging to threads from the list of messages. - - - -```javascript -let UID = "UID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .hideReplies(true) - .build(); - -messagesRequest.fetchPrevious().then( - messages => { - console.log("Messages for thread fetched successfully", messages); - }, error => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```javascript -let GUID = "GUID"; -let limit = 30; -let messagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hideReplies(true) - .build(); - -messagesRequest.fetchPrevious().then( - messages => { - console.log("Messages for thread fetched successfully", messages); - }, error => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```typescript -let UID: string = "UID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = new CometChat.MessagesRequestBuilder() - .setUID(UID) - .setLimit(limit) - .hideReplies(true) - .build(); - -messagesRequest.fetchPrevious().then( - (messages: CometChat.BaseMessage[]) => { - console.log("Messages fetched successfully", messages); - }, (error: CometChat.CometChatException) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - -```typescript -let GUID: string = "GUID", - limit: number = 30, - messagesRequest: CometChat.MessagesRequest = new CometChat.MessagesRequestBuilder() - .setGUID(GUID) - .setLimit(limit) - .hideReplies(true) - .build(); - -messagesRequest.fetchPrevious().then( - (messages: CometChat.BaseMessage[]) => { - console.log("Messages fetched successfully", messages); - }, (error: CometChat.CometChatException) => { - console.log("Message fetching failed with error:", error); - } -); -``` - - - - - -The above snippet will return messages between the logged in user and `cometchat-uid-1` excluding all the threaded messages belonging to the same conversation. diff --git a/sdk/ionic-legacy/transfer-group-ownership.mdx b/sdk/ionic-legacy/transfer-group-ownership.mdx deleted file mode 100644 index e1211e3e2..000000000 --- a/sdk/ionic-legacy/transfer-group-ownership.mdx +++ /dev/null @@ -1,46 +0,0 @@ ---- -title: "Transfer Group Ownership" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/transfer-group-ownership) which provides full compatibility with Ionic applications. - - -*In other words, as a logged-in user, how do I transfer the ownership of any group if I am the owner of the group?* - -In order to transfer the ownership of any group, the first condition is that you must be the owner of the group. In case you are the owner of the group, you can use the `transferGroupOwnership()` method provided by the `CometChat` class. - -This will be helpful as the owner is not allowed to leave the group. In case, you as the owner would like to leave the group, you will have to use this method and transfer your ownership first to any other member of the group and only then you will be allowed to leave the group. - - - -```javascript -let GUID = "GUID"; -let UID = "UID"; -CometChat.transferGroupOwnership(GUID, UID).then( - () => { - console.log("Successfully transferred ownership of the group."); - }, error => { - console.log("Could not transfer ownership of the group: ", error); - } -) -``` - - - - -```typescript -let GUID: string = "GUID"; -let UID: string = "UID"; -CometChat.transferGroupOwnership(GUID, UID).then( - (ownershipTransferred: string) => { - console.log("Successfully transferred ownership of the group."); - }, error => { - console.log("Could not transfer ownership of the group: ", error); - } -); -``` - - - - diff --git a/sdk/ionic-legacy/transient-messages.mdx b/sdk/ionic-legacy/transient-messages.mdx deleted file mode 100644 index 1fb922060..000000000 --- a/sdk/ionic-legacy/transient-messages.mdx +++ /dev/null @@ -1,114 +0,0 @@ ---- -title: "Transient Messages" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/transient-messages) which provides full compatibility with Ionic applications. - - -Transient messages are messages that are sent in real-time only and are not saved or tracked anywhere. The receiver of the message will only receive the message if he is online and these messages cannot be retrieved later. - -## Send a Transient Message - -You can use the `sendTransientMessage()` method to send a transient message to a user or in a group. The receiver will receive this information in the `onTransientMessageReceived()` method of the `MessageListener` class. In order to send the transient message, you need to use the `TransientMessage` class. - - - -```javascript -let receiverId = "UID"; -let receiverType = CometChat.RECEIVER_TYPE.USER; -let data = { "LIVE_REACTION": "heart" }; - -let transientMessage = new CometChat.TransientMessage(receiverId, receiverType, data); -CometChat.sendTransientMessage(transientMessage); -``` - - - - -```javascript -let receiverId = "GUID"; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; -let data = { "LIVE_REACTION": "heart" }; - -let transientMessage = new CometChat.TransientMessage(receiverId, receiverType, data); -CometChat.sendTransientMessage(transientMessage); -``` - - - - -```typescript -let receiverId: string = "UID"; -let receiverType: string = CometChat.RECEIVER_TYPE.USER; -let data: Object = { "LIVE_REACTION": "heart" }; - -let transientMessage: CometChat.TransientMessage = new CometChat.TransientMessage(receiverId, receiverType, data); -CometChat.sendTransientMessage(transientMessage); -``` - - - - -```typescript -let receiverId: string = "GUID"; -let receiverType: string = CometChat.RECEIVER_TYPE.GROUP; -let data: Object = { "LIVE_REACTION": "heart" }; - -let transientMessage: CometChat.TransientMessage = new CometChat.TransientMessage(receiverId, receiverType, data); -CometChat.sendTransientMessage(transientMessage); -``` - - - - - -## Real-time Transient Messages - -*In other words, as a recipient, how do I know when someone sends a transient message?* - -You will receive the transient message in the `onTransientMessageReceived()` method of the registered `MessageListener` class. - - - -```javascript -let listenerId = "UNIQUE_LITENER_ID"; - -CometChat.addMessageListener( -listenerId, -new CometChat.MessageListener({ - onTransientMessageReceived: transientMessage => { - console.log('transient message received', transientMessage); - }, -}) -); -``` - - - - -```typescript -let listenerId: string = "UNIQUE_LITENER_ID"; - -CometChat.addMessageListener( - listenerId, - new CometChat.MessageListener({ - onTransientMessageReceived: (transientMessage: CometChat.TransientMessage) => { - console.log('transient message received', transientMessage); - }, - }) -); -``` - - - - - -The `TransientMessage` class consists of the below parameters: - -| Parameter | Information | -| ---------------- | -------------------------------------------------------------------------------------------------------- | -| **sender** | An object of the User class holding all the information. related to the sender of the transient message. | -| **receiverId** | Unique Id of the receiver. This can be the Id of the group or the user the transient message is sent to. | -| **receiverType** | The type of the receiver - `CometChat.RECEIVER_TYPE.USER` or `CometChat.RECEIVER_TYPE.GROUP` | -| **data** | A JSONObject to provide data. | diff --git a/sdk/ionic-legacy/typing-indicators.mdx b/sdk/ionic-legacy/typing-indicators.mdx deleted file mode 100644 index 0fc63e6a9..000000000 --- a/sdk/ionic-legacy/typing-indicators.mdx +++ /dev/null @@ -1,176 +0,0 @@ ---- -title: "Typing Indicators" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/typing-indicators) which provides full compatibility with Ionic applications. - - -## Send a Typing Indicator - -*In other words, as a sender, how do I let the recipient(s) know that I'm typing?* - -### Start Typing - -You can use the `startTyping()` method to inform the receiver that the logged in user has started typing. The receiver will receive this information in the `onTypingStarted()` method of the `MessageListener` class. In order to send the typing indicator, you need to use the `TypingIndicator` class. - - - -```javascript -let receiverId = "UID"; -let receiverType = CometChat.RECEIVER_TYPE.USER; - -let typingNotification = new CometChat.TypingIndicator(receiverId, receiverType); -CometChat.startTyping(typingNotification); -``` - - - - -```javascript -let receiverId = "GUID"; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; - -let typingNotification = new CometChat.TypingIndicator(receiverId,receiverType); -CometChat.startTyping(typingNotification); -``` - - - - -```typescript -let receiverId: string = "UID"; -let receiverType: string = CometChat.RECEIVER_TYPE.USER; - -let typingNotification: CometChat.TypingIndicator = new CometChat.TypingIndicator(receiverId, receiverType); -CometChat.startTyping(typingNotification); -``` - - - - -```typescript -let receiverId: string = "GUID"; -let receiverType: string = CometChat.RECEIVER_TYPE.GROUP; - -let typingNotification: CometChat.TypingIndicator = new CometChat.TypingIndicator(receiverId, receiverType); -CometChat.startTyping(typingNotification); -``` - - - - - -### Stop Typing - -You can use the `endTyping()` method to inform the receiver that the logged in user has stopped typing. The receiver will receive this information in the `onTypingEnded()` method of the `MessageListener` class. In order to send the typing indicator, you need to use the `TypingIndicator` class. - - - -```javascript -let receiverId = "UID"; -let receiverType = CometChat.RECEIVER_TYPE.USER; - -let typingNotification = new CometChat.TypingIndicator(receiverId, receiverType); -CometChat.endTyping(typingNotification); -``` - - - - -```javascript -let receiverId = "GUID"; -let receiverType = CometChat.RECEIVER_TYPE.GROUP; - -let typingNotification = new CometChat.TypingIndicator(receiverId, receiverType); -CometChat.endTyping(typingNotification); -``` - - - - -```typescript -let receiverId: string = "UID"; -let receiverType: string = CometChat.RECEIVER_TYPE.USER; - -let typingNotification: CometChat.TypingIndicator = new CometChat.TypingIndicator(receiverId, receiverType); -CometChat.endTyping(typingNotification); -``` - - - - -```typescript -let receiverId: string = "GUID"; -let receiverType: string = CometChat.RECEIVER_TYPE.GROUP; - -let typingNotification: CometChat.TypingIndicator = new CometChat.TypingIndicator(receiverId, receiverType); -CometChat.endTyping(typingNotification); -``` - - - - - - -Custom Data - -You can use the `metadata` field of the `TypingIndicator` class to pass additional data along with the typing indicators. The metadata field is a JSONObject and can be set using the `setMetadata()` method of the `TypingIndicator` class. This data will be received at the receiver end and can be obtained using the `getMetadata()` method. - - - -## Real-time Typing Indicators - -*In other words, as a recipient, how do I know when someone is typing?* - -You will receive the typing indicators in the `onTypingStarted()` and the `onTypingEnded()` method of the registered `MessageListener` class. - - - -```javascript -let listenerId = "UNIQUE_LITENER_ID"; - -CometChat.addMessageListener( -listenerId, -new CometChat.MessageListener({ - onTypingStarted: typingIndicator => { - console.log("Typing started :", typingIndicator); - }, - onTypingEnded: typingIndicator => { - console.log("Typing ended :", typingIndicator); - } -}) -); -``` - - - - -```typescript -let listenerId: string = "UNIQUE_LITENER_ID"; - -CometChat.addMessageListener( - listenerId, - new CometChat.MessageListener({ - onTypingStarted: (typingIndicator: CometChat.TypingIndicator) => { - console.log("Typing started :", typingIndicator); - }, - onTypingEnded: (typingIndicator: CometChat.TypingIndicator) => { - console.log("Typing ended :", typingIndicator); - } - }) -); -``` - - - - - -The `TypingIndicator` class consists of the below parameters: - -| Parameter | Information | -| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **sender** | An object of the `User` class holding all the information. related to the sender of the typing indicator. | -| **receiverId** | Unique Id of the receiver. This can be the Id of the group or the user the typing indicator is sent to. | -| **receiverType** | This parameter indicates if the typing indicator is to be sent to a user or a group. The possible values are: 1. `CometChatConstants.RECEIVER_TYPE_USER` 2. `CometChatConstants.RECEIVER_TYPE_GROUP` | -| **metadata** | A JSONObject to provider additional data. | diff --git a/sdk/ionic-legacy/update-group.mdx b/sdk/ionic-legacy/update-group.mdx deleted file mode 100644 index fdeabb595..000000000 --- a/sdk/ionic-legacy/update-group.mdx +++ /dev/null @@ -1,63 +0,0 @@ ---- -title: "Update A Group" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/update-group) which provides full compatibility with Ionic applications. - - -## Update Group - -*In other words, as a group owner, how can I update the group details?* - -You can update the existing details of the group using the `updateGroup()` method. - - - -```javascript -var GUID = "GUID"; -var groupName = "Hello Group"; -var groupType = CometChat.GROUP_TYPE.PUBLIC; -var group = new CometChat.Group(GUID, groupName, groupType); - -CometChat.updateGroup(group).then( -group => { - console.log("Groups details updated successfully:", group); -}, error => { - console.log("Group details update failed with exception:", error); -} -); -``` - - - - -```typescript -var GUID: string = "GUID"; -var groupName: string = "Hello Group!"; -var groupType: string = CometChat.GROUP_TYPE.PUBLIC; - -var group: CometChat.Group = new CometChat.Group(GUID, groupName, groupType); - -CometChat.updateGroup(group).then( - (group: CometChat.Group) => { - console.log("Group details updated successfully:", group); - }, (error: CometChat.CometChatException) => { - console.log("Group details update failed with exception:", error); - } -); -``` - - - - - -This method takes an instance of the `Group` class as a parameter which should contain the data that you wish to update. - -| Parameter | Description | -| --------- | ---------------------------- | -| `group` | an instance of class `Group` | - -After a successful update of the group, you will receive an instance of `Group` class containing update information of the group. - -For more information on the `Group` class, please check [here](/sdk/ionic-legacy/create-group#group-class). diff --git a/sdk/ionic-legacy/upgrading-from-v3-guide.mdx b/sdk/ionic-legacy/upgrading-from-v3-guide.mdx deleted file mode 100644 index 2fcea9300..000000000 --- a/sdk/ionic-legacy/upgrading-from-v3-guide.mdx +++ /dev/null @@ -1,63 +0,0 @@ ---- -title: "Upgrading From V3" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/upgrading-from-v3) which provides full compatibility with Ionic applications. - - -Upgrading from v3.x to v4 is fairly simple. Below are the major changes that are released as a part of CometChat v4: - -Please follow the [setup](/sdk/ionic-legacy/setup) instructions to upgrade to the latest V3 version. - -## Dependency Change - -### Chat SDK - - - -```bash -npm i @cometchat/chat-sdk-ionic -``` - - - - - -### Calls SDK - - - -```bash -npm i @cometchat/calls-sdk-ionic -``` - - - - - -## Change The Import Statements - -### Chat SDK - - - -```javascript -import { CometChat } from "@cometchat/chat-sdk-ionic"; -``` - - - - - -### Calls SDK - - - -```javascript -import { CometChatCalls } from "@cometchat/calls-sdk-ionic"; -``` - - - - diff --git a/sdk/ionic-legacy/user-management.mdx b/sdk/ionic-legacy/user-management.mdx deleted file mode 100644 index be03ebbe2..000000000 --- a/sdk/ionic-legacy/user-management.mdx +++ /dev/null @@ -1,205 +0,0 @@ ---- -title: "User Management" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/user-management) which provides full compatibility with Ionic applications. - - -When a user logs into your app, you need to programmatically login the user into CometChat. But before you log in the user to CometChat, you need to create the user. - -Summing up- - -**When a user registers in your app** - -1. You add the user details in your database -2. You create a user in CometChat - -**When a user logs into your app** - -1. You log in the user to your app -2. You [log in the user to CometChat](/sdk/ionic-legacy/authentication) (programmatically) - -## Creating a user - -Ideally, user creation should take place at your backend. You can refer to our Rest API to learn more about [creating a user](https://api-explorer.cometchat.com/reference/creates-user) and use the appropriate code sample based on your backend language. - -However, if you wish to create users on the fly, you can use the `createUser()` method. This method takes a `User` object and the `Auth Key` as input parameters and returns the created `User` object if the request is successful. - - - -```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); - } -); -``` - - - - -```typescript -let authKey: string = "AUTH_KEY"; -var uid: string = "user1"; -var name: string = "Kevin"; - -var user: CometChat.User = new CometChat.User(uid); - -user.setName(name); - -CometChat.createUser(user, authKey).then( - (user: CometChat.User) => { - console.log("user created", user); - }, - (error: CometChat.CometChatException) => { - console.log("error", error); - } -); -``` - - - - - - - -UID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed. - - - -## Updating a user - -Updating a user similar to creating a user should ideally be achieved at your backend using the Restful APIs. For more information, you can check the [update a user](https://api-explorer.cometchat.com/reference/update-user) section. However, this can be achieved on the fly as well as using the `updateUser()` method. This method takes a `User` object and the `Auth Key` as inputs and returns the updated `User` object on the successful execution of the request. - - - -```javascript -let authKey = "AUTH_KEY"; -let uid = "user1"; -let name = "Kevin Fernandez"; - -var user = new CometChat.User(uid); - -user.setName(name); - -CometChat.updateUser(user, authKey).then( - (user) => { - console.log("user updated", user); - }, - (error) => { - console.log("error", error); - } -); -``` - - - - -```typescript -let authKey: string = "AUTH_KEY"; -var uid: string = "user1"; -var name: string = "Kevin Fernandez"; - -var user: CometChat.User = new CometChat.User(uid); - -user.setName(name); - -CometChat.updateUser(user, authKey).then( - (user: CometChat.User) => { - console.log("user updated", user); - }, - (error: CometChat.CometChatException) => { - console.log("error", error); - } -); -``` - - - - - -Please make sure the `User` object provided to the `updateUser()` method has the `UID` of the user to be updated set. - -## Updating logged-in user - -Updating a logged-in user is similar to updating a user. The only difference being this method does not require an AuthKey. This method takes a `User` object as input and returns the updated `User` object on the successful execution of the request. - - - -```javascript -let uid = "user1"; -let name = "Kevin Fernandez"; - -var user = new CometChat.User(uid); - -user.setName(name); - -CometChat.updateCurrentUserDetails(user).then( - (user) => { - console.log("user updated", user); - }, - (error) => { - console.log("error", error); - } -); -``` - - - - -```typescript -var uid: string = "user1"; -var name: string = "Kevin Fernandez"; - -var user: CometChat.User = new CometChat.User(uid); - -user.setName(name); - -CometChat.updateCurrentUserDetails(user).then( - (user: CometChat.User) => { - console.log("user updated", user); - }, - (error: CometChat.CometChatException) => { - console.log("error", error); - } -); -``` - - - - - -By using the `updateCurrentUserDetails()` method one can only update the logged-in user irrespective of the UID passed. Also, it is not possible to update the role of a logged-in user. - -## Deleting a user - -Deleting a user can only be achieved via the Restful APIs. For more information please check the [delete a user](https://api-explorer.cometchat.com/reference/delete-user) section. - -## User Class - -| Field | Editable | Information | -| ------------- | --------------------------------------------------- | -------------------------------------------------------------------- | -| uid | specified on user creation. Not editable after that | Unique identifier of the user | -| name | Yes | Display name of the user | -| avatar | Yes | URL to profile picture of the user | -| link | Yes | URL to profile page | -| role | Yes | User role of the user for role based access control | -| metadata | Yes | Additional information about the user as JSON | -| status | No | Status of the user. Could be either online/offline | -| statusMessage | Yes | Any custom status message that needs to be set for a user | -| lastActiveAt | No | The unix timestamp of the time the user was last active. | -| hasBlockedMe | No | A boolean that determines if the user has blocked the logged in user | -| blockedByMe | No | A boolean that determines if the logged in user has blocked the user | -| tags | Yes | A list of tags to identify specific users | diff --git a/sdk/ionic-legacy/user-presence.mdx b/sdk/ionic-legacy/user-presence.mdx deleted file mode 100644 index 399779170..000000000 --- a/sdk/ionic-legacy/user-presence.mdx +++ /dev/null @@ -1,108 +0,0 @@ ---- -title: "User Presence" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/user-presence) which provides full compatibility with Ionic applications. - - -User Presence helps us understand if a user is available to chat or not. - -## Real-time Presence - -*In other words, as a logged-in user, how do I know if a user is online or offline?* - -Based on the settings provided in the AppSettings class while initializing the SDK using the `init()` method, the logged-in user will receive the presence for the other users in the app. - -In the `AppSettings` class, you can set the type of Presence you wish to receive for that particular session of the app. - -For presence subscription, the AppSettingsBuilder provides 3 methods : - -* `subscribePresenceForAllUsers()` - This will inform the logged-in user when any user in the app comes online or goes offline. -* `subscribePresenceForRoles(Array roles)` - This will inform the logged-in user, only when the users with the specified roles come online or go offline. -* `subscribePresenceForFriends()` - This will inform the logged-in user, only when either of his friends come online or go offline. - -If none of the above methods are used, no presence will be sent to the logged-in user. - -You need to register the `UserListener` using the `addUserListener()` method where ever you wish to receive these events in. - - - -``` -let listenerID = "UNIQUE_LISTENER_ID"; - -CometChat.addUserListener( -listenerID, -new CometChat.UserListener({ - onUserOnline: onlineUser => { - console.log("On User Online:", { onlineUser }); - }, - onUserOffline: offlineUser => { - console.log("On User Offline:", { offlineUser }); - } -}) -); -``` - - - - -```ts -let listenerID: string = "UNIQUE_LISTENER_ID"; - -CometChat.addUserListener( - listenerID, - new CometChat.UserListener({ - onUserOnline: (onlineUser: CometChat.User) => { - console.log("On User Online:", { onlineUser }); - }, - onUserOffline: (offlineUser: CometChat.User) => { - console.log("On User Offline:", { offlineUser }); - } - }) -); -``` - - - - - -| Parameter | Description | -| ------------ | --------------------------------------------- | -| `listenerID` | An ID that uniquely identifies that listener. | - -You will receive an object of the `User` class in the listener methods. - -We recommend you remove the listener once the activity or view is not in use. We suggest adding this method when not in use. - - - -``` -let listenerID = "UNIQUE_LISTENER_ID"; -CometChat.removeUserListener(listenerID); -``` - - - - -```ts -let listenerID: string = "UNIQUE_LISTENER_ID"; -CometChat.removeUserListener(listenerID); -``` - - - - - -## User List Presence - -*In other words, as a logged-in user, when I retrieve the user list, how do I know if a user is online/offline?* - -When you fetch the list of users, in the [User](/sdk/ionic-legacy/user-management#user-class) object, you will receive 2 fields - -1. `status` - This will hold either of the two values : - -* online - This indicates that the user is currently online and available to chat. -* offline - This indicates that the user is currently offline and is not available to chat. - -2. `lastActiveAt` - in case the user is offline, this field holds the timestamp of the time when the user was last online. This can be used to display the Last seen of the user if need be. diff --git a/sdk/ionic-legacy/users-overview.mdx b/sdk/ionic-legacy/users-overview.mdx deleted file mode 100644 index 46e0d1027..000000000 --- a/sdk/ionic-legacy/users-overview.mdx +++ /dev/null @@ -1,12 +0,0 @@ ---- -title: "Users" -sidebarTitle: "Overview" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/users-overview) which provides full compatibility with Ionic applications. - - -The primary aim for our user's functionality is to allow you to quickly retrieve and add users to CometChat. - -You can begin with [user management](/sdk/ionic-legacy/user-management) to sync your users to CometChat. Once that is done, you can [retrieve users](/sdk/ionic-legacy/retrieve-users) and display them in your app. diff --git a/sdk/ionic-legacy/video-view-customisation.mdx b/sdk/ionic-legacy/video-view-customisation.mdx deleted file mode 100644 index b10103853..000000000 --- a/sdk/ionic-legacy/video-view-customisation.mdx +++ /dev/null @@ -1,91 +0,0 @@ ---- -title: "Video View Customisation" ---- - - -**Deprecated:** The Ionic Cordova SDK is deprecated. For new Ionic/Cordova applications, please use the [JavaScript SDK](/sdk/javascript/video-view-customisation) which provides full compatibility with Ionic applications. - - -This section will guide you to customise the main video container. - -## Implementation - -Once you have decided to implement [Direct Calling](/sdk/ionic-legacy/direct-call) and followed the steps to implement them. Just few additional methods will help you quickly customize the main video container. - -Please make sure your callSettings is configured accordingly for [Direct Calling](/sdk/ionic-legacy/direct-call). - -## Main Video Container Setting - -The `MainVideoContainerSetting` Class is the required in case you want to customise the main video view. You need to pass the Object of the `MainVideoContainerSetting` Class in the `setMainVideoContainerSetting()` method of the `CallSettingsBuilder`. - -| Setting | Description | -| ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `setMainVideoAspectRatio(aspectRatio: string)` | This method is used to set the aspect ratio of main video.

**Default Value:** `contain`

**Possible Values:**
1. `CometChatCalls.CallSettings.ASPECT_RATIO_CONTAIN`
2. `CometChatCalls.CallSettings.ASPECT_RATIO_COVER` | -| `setFullScreenButtonParams(position: string, visibility: boolean)` | This method is used to set the position & visibility parameter of the full screen button.

**Default:** Visible in the bottom-right position

**Possible Values for POSITION:**
1. `CometChatCalls.CallSettings.POSITION_TOP_LEFT`
2. `CometChatCalls.CallSettings.POSITION_TOP_RIGHT`
3. `CometChatCalls.CallSettings.POSITION_BOTTOM_LEFT`
4. `CometChatCalls.CallSettings.POSITION_BOTTOM_RIGHT`

**Possible Values for VISIBILITY:**
1. `true`
2. `false` | -| `setNameLabelParams(position: string, visibility: boolean, backgroundColor: string)` | This method is used to set the position, visibility & background color of the name label.

**Default:** Visible in the bottom-left position with background-color `#333333`

**Possible Values for POSITION:**
1. `CometChatCalls.CallSettings.POSITION_TOP_LEFT`
2. `CometChatCalls.CallSettings.POSITION_TOP_RIGHT`
3. `CometChatCalls.CallSettings.POSITION_BOTTOM_LEFT`
4. `CometChatCalls.CallSettings.POSITION_BOTTOM_RIGHT`

**Possible Values for VISIBILITY:**
1. `true`
2. `false` | -| `setZoomButtonParams(position: string, visibility: boolean)` | This method is used to set the position, visibility of the zoom button.

**Default:** Visible in the bottom-right position

**Possible Values for POSITION:**
1. `CometChatCalls.CallSettings.POSITION_TOP_LEFT`
2. `CometChatCalls.CallSettings.POSITION_TOP_RIGHT`
3. `CometChatCalls.CallSettings.POSITION_BOTTOM_LEFT`
4. `CometChatCalls.CallSettings.POSITION_BOTTOM_RIGHT`

**Possible Values for VISIBILITY:**
1. `true`
2. `false` | -| `setUserListButtonParams(position: string, visibility: boolean)` | This method is used to set the position, visibility of the user list button.

**Default:** Visible in the bottom-right position

**Possible Values for POSITION:**
1. `CometChatCalls.CallSettings.POSITION_TOP_LEFT`
2. `CometChatCalls.CallSettings.POSITION_TOP_RIGHT`
3. `CometChatCalls.CallSettings.POSITION_BOTTOM_LEFT`
4. `CometChatCalls.CallSettings.POSITION_BOTTOM_RIGHT`

**Possible Values for VISIBILITY:**
1. `true`
2. `false` | - -Example: - - - -```javascript -import { CometChatCalls } from '@cometchat/calls-sdk-ionic'; - -let videoSettings = new CometChatCalls.MainVideoContainerSetting(); - -videoSettings.setMainVideoAspectRatio(CometChatCalls.CallSettings.ASPECT_RATIO_CONTAIN); -videoSettings.setFullScreenButtonParams(CometChatCalls.CallSettings.POSITION_BOTTOM_RIGHT, true); -videoSettings.setNameLabelParams(CometChatCalls.CallSettings.POSITION_BOTTOM_LEFT, true, "#333333"); -videoSettings.setZoomButtonParams(CometChatCalls.CallSettings.POSITION_BOTTOM_RIGHT, true); -videoSettings.setUserListButtonParams(CometChatCalls.CallSettings.POSITION_BOTTOM_RIGHT, true); -``` - - - - -```typescript -import { CometChatCalls } from '@cometchat/calls-sdk-ionic'; -import { MainVideoContainerSetting } from '@cometchat/calls-sdk-ionic/dist/models/CallSettings'; - -let videoSettings: MainVideoContainerSetting = new CometChatCalls.MainVideoContainerSetting(); - -videoSettings.setMainVideoAspectRatio(CometChatCalls.CallSettings.ASPECT_RATIO_CONTAIN); -videoSettings.setFullScreenButtonParams(CometChatCalls.CallSettings.POSITION_BOTTOM_RIGHT, true); -videoSettings.setNameLabelParams(CometChatCalls.CallSettings.POSITION_BOTTOM_LEFT, true, "#333333"); -videoSettings.setZoomButtonParams(CometChatCalls.CallSettings.POSITION_BOTTOM_RIGHT, true); -videoSettings.setUserListButtonParams(CometChatCalls.CallSettings.POSITION_BOTTOM_RIGHT, true); -``` - - - - - -Once you have the `MainVideoContainerSetting` object, pass it to `CallSettingsBuilder` via the `setMainVideoContainerSetting` method as shown below, - - - -```javascript -import { CometChatCalls } from '@cometchat/calls-sdk-ionic'; - -const callSettings = new CometChatCalls.CallSettingsBuilder() - .setMainVideoContainerSetting(videoSettings) - .build(); -``` - - - - -```typescript -import { CometChatCalls } from '@cometchat/calls-sdk-ionic'; -import { CallSettings } from '@cometchat/calls-sdk-ionic/dist/models/CallSettings'; - -const callSettings: CallSettings = new CometChatCalls.CallSettingsBuilder() - .setMainVideoContainerSetting(videoSettings) - .build(); -``` - - - - diff --git a/sdk/ionic-legacy/webhooks-overview.mdx b/sdk/ionic-legacy/webhooks-overview.mdx deleted file mode 100644 index 598d43500..000000000 --- a/sdk/ionic-legacy/webhooks-overview.mdx +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: "Webhooks" -url: "/fundamentals/webhooks-overview" ---- \ No newline at end of file diff --git a/snippets/widget/legacy/overview.mdx b/snippets/widget/legacy/overview.mdx deleted file mode 100644 index 7bd5b99b8..000000000 --- a/snippets/widget/legacy/overview.mdx +++ /dev/null @@ -1,25 +0,0 @@ -The Widget simplifies the process of integrating a chat functionality on your website. As a developer, you only need to toggle the widget's settings from our Dashboard and customize it to fit your needs. Within a few minutes, you can get started with our widget. - -The Chat Widget is available for the following platforms: - -1. HTML / Bootstrap / jQuery -2. WordPress - -## Prerequisite - -1. [Login](https://app.cometchat.com/login) to CometChat Dashboard and select your app. -2. Click on the **Chats tab**, then select **Widgets** from the left navigation pane. - - - - - -3. You can create new widgets as well as see a list of existing ones here. - -## Features of Widget - -| Features | Description | -| --------- | ----------------------------------------------------------------------------------------------- | -| Install | This provides the required details about a widget so that it can be integrated in your website. | -| Customize | Change the widget's name, docked layout icons and colors, custom JS and CSS. | -| Settings | Configure what shows up in the sidebar as well as in the chat component. | diff --git a/widget/html/legacy.mdx b/widget/html/legacy.mdx deleted file mode 100644 index 513b26aaa..000000000 --- a/widget/html/legacy.mdx +++ /dev/null @@ -1,902 +0,0 @@ ---- -title: "HTML Widget (Legacy)" -sidebarTitle: "HTML Widget (Legacy)" ---- - -import ChatWidgetLegacyOverview from '/snippets/widget/legacy/overview.mdx'; - -## Overview - - - - -The Chat Widget is not customizable beyond the configuration options available in the Widget Builder in dashboard. If you require deeper customization, consider using our [UI Kits](/ui-kit/react/overview) instead. - - -*** - -## HTML / Bootstrap / JQuery - -### Before getting started - -Go through the [overview](#overview) to set up Chat Widget from the CometChat Dashboard. - -Once you’ve created a widget, as shown in the image below. - - - - - -You have an option of loading the Chat Widget in: - -1. Embedded Layout -2. Docked Layout - - -**Security Best Practices** - -- The **Auth Key** method is recommended for **proof-of-concept (POC) development** and early-stage testing. -- For **production environments**, use an **Auth Token** instead of an **Auth Key** to enhance security and prevent unauthorized access. See the [Security Measures using Auth Token](#security-measures-using-auth-token) section below for details. - - -### Embedded Layout - - - - - -You may simply copy-paste the code below to run the Chat Widget in Embedded Layout. - - - -Replace APP_ID, APP_REGION, AUTH_KEY, WIDGET_ID with your CometChat App ID, Region, Auth Key, and Widget ID in the below code. - -Replace `UID` with the ID of the user you want to login with. - - - - - -```html - - - - - - - -
- - - - -``` - -
- - -```javascript -// Embedded Layout - JavaScript initialization -CometChatWidget.init({ - "appID": "YOUR_APP_ID", - "appRegion": "YOUR_APP_REGION", - "authKey": "YOUR_AUTH_KEY" -}).then(response => { - console.log("Initialization completed successfully"); - CometChatWidget.login({ - "uid": "YOUR_UID" - }).then(response => { - CometChatWidget.launch({ - "widgetID": "YOUR_WIDGET_ID", - "target": "#cometchat", - "roundedCorners": "true", - "height": "600px", - "width": "800px", - "defaultID": "cometchat-uid-1", //default UID (user) or GUID (group) to show - "defaultType": "user" //user or group - }); - }, error => { - console.log("User login failed with error:", error); - }); -}, error => { - console.log("Initialization failed with error:", error); -}); -``` - - - -
- -To launch an Embedded Widget, pass a configuration object to `launch` method with the following keys: - -| Parameter | Description | -| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | -| widgetID | ID of the widget can be accessed from the CometChat dashboard | -| target | ID of the div tag where CometChat Widget will appear | -| roundedCorners | Boolean value that enables/disables rounded corners. | -| height | Height of the widget | -| width | Width of the widget | -| defaultID | To show a default logged in user or group in your chat a.Use UID of a user for one-on-one conversations b.Use GUID for group conversations | -| defaultType | Either `user` or `group` depending upon the defaultID | - -### Docked Layout - - - - - -You may simply copy-paste the code below to run the Chat Widget in Docked Layout. - - - -Replace `APP_ID`, `APP_REGION`, `AUTH_KEY`, `WIDGET_ID` with your CometChat App ID, Region, Auth Key, and Widget ID in the below code. - -Replace `UID` with the ID of the user you want to login with. - - - - - -```html - - - - - - - - - - - -``` - - - - -```javascript -// Docked Layout - JavaScript initialization -CometChatWidget.init({ - "appID": "YOUR_APP_ID", - "appRegion": "YOUR_APP_REGION", - "authKey": "YOUR_AUTH_KEY" -}).then(response => { - console.log("Initialization completed successfully"); - CometChatWidget.login({ - "uid": "YOUR_UID" - }).then(response => { - CometChatWidget.launch({ - "widgetID": "YOUR_WIDGET_ID", - "docked": "true", - "alignment": "left", //left or right - "roundedCorners": "true", - "height": "450px", - "width": "400px", - "defaultID": "cometchat-uid-1", //default UID (user) or GUID (group) to show - "defaultType": "user" //user or group - }); - }, error => { - console.log("User login failed with error:", error); - }); -}, error => { - console.log("Initialization failed with error:", error); -}); -``` - - - - - - - -Please note that the above execution is taking place on `DomContentLoaded` event fired by the window object. You can break down these steps on different events of your choice to have a more controlled flow of initializing and launching the Chat Widget. - - - -To launch a Docked widget, pass a configuration object to the launch method with the following keys: - -| Parameter | Description | -| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | -| widgetID | ID of the widget can be accessed from the CometChat dashboard | -| docked | Boolean value to show the enable the docked view | -| alignment | Can be set to `left` or `right` | -| roundedCorners | Boolean value that enables/disables rounded corners | -| height | Height of the widget | -| width | Width of the widget | -| defaultID | To show a default logged in user or group in your chat a.Use UID of a user for one - one conversations b.Use GUID for group conversations | -| defaultType | Either user or group depending upon the defaultID | - -As mentioned earlier, this launch method can be called multiple times. By modifying the keys in the above configuration object. - - - -Make sure you specify a different and unique `target` if you intend to launch another instance of Chat Widget. - - - -### Advanced Features - -#### Open or close chat window - -Chat window of docked layout can be opened/closed using the below method. This method can be triggered on the click event of any element of your webpage. - - - -```javascript -CometChatWidget.openOrCloseChat(FLAG); //true or false -``` - - - - - -It takes the following parameters: - -| Parameter | Description | Type | -| --------- | ----------------------------------------------------------------------------------------------------- | -------- | -| FLAG | Value could be _true_ or _false_ _true_ will open the chat window _false_ will close the chat window. | Required | - -#### Chat with a particular user - -This method will open a particular user chat window. This method can be triggered by the click event of any element of your webpage. - - - -```javascript -CometChatWidget.chatWithUser(UID); -``` - - - - - -It takes the following parameters: - -| Parameter | Description | Type | -| --------- | ---------------------------------------- | -------- | -| UID | The ID of the user you want to chat with | Required | - -#### Chat with a particular group - -This method will open a particular group chat window. This method can be triggered by the click event of any element of your webpage. - - - -```javascript -CometChatWidget.chatWithGroup(GUID); -``` - - - - - -It takes the following parameters: - -| Parameter | | Description | Type | -| --------- | - | ---------------------------------------------------- | -------- | -| GUID | | The ID of the group you want to initiate a call with | Required | - -#### Initiate calls with a particular user - -This method will initiate a call with the user. This method can be triggered by the click event of any element of your web page. - - - -```javascript -CometChatWidget.callUser(UID); -``` - - - - - -It takes the following parameters: - -| Parameter | Description | Type | -| --------- | ---------------------------------------------------- | -------- | -| UID | The ID of the user you want to initiate a call with. | Required | - -#### Initiate calls with a particular group - -This method will initiate a call with the group. This method can be triggered by the click event of any element of your web page. - - - -```javascript -CometChatWidget.callGroup(GUID); -``` - - - - - -It takes the following parameters: - -| Parameter | | Description | Type | -| --------- | --- | ---------------------------------------------------- | -------- | -| GUID | | The ID of the group you want to initiate a call with | Required | - -#### Message Listener - -We have provided a callback that is fired every time a message is received. You can use this to show Custom Notifications on your website or perform some other custom action as per your requirement. - - - -```javascript -CometChatWidget.launch({ -// Embedded or Docked layout configuration -}).then(response => { - -// OPTIONAL: This is called in the success callback of launch method -CometChatWidget.on("onMessageReceived", (message) => { -console.log("CometChatWidget onMessageReceived", message); -}); -}); - -```` - - - - - -#### Chat open state listener - -We have provided a callback that is fired every time the docked layout of the chat widget is in an open state. You can use this to perform some custom action as per your requirement. - - - -```javascript -CometChatWidget.launch({ -// Embedded or Docked layout configuration -}).then(response => { - -// OPTIONAL: This is called in the success callback of launch method -CometChatWidget.on("openChat", (args) => { - console.log("CometChatWidget Chat is open", args); -}); -}); -```` - - - - - -#### Chat closed state listener - -We have provided a callback that is fired every time the docked layout of the chat widget is in a closed state. You can use this to perform some custom action as per your requirement. - - - -```javascript -CometChatWidget.launch({ -// Embedded or Docked layout configuration -}).then(response => { - -// OPTIONAL: This is called in the success callback of launch method -CometChatWidget.on("closeChat", (args) => { -console.log("CometChatWidget Chat is closed", args); -}); -}); - -```` - - - - - -#### Click listener - -We have provided a callback that is fired every time a user or group is clicked on the sidebar. You can use this to perform some custom action as per your requirement. - - - -```javascript -CometChatWidget.launch({ -// Embedded or Docked layout configuration -}).then(response => { - -// OPTIONAL: This is called in the success callback of launch method -CometChatWidget.on("onItemClick", (args) => { - console.log("CometChatWidget user/group is clicked", args); -}); -}); -```` - - - - - -#### Localization - -With language localization, our Chat Widget adapts to the language of a specific country or region. Chat Widget allows you to detect the language of your users based on their browser settings and set the language of the widget accordingly. Currently, we support the following 12 languages for localization: - -- English (en, en-US, en-GB) -- Chinese (zh, zh-TW) -- Spanish (es) -- Hindi (hi) -- Russian (ru) -- Arabic (ar) -- Portuguese (pt) -- Malay (ms) -- French (fr) -- German (de) -- Swedish (sv) -- Lithuanian (lt) -- Hungarian (hu) - - - -```javascript -CometChatWidget.localize(LANGUAGE_CODE); -``` - - - - - -It takes the following parameters: - -| Parameter | Description | Type | -| -------------- | ------------------------------------------------- | -------- | -| LANGUAGE_CODE | The language code the texts to be translated into | Required | - -#### User/Group Management - -##### Create a user on-the-fly - -This saves you the hassle of creating users beforehand from the CometChat Pro Dashboard. In order to create a user on-the-fly, you can call the `createOrUpdateUser()` method on the CometChatWidget class. - -It might happen that the user already exists. In that case, this method updates the user details. It can be used to change the user's name on-the-fly. - -The method is as follows: - - - -```javascript -CometChatWidget.init({ -appID: 'YOUR_APP_ID', -appRegion: 'YOUR_APP_REGION', -authKey: 'YOUR_AUTH_KEY', -}).then((response) => { - -/\*\* - -- Create user once initialization is successful - \*/ - const user = new CometChatWidget.CometChat.User(UID); - user.setName(NAME); - user.setAvatar(AVATAR_URL); - user.setLink(PROFILE_LINK); - CometChatWidget.createOrUpdateUser(user).then((user) => { - -// Proceed with user login -CometChatWidget.login({ -uid: UID, -}).then((loggedInUser) => { - - // Proceed with launching your Chat Widget - CometChatWidget.launch({ - // Embedded or docked layout configuration - }) - -}); -}); -}); - -```` - - - - - -It takes a configuration object with the following keys: - -| Parameter | Description | Type | -| ------------- | ------------------------------------------- | -------- | -| UID | The ID of the user to be created and log in | Required | -| NAME | The username associated with the user | Required | -| AVATAR_URL | URL to profile picture of the user | Optional | -| PROFILE_LINK | URL to profile page | Optional | - -##### Create a group on-the-fly - -This saves you the hassle of creating groups beforehand from the CometChat Pro Dashboard. In order to create a group on-the-fly, you can call the `createOrUpdateGroup()` method on the CometChatWidget class. - -It might happen that the group already exists. In that case, this method updates the group details. It can be used to change the group's name and type on the fly. - - - -```javascript -CometChatWidget.init({ -appID: 'YOUR_APP_ID', -appRegion: 'YOUR_APP_REGION', -authKey: 'YOUR_AUTH_KEY', -}).then((response) => { -CometChatWidget.login({ - uid: "YOUR_UID", -}).then((loggedInUser) => { - /** - * Create group once your user has logged in. - */ - const group = new CometChatWidget.CometChat.Group(GUID, GROUP_NAME, GROUP_TYPE, PASSWORD); - group.setIcon(ICON_URL); - CometChatWidget.createOrUpdateGroup(group).then(group => { - // Proceed with launch - CometChatWidget.launch({ - // Embedded or docked layout configuration - }) - }); -}); -}); -```` - - - - - -It takes a configuration object with the following keys: - -| Parameter | Description | Type | -| ----------- | ----------------------------------------------------------------------------------------------------- | -------- | -| GUID | The group will be created with the mentioned ID | Required | -| GROUP_NAME | The name associated with the group being created | Required | -| GROUP_TYPE | The type of group that you want to create. Type of the group can be: 1. Public 2. Password 3. Private | Required | -| PASSWORD | The group password when groupType is set to 'Password' | Required | -| ICON_URL | An URL to group icon | Optional | - -#### User Logout - -When your user logs out from the website, you can also log out the user from Chat Widget by calling the `logout()` method of the `CometChatWidget` class. - - - -```javascript -CometChatWidget.logout().then(response => { - // User successfully logged out. -// Perform any clean up if required. -}); -``` - - - - - -#### Security Measures using Auth Token - -If you wish to manage the Auth Key and generate Auth Token from your server application. We recommended you follow the below steps. - -Please open this document - [https://api-explorer.cometchat.com/reference/chat-apis](https://api-explorer.cometchat.com/reference/chat-apis) and refer to this Post API call ([https://api-explorer.cometchat.com/reference/create-authtoken](https://api-explorer.cometchat.com/reference/create-authtoken)) to create users and generate Auth token - -You may then use the generated **Auth Token** and pass it to the login method below to log in to the user - -The below code can be copy-pasted to launch your chat widget using Auth Token - - - -Replace APP_ID, APP_REGION, AUTH_TOKEN, WIDGET_ID with your CometChat App ID, Region, Auth Token, and Widget ID in the below code. - -Replace `UID` with the ID of the user you want to login with. - - - - - -```html - - - - - -
- - - -``` - -
- - -```html - - - - - - - -
- - - - -``` - -
- -
- -To launch an embedded/docked widget, pass a configuration object to the launch method with the following keys: - -| Parameter | Description | -| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | -| widgetID | ID of the widget can be accessed from the CometChat dashboard | -| target | For embedded layout, pass the ID of the div tag where CometChat Widget will appear ID of the div tag where CometChat Widget will appear | -| docked | For docked layout, use the docked parameter as a boolean value to show the enable the docked view | -| roundedCorners | Boolean value that enables/disables rounded corners. | -| height | Height of the widget | -| width | Width of the widget | -| defaultID | To show a default logged in user or group in your chat a.Use UID of a user for one - one conversations b.Use GUID for group conversations | -| defaultType | Either user or group depending upon the defaultID | - -*** - -## Custom Build - -Deploy a custom build of the chat widget on your own server. - -### Installation steps - -1. Clone the repository - -```bash -git clone https://github.com/cometchat-pro/web-chat-widget-custom -``` - -2. Navigate to the project directory and set your CDN URL in `CONSTS.js` - -```bash -cd CometChatWorkspace -``` - -```javascript -// EG: If URL is set as https://your_domain.com/widget -// cometchatwidget.js will be available at https://your_domain.com/widget/cometchatwidget.js -module.exports = { - URL: "https://your_domain.com/widget", -} -``` - -3. Install dependencies - -```bash -npm install -``` - -4. Build the custom widget - -```bash -npm run build:custom -``` - -5. Copy the contents of the `build` directory to your website’s source. - -### Usage - -Update the widget CDN link in your installation code. It should match the URL you configured in `CONSTS.js`. - - - -```html - - - - - - - -
- - - - -``` - -
- - -```html - - - - - - - - - - - -``` - - - -
diff --git a/widget/wordpress/legacy.mdx b/widget/wordpress/legacy.mdx deleted file mode 100644 index a3667efcd..000000000 --- a/widget/wordpress/legacy.mdx +++ /dev/null @@ -1,245 +0,0 @@ ---- -title: "WordPress Widget (Legacy)" -sidebarTitle: "WordPress Widget (Legacy)" ---- - -import ChatWidgetLegacyOverview from '/snippets/widget/legacy/overview.mdx'; - -## Overview - - - -*** - -## WordPress / BuddyPress - -### Before getting started - -Go through the [overview](#overview) to set up Chat Widget from the CometChat Dashboard. - -### Installation - -1. [Download the CometChat Pro](https://kernl.us/api/v1/archive/688bbf1f5a0dc110ce1bfafe) plugin. -2. In WordPress Admin, go to **Plugins → Add New**. - - - - - -3. Click **Upload Plugin**, choose the zip, then click **Install Now**. - - - - - -4. After upload completes, click **Activate Plugin**. - - - - - -### Configuration - -1. Get **App ID**, **Region**, **REST API Key**, and **Auth Key** from **CometChat Dashboard → Chats → Widget**. - - - - - -2. In WordPress go to **Settings → CometChat Pro**, then set: - -* `App ID` -* `Region` -* `REST API Key` -* `Auth Key` - - - - - -3. Click **Update Settings**. The logged-in WordPress user will be registered in CometChat. -4. Choose layout: - * Embedded Layout - * Docked Layout - -### Embedded Layout - - - - - -Use the shortcode to load the Chat Widget in embedded layout. Configure keys as needed. - - - -Replace `WIDGET_ID` with your Widget ID. - - - - - -``` -[cometchat-pro widget-id='WIDGET_ID' widget-height='600px' widget-width='600px' widget-version='v3'] -``` - - - - - -Configurable keys: - -| Keys | Description | -| -------------- | ----------------------------------------------------------------- | -| widget-id | ID of the widget from the CometChat dashboard | -| widget-width | Width of the widget | -| widget-height | Height of the widget | -| widget-version | Version of the Chat Widget | - -Optional parameters: - -| Keys (optional) | Description | -| ---------------- | ---------------------------------------------------------------------------------------------------------------------------- | -| default-username | Default user to start a conversation with | -| default-id | UID (user) or GUID (group) to show by default | -| default-type | `user` or `group` depending on default-id | -| rounded-corners | Boolean to enable/disable rounded corners | - -### Docked Layout - - - - - -Use the shortcode to load the Chat Widget in docked layout. - - - -Replace `WIDGET_ID` with your Widget ID. - - - - - -``` -[cometchat-pro widget-id='WIDGET_ID' widget-height='600px' widget-width='600px' widget-version='v3' widget-docked='true' widget-docked-position='right' rounded-corners='true'] -``` - - - - - -Configurable keys: - -| Keys | Description | -| ---------------------- | ----------------------------------------------------------------- | -| widget-id | ID of the widget from the CometChat dashboard | -| widget-width | Width of the widget | -| widget-height | Height of the widget | -| widget-version | Version of the Chat Widget | -| widget-docked | Boolean to show/hide docked layout | -| widget-docked-position | `left` or `right` alignment | - -Optional parameters are the same as embedded layout (default-username, default-id, default-type, rounded-corners). - -### Show docked layout on all pages - -1. Go to **Settings → CometChat Pro** in WordPress. -2. Paste the docked shortcode under **Load CometChat Pro on all pages/sitewide?** to show it everywhere. - -*** - -## Advanced Features - -### Open or close chat window - -```javascript -CometChatWidget.openOrCloseChat(FLAG); // true or false -``` - -| Parameter | Description | Type | -| --------- | ------------------------------------------------------------------------------------- | -------- | -| FLAG | `true` opens the chat window, `false` closes it. | Required | - -### Chat with a particular user - -```javascript -CometChatWidget.chatWithUser(UID); -``` - -| Parameter | Description | Type | -| --------- | ---------------------------------------- | -------- | -| UID | ID of the user to chat with | Required | - -### Chat with a particular group - -```javascript -CometChatWidget.chatWithGroup(GUID); -``` - -| Parameter | Description | Type | -| --------- | ----------------------------------------- | -------- | -| GUID | ID of the group to chat with | Required | - -### Initiate calls with a particular user - -```javascript -CometChatWidget.callUser(UID); -``` - -| Parameter | Description | Type | -| --------- | ---------------------------------------------------- | -------- | -| UID | ID of the user to initiate a call with | Required | - -### Initiate calls with a particular group - -```javascript -CometChatWidget.callGroup(GUID); -``` - -| Parameter | Description | Type | -| --------- | ---------------------------------------------------- | -------- | -| GUID | ID of the group to initiate a call with | Required | - -### Message Listener - -```javascript -CometChatWidget.on("onMessageReceived", (args) => { - console.log("CometChatWidget onMessageReceived", args); -}); -``` - -### Chat open state listener - -```javascript -CometChatWidget.launch({ - // Embedded or Docked layout configuration -}).then(() => { - CometChatWidget.on("openChat", (args) => { - console.log("CometChatWidget Chat is open", args); - }); -}); -``` - -### Chat closed state listener - -```javascript -CometChatWidget.launch({ - // Embedded or Docked layout configuration -}).then(() => { - CometChatWidget.on("closeChat", (args) => { - console.log("CometChatWidget Chat is closed", args); - }); -}); -``` - -### Localization - -```javascript -CometChatWidget.localize(LANGUAGE_CODE); -``` - -Supported languages include: en, zh, es, hi, ru, ar, pt, ms, fr, de, sv, lt, hu. - -| Parameter | Description | Type | -| -------------- | ------------------------------------------------- | -------- | -| LANGUAGE_CODE | Language code to localize widget text | Required |