About Query Channel

Hello I used your API services and want to get the channel with last active how can make it ?

I will give you my scenario that I have chat in my app and want if the some one send message to me the channel of this one to be the first channel I retrieve and the first one to be second and so on ?

@hossam For the use case you described, we recommend using our SDK. Typically, when you query channels with our API, they are sorted by ‘last active’ by default. Based on your use case, you will need to use real-time events, which our SDK supports as documented here: Amity SDK - Realtime Events.

Can I use the SDK for chat only ?

I have every thing as API with you so can I use the SDK for the chat only ?

Hello I want to use Chat SDK and I used every thing using your API and the authentication using API , every thing using API and I want to use only the Chat SDK to get the ChatRealTime so how can make it please

Hello @hossam ,

To integrate ChatRealTime using our Chat SDK alongside your existing API for authentication, please follow these steps:

  1. Install the Chat SDK: Refer to our Installation and Authentication Guide for detailed instructions on setting up the SDK.
  2. Set Up Authentication: Ensure your authentication setup aligns with our API as detailed in the guide.
  3. Implement ChatRealTime: For instructions on using real-time chat features, visit our Chat SDK Documentation.

So Thank you for help , please can you provide me the steps after this

import { API_REGIONS, Client, enableCache } from '@amityco/ts-sdk';

const apiKey = 'b0e9ec5d3eddf5641f328d4a555b168ed20c8bb0bf356b7a';

const client = Client.createClient(apiKey, API_REGIONS.EU);

enableCache();

And when log the response in the SDK It return

{"accessTokenExpiryWatcher": [Function accessTokenExpiryWatcher], "apiKey": "b0e9ec5d3eddf5641f328d4a555b168ed20c8bb0bf356b7a", "cache": {"data": {}}, "emitter": {"all": Map {}, "emit": [Function emit], "off": [Function off], "on": [Function on]}, "getFeedSettings": [Function getFeedSettings], "getMarkerSyncConsistentMode": [Function getMarkerSyncConsistentMode], "getMessagePreviewSetting": [Function getMessagePreviewSetting], "getSocialSettings": [Function getSocialSettings], "hasPermission": [Function hasPermission$1], "http": [Function wrap], "isUnreadCountEnabled": false, "log": [Function print], "mqtt": {"connect": [Function connect], "connected": false, "disconnect": [Function disconnect], "off": [Function off], "on": [Function on], "once": [Function once], "removeAllListeners": [Function removeAllListeners], "subscribe": [Function subscribe], "unsubscribe": [Function unsubscribe]}, "sessionHandler": undefined, "sessionState": "notLoggedIn", "use": [Function use], "validateTexts": [Function validateTexts], "validateUrls": [Function validateUrls], "version": "v6.22.0-cjs", "ws": {"_callbacks": {"$connect": [Array], "$connecting": [Array], "$disconnect": [Array]}, "acks": {}, "connected": false, "disconnected": true, "flags": {}, "ids": 0, "io": {"_randomizationFactor": 0.5, "_reconnection": true, "_reconnectionAttempts": Infinity, "_reconnectionDelay": 2000, "_reconnectionDelayMax": 5000, "_timeout": 20000, "autoConnect": false, "backoff": [Backoff], "connecting": [Array], "decoder": [Decoder], "encoder": [Encoder], "encoding": false, "lastPing": null, "nsps": [Object], "opts": [Object], "packetBuffer": [Array], "readyState": "closed", "subs": [Array], "uri": "https://api.sg.amity.co"}, "json": [Circular], "nsp": "/", "receiveBuffer": [], "sendBuffer": []}}

But I want to connect with EU and I put this already so why?
and how can connect with API to make login ?

@amitysupport

@hossam Regarding the issue you encountered, please check this link for more information: Create User - Amity SDK Core Concepts.

I think you don’t answer my question I told you when I trying to connect to the SDK I got that

{"accessTokenExpiryWatcher": [Function accessTokenExpiryWatcher], "apiKey": "b0e9ec5d3eddf5641f328d4a555b168ed20c8bb0bf356b7a", "cache": {"data": {}}, "emitter": {"all": Map {}, "emit": [Function emit], "off": [Function off], "on": [Function on]}, "getFeedSettings": [Function getFeedSettings], "getMarkerSyncConsistentMode": [Function getMarkerSyncConsistentMode], "getMessagePreviewSetting": [Function getMessagePreviewSetting], "getSocialSettings": [Function getSocialSettings], "hasPermission": [Function hasPermission$1], "http": [Function wrap], "isUnreadCountEnabled": false, "log": [Function print], "mqtt": {"connect": [Function connect], "connected": false, "disconnect": [Function disconnect], "off": [Function off], "on": [Function on], "once": [Function once], "removeAllListeners": [Function removeAllListeners], "subscribe": [Function subscribe], "unsubscribe": [Function unsubscribe]}, "sessionHandler": undefined, "sessionState": "notLoggedIn", "use": [Function use], "validateTexts": [Function validateTexts], "validateUrls": [Function validateUrls], "version": "v6.22.0-cjs", "ws": {"_callbacks": {"$connect": [Array], "$connecting": [Array], "$disconnect": [Array]}, "acks": {}, "connected": false, "disconnected": true, "flags": {}, "ids": 0, "io": {"_randomizationFactor": 0.5, "_reconnection": true, "_reconnectionAttempts": Infinity, "_reconnectionDelay": 2000, "_reconnectionDelayMax": 5000, "_timeout": 20000, "autoConnect": false, "backoff": [Backoff], "connecting": [Array], "decoder": [Decoder], "encoder": [Encoder], "encoding": false, "lastPing": null, "nsps": [Object], "opts": [Object], "packetBuffer": [Array], "readyState": "closed", "subs": [Array], "uri": "https://api.sg.amity.co"}, "json": [Circular], "nsp": "/", "receiveBuffer": [], "sendBuffer": []}}

And I used region EU but still get this error

Hi hossam, Can you try login with this code? The login will be completely after you call Client.login and pass userId and displayName to the function

 const client: Amity.Client = Client.createClient(apiKey, 'eu', {
    apiEndpoint: { http: 'https://api.eu.amity.co' },
  });

  const handleConnect = async (userId: string, displayName: string) => {


    const response = await Client.login(
      {
        userId: userId,
        displayName: displayName
      },
      sessionHandler,
    );
    console.log('response:', response)
  };
  

  const sessionHandler: Amity.SessionHandler = {
    sessionWillRenewAccessToken(renewal: Amity.AccessTokenRenewal) {
      // for details on other renewal methods check session handler
      renewal.renew();
    },
  };