페이지 이동경로
  • Docs>
  • JavaScript>
  • Upgrade v1 to v2

JavaScript

Upgrade v1 to v2

This document guides information to upgrade Kakao SDK for JavaScript("JavaScript SDK") from v1(lower version of 2.0.0) to v2(version 2.0.0 or higher).

Breaking changes

Here are the major changes in the JavaScript SDK v2. To see how to take action for each change, click the corresponding link below.

Change minimum version of Internet Explorer

The minimum supported version of Internet Explorer (IE) is changed to IE 11 in JavaScript SDK v2. To support IE 9 or IE 10, use Legacy JavaScript SDK.

Change script tag used to load JavaScript SDK

To load the JavaScript SDK v2, the version must be specified inside the <script> element.

integrity is an attribute for Subresource Integrity (SRI). To strengthen security, use integrity. To copy the script tag or the integrity value of the desired SDK version, see Download.

<!-- Before -->
<script src="https://t1.kakaocdn.net/kakao_js_sdk/v1/kakao.min.js"></script>

<!-- After -->
<script src="https://t1.kakaocdn.net/kakao_js_sdk/${VERSION}/kakao.min.js"
  integrity="${INTEGRITY_VALUE}" crossorigin="anonymous"></script>

Replace callback patterns with promise patterns

The functions in the JavaScript SDK v2 return the Promise objects instead of callback parameters such as success, fail, and always.

Replace the callback parameters with the Promise.then() and Promise.catch() functions by referring to the following sample snippet and each development guide.

// Before
Kakao.API.request({
  url: '/v2/user/me',
  success: function(response) {
    console.log(response);
  },
  fail: function(error) {
    console.log(error);
  },
});

// After
Kakao.API.request({
  url: '/v2/user/me',
})
  .then(function(response) {
    console.log(response);
  })
  .catch(function(error) {
    console.log(error);
  });

End support for login by presenting popup window

To provide a better service with strengthened security, JavaScript SDK v2 does not provide the associated functions used to obtain an access token on the client side by presenting popup window in JavaScript SDK v1.

To integrate Kakao Login with the JavaScript SDK v2, use the Kakao.Auth.authorize() function instead.

Feature JavaScript SDK v1 JavaScript SDK v2
Kakao Login Kakao.Auth.login()
Kakao.Auth.createLoginButton()
Kakao.Auth.loginForm()
Kakao.Auth.autoLogin()
Kakao.Auth.authorize()

Change module names and API request URLs

As some service names are changed, the associated modules and API request URLs are changed as follows.

Feature JavaScript SDK v1 JavaScript SDK v2
Kakao Talk Sharing Kakao.Link Kakao.Share
Kakao Talk Channel Kakao.PlusFriend Kakao.Channel
Checking Kakao Talk Channel relationship /v1/api/talk/plusfriends /v1/api/talk/channels