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).
Here are the major changes in the JavaScript SDK v2. To see how to take action for each change, click the corresponding link below.
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.
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>
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);
});
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() |
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 |