This document describes what you should do to integrate the Kakao SDK for iOS (hereinafter referred to as 'iOS SDK') into your web before leveraging the Kakao APIs.
To use the iOS SDK, you must register the iOS platform in advance. Go to [My Application] > [Platform] and register the iOS platform by specifying the Bundle ID.
The iOS SDK has the following features:
Here are what you need to use the iOS SDK:
The iOS SDK uses the following libraries that are automatically installed when installing the iOS SDK:
You can install the Kakao SDK either by:
pod install
.# Add all modules
pod 'KakaoSDK'
# or
# Add the desired modules
pod 'KakaoSDKCommon' # Common module that contains essential elements
pod 'KakaoSDKAuth' # Authentication
pod 'KakaoSDKUser' # Kakao Login, User
pod 'KakaoSDKTalk' # Friend, Message(Kakao Talk)
pod 'KakaoSDKStory' # Kakao Story
pod 'KakaoSDKLink' # Message(Kakao Link)
pod 'KakaoSDKTemplate' # Message default template
pod 'KakaoSDKNavi' # Kakao Navi
# Add all modules
pod 'RxKakaoSDK'
# or
# Add the desired modules
pod 'RxKakaoSDKCommon' # Common module that contains essential elements
pod 'RxKakaoSDKAuth' # Authentication
pod 'RxKakaoSDKUser' # Kakao Login, User
pod 'RxKakaoSDKTalk' # Friend, Message(Kakao Talk)
pod 'RxKakaoSDKStory' # Kakao Story
pod 'RxKakaoSDKLink' # Message(Kakao Link)
Some modules in the Kakao SDK are dependent on another module. If you add the Common or Auth module, its subordinate modules are automatically added together.
In iOS SDK 2.8.5 or higher, you can simply install the iOS SDK by using Swift Package Manager (SPM). The SPM is a tool used to manage the distribution of source code and built in Xcode 11 or higher. For more details, refer to Adding Package Dependencies to Your App.
In your Xcode,
https://github.com/kakao/kakao-ios-sdk.git
https://github.com/kakao/kakao-ios-sdk-rx
Package name | Description |
---|---|
KakaoSDK / RxKakaoSDK | Select this library if you want to add all dependencies. |
KakaoSDKAuth/RxKakaoSDKAuth | Add this library for authentication or calling the Checking token presence API. |
KakaoSDKCommon / RxKakaoSDKCommon | Add this library for the common module that contains essential elements. |
KakaoSDKCommonCore / RxKakaoSDKCommonCore | Add this library for the common module except for the network function. |
KakaoSDKUser / RxKakaoSDKUser | Add this library for Kakao Login. |
KakaoSDKStory / RxKakaoSDKStory | Add this library for Kakao Story API. |
KakaoSDKTemplate (Not supported for ReactiveX iOS SDK) |
Add this library for configuring a default template when calling Kakao Link or Kakao Talk messaging API. |
KakaoSDKLink / RxKakaoSDKLink | Add this library for Kakao Link API. |
KakaoSDKTalk / RxKakaoSDKTalk | Add this library for Kakao Talk messaging API and Kakao Talk Social API. |
KakaoSDKNavi (Not supported for ReactiveX iOS SDK) |
Add this library for Kakao Navi API. |
To check if libraries are successfully added, select your project in [TARGETS], and then check if the libraries you selected are listed under 'Frameworks, Libraries, and Embedded Content'.
Since iOS 9.0, iOS only allows apps registered in Allowlist to enhance security. Thus, you must register 'Allowlist' to allow your app to run Kakao apps, such as Kakao Talk, Kakao Story, Kakao Navi, and so on.
To register Allowlist:
LSApplicationQueriesSchemes
key with an array type in the plist file. LSApplicationQueriesSchemes
key, and set them to "kakaokompassauth" and "kakaolink".You need to set 'URL Schemes' to use the Custom URL Scheme. The Custom URL Scheme is used to run an app through a Kakao Talk message or Kakao Story post, or to go back to your app after logging in through Kakao Talk or Kakao Account.
kakao${YOUR_NATIVE_APP_KEY}
format. For example, if your Native app key is 123456789, set 'URL Schemes' to "kakao123456789".This setting above is used to create the Custom URL Scheme in the following format.
kakao${NATIVE_APP_KEY}://oauth
kakao${NATIVE_APP_KEY}://kakaolink
kakao${NATIVE_APP_KEY}://kakaostory
Or you can add the keys manaully in the Info.plst file as follows:
<key>KAKAO_APP_KEY</key>
<string>0123456789abcdefghijklmn</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>kakao${YOUR_NATIVE_APP_KEY}</string>
<string>kakaokompassauth</string>
<string>storykompassauth</string>
<string>kakaolink</string>
<string>storylink</string>
</array>
After installing the SDK, you need to initialize the SDK for the initial setup.
To initialize the iOS SDK,
KakaoSDK
instance by adding the initSDK
method with your Native app key in the application
method of AppDelegate
instance. initSDK()
inside the ${PROJECT_NAME}App class created with the SwiftUI App project, instead of AppDelegate.swift.import KakaoSDKCommon
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
...
KakaoSDK.initSDK(appKey: "NATIVE_APP_KEY")
...
}
import RxKakaoSDKCommon
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
...
RxKakaoSDK.initSDK(appKey: "NATIVE_APP_KEY")
...
}
import SwiftUI
import KakaoSDKCommon
import KakaoSDKAuth
...
@main
struct SwiftUI_testApp: App {
...
init() {
// Initialize Kakao SDK.
KakaoSDK.initSDK(appKey: "NATIVE_APP_KEY")
}
...
}
In iOS SDK 2.8.3, the class names, used for initialization, have been changed: - KakaoSDKCommon → KakaoSDK - RxKakaoSDKCommon → RxKakaoSDK
To see how to integrate Kakao Login using the Legacy Kakao SDK for iOS, click this button. It is highly recommended to migrate to the new version of iOS SDK as soon as possible because the Legacy version may not be supported anymore.
You can migrate the Legacy iOS SDK (version 1.x.x) to the latest version of iOS SDK (version 2.x.x) using this migration guide.
The Legacy iOS SDK requires you to configure a project and import the SDK, and then call APIs. On the other hand, the latest iOS SDK requires explicit initialization, so you must have your app launched and initialized first and then call an API.
The token-based APIs refer to the APIs that require Kakao Login with which you can get an access token.
With the Legacy iOS SDK, you need to use KOSessionTask
to call an API that passes an access token issued through Kakao Login. When using the Legacy iOS SDK, the session changes according to a user's login status, and some APIs can be called only when a session is open.
APIs in the latest iOS SDK are separated by modules so that you can use the desired modules only. However, for the API that passes an access token through Kakao Login, you must install the Kakao Login module along with the desired module and implement the login function.
Considering the structural difference, you must check if the module you want to use is dependent on Kakao Login. For the token-based APIs that require Kakao Login, the development guide for each API describes the required modules and whether to implement Kakao Login.
initSDK()
method that initializes the SDK through KakaoCommon
.Name | Legacy SDK | SDK |
---|---|---|
Initializing Kakao SDK | - | initSDK() |
In iOS SDK 2.8.3, the class names, used for initialization, have been changed: - KakaoSDKCommon → KakaoSDK - RxKakaoSDKCommon → RxKakaoSDK
KOSession
.KOSessionTask
UserApi
in the KakaoSDKUser
module.AuthApi
in the KakaoSDKAuth
module.Name | Legacy SDK | SDK |
---|---|---|
Kakao Login | openWithCompletionHandler | - |
Login with Kakao Talk | - | loginWithKakaoTalk() |
Login with Kakao Account | - | loginWithKakaoAccount() |
Logout | logoutAndCloseWithCompletionHandler | logout() |
Unlink | unlinkTaskWithCompletionHandler | unlink() |
Retrieving user information | userMeTaskWithCompletion | me() |
Storing user information | profileUpdateTaskWithProperties:properties: | updateProfile(properties:) |
Requesting additional consent | updateScopes:needsAgreementScopes: | loginWithKakaoTalk(scopes:) loginWithKakaoAccount(scopes:) |
Checking if Kakao Talk is installed | - | isKakaoTalkLoginAvailable() |
Retrieving token information | accessTokenInfoTaskWithCompletionHandler | accessTokenInfo() |
Checking token presence | isOpen | hasToken() |
KOSessionTask
.TalkApi
in the KakaoSDKTalk
module.Name | Legacy SDK | SDK |
---|---|---|
Retrieving Kakao Talk profile | talkProfileTaskWithCompletionHandler | profile() |
Retrieving list of friends | appFriendsWithContext:context: | friends() |
KLKTalkLinkCenter
for Sending message API. KLKImageStorage
.LinkApi
in the KakaoSDKLink
module.Name | Legacy SDK | SDK |
---|---|---|
Checking if Kakao Talk is installed | - | isKakaoLinkAvailable() |
Sending with default template | sendDefaultWithTemplate:template: | defaultLink(templatable:) |
Sending with custome template | sendCustomWithTemplateId:templateId:templateArgs: | customLink(templateId:templateArgs:) |
Sending a scrap message | sendScrapWithURL: url:templateId: | scrapLink(requestUrl:templateId:) |
Uploading an image | uploadWithImage:sourceImage: | imageUpload(image:) |
Scraping an image | scrapWithImageURL:imageURL: | imageScrap(imageUrl:) |
Deleting an image | deleteWithImageURL:imageURL: | - |
KOSessionTask
.TalkApi
in the KakaoSDKTalk
module.Name | Legacy SDK | SDK |
---|---|---|
Sending me with default template | talkMemoSendTaskWithTemplate:template: | sendDefaultMemo(templatable:) |
Sending me with custom template | talkMemoSendTaskWithTemplateId:templateId: | sendCustomMemo(templateId:) |
Sending me a scrap message | talkMemoSendTaskWithURL:url:templateId: | sendScrapMemo(requestUrl:templateId:) |
Sending friends with default template | sendMessageToFriendsWithTemplate:template: | sendDefaultMessage(templatable:receiverUuids:) |
Sending friends with custom template | sendMessageToFriendsTaskWithTemplateId:templateId: | sendCustomMessage(templateId:receiverUuids:) |
Sending friends a scrap message | sendMessageToFriendsTaskWithURL:url:templateId: | sendScrapMessage(requestUrl:templateId:receiverUuids:) |
KOSessionTask
.StoryApi
in the KakaoSDKStory
module.Name | Legacy SDK | SDK |
---|---|---|
Validating Kakao Story user | storyIsStoryUserTaskWithCompletionHandler | isStoryUser() |
Retrieving Kakao Talk profile | storyProfileTaskWithCompletionHandler | profile() |
Posting text story | storyPostNoteTaskWithContent:content: | postNote(content:) |
Posting photo story | storyPostPhotoTaskWithImageUrls:content:images: | postPhoto(content:images:) |
Posting link story | storyPostLinkTaskWithLinkInfo:link: | postLink(content:linkInfo:) |
Retrieving specified story | storyGetMyStoryTaskWithMyStoryId:myStoryId: | story(id:) |
Retrieving multiple stories | storyGetMyStoriesTaskWithLastMyStoryId:lastMyStoryId: | stories() |
Deleting story | storyDeleteMyStoryTaskWithMyStoryId:myStoryId: | delete(id:) |
Uploading image | storyMultiImagesUploadTaskWithImages:chosenImages: | upload(images:) |
Scraping web page | storyGetLinkInfoTaskWithUrl:url: | linkInfo(url:) |
KPFPlusFriend
.KOSessionTask
.TalkApi
in the KakaoSDKTalk
module.Name | Legacy SDK | SDK |
---|---|---|
Adding Kakao Talk Channel | addFriend:plusFriendId: | makeUrlForAddChannel(channelPublicId:) |
Kakao Talk Channel chat | chat:plusFriendId: | makeUrlForChannelChat(channelPublicId:) |
Checking Kakao Talk Channel relationship | talkPlusFriendsTask | channels() |
KOSessionTask
.KOSession
.UserApi
in the KakaoSDKUser
module.Name | Legacy SDK | SDK |
---|---|---|
Retrieving shipping address | shippingAddressTask | shippingAddresses() |
Checking user agreed terms | serviceTermsTask | serviceTerms() |
Getting consent to desired term | open | loginWithKakaoTalk(serviceTerms:) loginWithKakaoAccount(serviceTerms:) |
KNVNaviLauncher
.KakaoSDKNavi
in the NaviApi
module.Name | Legacy SDK | SDK |
---|---|---|
Navigation | navigateWithParams:params: | navigateUrl(destination:) |
Getting URL for navigation | - | Deprecated webNavigateUrl(destination:) |
Sharing location | shareDestinationWithParams:params: | shareUrl(destination:) |
Setting conditions for navigation | locationWithName | NaviOption() |
Setting conditions for destination information | paramsWithDestination | NaviLocation() |
KOSessionTask
.Name | Legacy SDK | SDK |
---|---|---|
Registering push token | pushRegisterDeviceWithToken:deviceToken: | - |
Retrieving push token | pushGetTokensTaskWithCompletionHandler | - |
Deleting push token | pushDeregisterDeviceWithToken:deviceToken: | - |