Bitly

Learn how to minify the long website links in your text messages using Bitly.

Bitly helps you convert your long website links into short, manageable URLs that are reliable, secure and never expire.

Before you begin:

  1. Sign up at Bitly
  2. Once you have logged in, click on the Account name displayed in the top right corner.
  3. Click on Settings and in the left navigation pane, select API.
  4. Click on Generate Token to create a new Access Token.
  5. Using the above Access Token, fetch the GUID for your group using their Get Groups API.
  6. The Access Token and Bitly Group's GUID are required in extension settings.

Settings

  1. Login to the CometChat Dashboard.
  2. Select one of your apps.
  3. On the Extensions page, enable Bitly.
  4. Click on the settings button.
  5. Enter your Bitly Access Token and Group's GUID.
  6. Save your settings.

How does it work?

This extension uses the callExtension method provided by the CometChat Pro SDK.
You can call the extension as follows:

CometChat.callExtension('url-shortener-bitly', 
                        'POST', 'v1/shorten', 
                        {text: "Your message with URL https://yourdomain.com/very/very/long/url"})
  .then(response => {
    // minifiedText in response
})
.catch(error => {
    // Error occured
});
String URL = "/v1/shorten";
JSONObject body=new JSONObject();

body.put("text", "Your message with URL https://yourdomain.com/very/very/long/url");

CometChat.callExtension("url-shortener-bitly", "POST", URL, body,
new CometChat.CallbackListener < JSONObject > () {
    @Override
    public void onSuccess(JSONObject jsonObject) {
        // minifiedText from the extension
    }
    @Override
    public void onError(CometChatException e) {
        // Some error occured
    }
});
CometChat.callExtension(slug: "url-shortener-bitly", type: .post, endPoint: "/v1/shorten", body: ["text": "Your message with URL https://yourdomain.com/very/very/long/url"], onSuccess: { (response) in
        // minifiedText from the extension
      }) { (error) in
        // Some error occured
      }
    }

Did this page help you?