Getting Started

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 this link.

React Native

Use this React Native-specific SDK.

  • CDN:

<script src="https://asset.talkplus.io/react-native/talkplus-rn-0.5.4.js"></script>
  • Binary


1a. NPM

npm install talkplus-sdk

1b. CDN

<script src="https://asset.talkplus.io/npm/talkplus-0.5.4"></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"
}

Last updated