This document guides how to use the Kakao SDK for iOS("iOS SDK") provided by the Kakao API platform.
The minimum requirements for iOS SDK are below.
The iOS SDK uses the following libraries that are automatically installed when installing the iOS SDK.
Module | Description |
---|---|
KakaoSDKCommon | Common module that contains essential elements |
KakaoSDKCommonCore | Common module without network features |
KakaoSDKAuth | Authentication |
KakaoSDKUser | Kakao Login, User Management |
KakaoSDKShare | Kakao Talk Sharing |
KakaoSDKTalk | Kakao Talk Social, Kakao Talk Messaging |
KakaoSDKTemplate | Message template |
KakaoSDKNavi | Kakao Navi |
KakaoSDKFriend | Friend picker |
KakaoSDKFriendCore | Module for picker |
KakaoSDKCert | Kakao Certificate |
KakaoSDKCertCore | Module for Kakao Certificate |
Module | Description |
---|---|
RxKakaoSDKCommon | Common module that contains essential elements |
RxKakaoSDKCommonCore | Common module without network features |
RxKakaoSDKAuth | Authentication |
RxKakaoSDKUser | Kakao Login, User Management |
RxKakaoSDKShare | Kakao Talk Sharing |
RxKakaoSDKTalk | Kakao Talk Social, Kakao Talk Messaging |
RxKakaoSDKFriend | Module for picker |
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.
Set iOS app information on [My Application] > [Platform]. Refer to Platform.
Since iOS 9.0, iOS only allows apps registered in Allowlist to enhance security. Register Allowlist to allow the app to run Kakao apps, such as Kakao Talk, Kakao Navi, and so on.
LSApplicationQueriesSchemes
key with an array type on [Info] > [Custom iOS Target Properties]kakaokompassauth
, kakaolink
, and kakaoplus
to the LSApplicationQueriesSchemes
key for the Custom URL Scheme.Or add the keys manaully in the Info.plst file as follows.
<key>LSApplicationQueriesSchemes</key>
<array>
<!-- Login with Kakao Talk -->
<string>kakaokompassauth</string>
<!-- Kakao Talk Sharing -->
<string>kakaolink</string>
<!-- Kakao Talk Channel -->
<string>kakaoplus</string>
</array>
For Xcode 14 or above, the key for allowlist may be automatically converted from the current key LSApplicationQueriesSchemes
to the new key Queried URL Schemes
. The Info.plist file internally uses the existing key. When modifing the Info.plist file directly, use the current key.
Set the Native app key in kakao${YOUR_NATIVE_APP_KEY}
format on [Info] > [URL Type] > [URL Schemes]. For example, if your Native app key is 123456789, set 'URL Schemes' to "kakao123456789".
The URL Schemes are used to generate the Custom URL Scheme. The Custom URL Scheme is used to run an app through a Kakao Talk message or to go back to the app after logging in through Kakao Talk or Kakao Account. The Custom URL Schemes are in the following format.
kakao${NATIVE_APP_KEY}://oauth
kakao${NATIVE_APP_KEY}://kakaolink
To install the Kakao SDK, use CocoaPods or Swift Package Manager (SPM).
CocoaPods version 1.8 or higher is requried. Add the entire modules of the Kakao SDK or the desired modules in the Podfile in the project as below.
# 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 management
pod 'KakaoSDKTalk' # Kakao Talk Social, Kakao Talk Messaging
pod 'KakaoSDKFriend' # Friend picker, 'Cocoapods settings for picker' is required.
pod 'KakaoSDKShare' # Kakao Talk Sharing
pod 'KakaoSDKTemplate' # Message default template
pod 'KakaoSDKNavi' # Kakao Navi
pod 'KakaoSDKCert' # Kakao Certificate
# 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' # Kakao Talk Social, Kakao Talk Messaging
pod 'RxKakaoSDKFriend' # Friend picker, 'Cocoapods settings for picker' is required.
pod 'RxKakaoSDKShare' # Kakao Talk Sharing
pod 'KakaoSDKTemplate' # Message default template
pod 'KakaoSDKNavi' # Kakao Navi
pod 'KakaoSDKCert' # Kakao Certificate
Select ➊ [Project Target] > ➋ [Package Dependencies] > ➌ [Packages] and click [+].
Search the repository URL below for the iOS SDK on ➍ [Search].
SDK | Repository Name | Repository URL |
---|---|---|
iOS SDK | kakao-ios-sdk |
https://github.com/kakao/kakao-ios-sdk |
ReactiveX iOS SDK | kakao-ios-sdk-rx |
https://github.com/kakao/kakao-ios-sdk-rx |
Check the name of the repository and select [Branch] for ➎ [Dependency Rule]. Input the branch name as master
and click ➏ [Add Packages].
Set [Dependency Rule] to install a specific version. But only versions higher than 2.8.5 are available.
On the screen presenting avaiable packages, check the desired modules on ➐ [Package Product] and click ➑ [Add Packages]. To install all of the modules, select [KakaoSDK] or [RxKakaoSDK].
The installed iOS SDK is presented on [Packages].
Each target of the project requires the iOS SDK separately. To install the iOS SDK for the test app, set the [Add to Target] to the test app.
When using SPM to install KakaoSDKFriend and RxKakaoSDKFriend modules, set the resource bundle for the picker. Add KakaoSDKFriendResources.bundle file to [Build Phase] > [Copy Bundle Resources] by clicking [+] or drag and drop.
Import the iOS SDK and initialize it with the Native app key. Add the codes below in AppDelegate.swift.
When using SwiftUI Life Cycle, add the codes in ${PROJECT_NAME}App 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