페이지 이동경로
  • Docs>
  • iOS>
  • Getting started

iOS

Getting started

This document guides how to use the Kakao SDK for iOS("iOS SDK") provided by the Kakao API platform.

Modules

The modules and main features of iOS SDK are below.

Swift
RxSwift
Module Client Description
KakaoSDKCommon - Common module for essential elements
Including PrivacyInfo.xcprivacy file

Main features: Initialize
KakaoSDKAuth AuthApi Module for the authentication and token management through Kakao Login

Main features: Check token presence API
KakaoSDKUser UserApi Module for the Kakao Login APIs

Main features: Kakao Login API, Retrieve user information API
KakaoSDKShare ShareApi Module for the Kakao Talk Sharing APIs

Main features: Send message with custom template API
KakaoSDKTalk TalkApi Module for the Kakao Talk Channel, Kakao Talk Social, Kakao Talk Message APIs¹⁾

Main features: Follow Kakao Talk Channel API
KakaoSDKTemplate - Module for message templates
KakaoSDKFriend PickerApi Module for the picker APIs¹⁾

Main features: Retrieve friends through picker API
KakaoSDKFriendCore - Module for the operations of the picker
KakaoSDKNavi NaviApi Module for the Kakao Navi APIs
KakaoSDKCert CertApi Module for the Kakao Certification APIs¹⁾
KakaoSDKCertCore - Module for the operations of the Kakao Certificate
Including PrivacyInfo.xcprivacy file

1) Use the KakaoSDKUser module together for login-based APIs

Module Client Description
RxKakaoSDKCommon - Common module for essential elements

Main features: Initialize
RxKakaoSDKAuth AuthApi Module for the authentication and token management through Kakao Login

Main features: Check token presence API
RxKakaoSDKUser UserApi Module for the Kakao Login APIs

Main features: Kakao Login API, Retrieve user information API
RxKakaoSDKShare ShareApi Module for the Kakao Talk Sharing APIs
RxKakaoSDKTalk TalkApi Module for the Kakao Talk Channel, Kakao Talk Social, Kakao Talk Message APIs¹⁾

Main features: Follow Kakao Talk Channel
RxKakaoSDKFriend PickerApi Module for the picker APIs¹⁾

Main features: Retrieve friends through picker

1) Use the RxKakaoSDKUser module together for login-based APIs

Module dependency

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.

Kakao SDK module dependency tree

Before you begin

Requirements

The minimum requirements for iOS SDK are below.

  • Xcode 14.3 or higher
  • iOS 13.0 or higher
  • iOS Deployment Target 13.0 or higher
  • Swift 5.0 or higher
Note: External library dependency

The iOS SDK uses the following libraries that are automatically installed when installing the iOS SDK.

Platform

Set iOS app information on [My Application] > [Platform]. Refer to Platform.

Project settings

Allowlist

Since iOS 9.0, iOS only allows apps registered in Allowlist to enhance security. Register Allowlist to allow the app to run Kakao Talk.

  1. Add the Queried URL Schemes key with an array type on [Info] > [Custom iOS Target Properties]
  2. Add below text to the [Item] value of the key.
How to register Allowlist in Xcode

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>
Caution: Change key for allowlist

The Info.plist file internally uses LSApplicationQueriesSchemes instead of Qualied URL Schemes. In Xcode 14 and earlier, the menu settings may also appear as LSApplicationQueriesSchemes instead of Quedied URL Schemes.

URL Schemes

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".

How to set custom URL scheme in Xcode

The URL Schemes are used to generate the Custom URL Scheme. The Custom URL Scheme is used to run the service app through a Kakao Talk message or to go back to the service app after Kakao Login. The Custom URL Schemes are in the following format.

  • Kakao Login: kakao${NATIVE_APP_KEY}://oauth
  • Kakao Talk Sharing: kakao${NATIVE_APP_KEY}://kakaolink

Install

To install the Kakao SDK, use Swift Package Manager (SPM).

Note

Install using Cocoapods is no longer supported in iOS SDK 2.23.0 or higher version.

1. Add Swift Packages

Select ➊ [Project Target] > ➋ [Package Dependencies] > ➌ [Packages] and click [+].

SPM Setting screen
2. Search repository

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].

Search screen
Note: How to specify the version

Set [Dependency Rule] to install a specific version. But only versions higher than 2.8.5 are available.

3. Select and install modules

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].

Select packages

The installed iOS SDK is presented on [Packages].

Packages
Note: Target

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.

4. Set resource bundle

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.

Set resource bundle

Import modules

To use iOS SDK in the app, import files of the required modules. Required modules for each product are below.

Common
Kakao Talk Channel
// iOS SDK
import KakaoSDKCommon

// ReactiveX iOS SDK
import KakaoSDKCommon
import RxKakaoSDKCommon
// iOS SDK
import KakaoSDKTalk
import KakaoSDKUser    // to use Check Kakao Talk Channel Relationship API

// ReactiveX iOS SDK
import KakaoSDKTalk
import KakaoSDKUser    // to use Check Kakao Talk Channel Relationship API
import RxKakaoSDKTalk
import RxKakaoSDKUser    // to use Check Kakao Talk Channel Relationship API

Initialize

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.

Swift
RxSwift
SwiftUI App
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}")
    }
    ...

}
Note: Class name change

In iOS SDK 2.8.3, the class names, used for initialization, have been changed.
- KakaoSDKCommon → KakaoSDK
- RxKakaoSDKCommon → RxKakaoSDK