Klat
  • TalkPlus SDK
  • Android
    • Getting Started
    • Callback
    • User
      • Create User / Login
      • Update User Information
      • Block / Unblock
      • Logout
      • Delete User
    • Channel
      • Create / Delete Channel
      • View Channel
      • Updating Channel
      • Viewing Channel LIst
      • Manage Channel Members
      • Join / Leave Channel
      • Messaging
      • Hide / Show Channel
      • Freeze / Unfreeze Channel
      • Transfer Channel Ownership
      • Channel Push Notification Settings
      • Channel Member Data
    • Push Notification
    • Sample Application
    • What's New
  • iOS
    • Getting Started
    • Callback
    • User
      • Create / Login
      • Update User Information
      • Block / Unblock
      • Logout
      • Delete User
    • Channel
      • Create / Delete Channel
      • View Channel
      • Updating Channel
      • View Channel List
      • Manage Channel Members
      • Join / Leave Channel
      • Messaging
      • Hide / Show Channel
      • Freeze / Unfreeze Channel
      • Transfer Channel Ownership
      • Channel Push Notification Settings
      • Channel Member Data
    • Push Notification
    • Sample Application
    • What's New
  • Unity
    • Getting Started
    • Callback
    • User
      • Create User / Login
      • Update User Information
      • Block / Unblock
      • Logout
      • Delete User
    • Channel
      • Create / Delete Channel
      • View Channel
      • Updating Channel
      • View Channel List
      • Manage Channel Members
      • Join / Leave Channel
      • Messaging
      • Hide / Show Channel
      • Freeze / Unfreeze Channel
      • Transfer Channel Ownership
      • Channel Push Notification Settings
      • Channel Member Data
    • Push Notification
    • Sample Application
  • JavaScript
    • Getting Started
    • Realtime Event
    • Pagination
    • User
      • Create User / Login
      • Update User Information
      • Block / Unblock
      • Logout
      • Delete
    • Channel
      • Create / Delete Channel
      • View Channel
      • Updating Channel
      • View Channel List
      • Manage Channel Members
      • Join / Leave Channel
      • Messaging
      • Hide / Show Channel
      • Freeze / Unfreeze Channel
      • Transfer Channel Ownership
      • Channel Push Notification Settings
      • Channel Member Data
    • Push Notification (FCM)
    • Sample Application
    • What's New
  • Flutter
    • Getting Started
    • Callback
    • User
      • Create User / Login
      • Update User Information
      • Block / Unblock
      • Logout
      • Delete User
    • Channel
      • Create Channel
      • View Channel
      • Updating Channel
      • View Channel List
      • Manage Channel Members
      • Join / Leave Channel
      • Messaging
      • Hide / Show Channel
      • Freeze / Unfreeze Channel
      • Transfer Channel Ownership
      • Channel Push Notification Settings
      • Channel Member Data
    • Push Notification (FCM)
  • REST API
    • Getting Started
    • API
      • Users
        • Create User
        • Login (using login token)
        • View User
        • Update User
        • Activate / Deactivate
        • Enable / Disable Push Notification
        • Delete User
        • View Users
        • View Channels
        • Block / Unblock
      • Channel
        • Create Channel
        • View Channel
        • Update Channel
        • Delete Channel
        • View Channel List
        • Manage Channel Members
        • Messaging
        • Hide / Show Channel
        • Channel Freeze / Unfreeze
        • Transfer Channel Ownership
        • Channel Push Notification Settings
      • Bot
        • Create Bot
        • View Bot List
        • View Bot
        • Update Bot
        • Delete Bot
        • View Joined Channel List
        • Messaging
        • Join / Leave Channel
    • Push Notification
    • Rate Limit
  • MISC
    • Webhooks
    • SDK Rate Limit
    • Error Code
    • FAQ
      • Function
      • Spec
Powered by GitBook
On this page
  • 0. Minimum Requirements
  • 1a. NPM
  • 1b. CDN
  • 1c. Download
  • 2. Initializing
  • 3. Promise, Async/Await and Callback
  • 4. Login / Logout Process
  • 5. Error
  1. JavaScript

Getting Started

PreviousSample ApplicationNextRealtime Event

Last updated 5 months ago

0. Minimum Requirements

  • IE11

  • Edge 12

  • Firefox 29

  • Chrome 33

  • Safari 7.1


For handling FCM Push Notification in an SPA (such as Vue.js or React) or React Native, see .

1a. NPM

npm install talkplus-sdk

1b. CDN

<script src="https://asset.talkplus.io/npm/talkplus-0.5.7"></script>

1c. Download


2. Initializing

const client = new TalkPlus.Client({appId: 'YOUR_APP_ID'});

3. Promise, Async/Await and Callback

Most functions in the SDK can be called using async/await or by providing a callback function.

// Promise
this.loginAnonymous({
      userId: 'user-123',
      username: 'user-123',
      profileImageUrl: '',
    })
      .then((data) => console.log(data))
      .catch((err) => console.error(err));
      
// async/await
try {
    await client.loginAnonymous({
        userId: 'user-123',
        username: 'user-123',
        profileImageUrl: '',
    });
} catch (err) {
}


// callback
client.loginAnonymous({
    userId: 'user-123', 
    username: 'user-123',
}, function (err, data) {
    console.error(err);
    console.log(data);
});

4. Login / Logout Process

  1. You need to log in (either using loginAnonymous or loginWithToken) after initializing the TalkPlus SDK.

  2. Once logged in, client can receive realtime messages. Web Push Notification is not supported. However, if your app need to support FCM push notification, you can register your device FCM token using registerFcmToken and receive FCM push notification.

  3. TalkPlus SDK does not use cookie or other local storages so closing the browser tab ends the current session.

5. Error

The error JSON response follows the format below:

{
  "error": true,
  "code": "1006",
  "message": "Unauthorized"
}
this link
87KB
talkplus-0.5.7