페이지 이동경로
  • Docs>
  • Kakao Talk Channel>
  • iOS

Kakao Talk Channel

iOS

This document describes how to integrate Kakao Talk Channel APIs into your service with the Kakao SDK for iOS (hereinafter referred to as 'iOS SDK').

Tag used in this document
Tag Description
Login required The API marked with this tag requires Kakao Login. You must implement the Kakao Login function first, and then call the corresponding API by using the access token issued when a user logs in.
Consent required To use the API marked with this tag, you must enable a specific scope required for the corresponding API.
In addition, a user must also consent to the scope. Otherwise, an error occurs or empty value is returned. To check which scopes a user has consented to, you can call the Retrieving consent details API.

Before you begin

Register iOS Platform

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. If not, an error may occur.

Add modules

To use the features of Kakao Talk Channel, add the KakaoSDKTalk or RxKakaoSDKTalk (Kakao Talk module) in the Podfile by referring to Install SDK.

To use the Checking Kakao Talk Channel relationship API that requires Kakao Login, you must also add the Kakao Login module, KakaoSDKUser.

After that, add the import statements as follows.

Swift
RxSwift
import KakaoSDKTalk 

//If you use the Checking Kakao Talk Channel relationship API, import this module as well.
import KakaoSDKUser
import KakaoSDKTalk
import RxKakaoSDKTalk

//If you use the Checking Kakao Talk Channel relationship API, import this module as well.
import RxKakaoSDKUser
import KakaoSDKUser

Add Kakao Talk Channel

To enable a user to add a specific Kakao Talk Channel as a friend, call the makeUrlForAddChannel() method in TalkApi. You can invoke the bridge page URL using the present() method in safariViewController.

This API does not force users to add Kakao Talk Channels, but only presents the bridge page to redirect users to Kakao Talk Channel, specified with the value of channelPublicId. When this feature is invoked, users can select whether to add the Kakao Talk Channel on the bridge page.

Parameter
Name Type Description Required
channelPublicId String Kakao Talk Channel ID. O
Sample
//in ViewController
var safariViewController : SFSafariViewController? // to keep instance
...

self.safariViewController = SFSafariViewController(url: TalkApi.shared.makeUrlForAddChannel(channelPublicId:"{channel-id}")!)

guard (self.safariViewController != nil) else { return }

self.safariViewController?.modalTransitionStyle = .crossDissolve
self.safariViewController?.modalPresentationStyle = .overCurrentContext
self.present(self.safariViewController!, animated: true) {
    print("Succeeded in opening a bridge page to add Kakao Talk Channel.")
}

When the user selects the option to add Kakao Talk Channel on the bridge page, the Kakao Talk app starts through a Custom URL Scheme, and the designated screen of the Kakao Talk Channel is displayed.

This API does not inform you whether the user adds the Kakao Talk Channel. To check the added status, use the Checking Kakao Talk Channel relationship API that shows the relationship between a user and a Kakao Talk Channel.

Start Kakao Talk Channel chat

To allow a user to start a Kakao Talk Channel chat, call the makeUrlForChannelChat() method in TalkApi. You must pass the Kakao Talk Channel ID through channelPublicId as an argument. You can invoke the bridge page URL using the present() method in safariViewController.

Parameter
Name Type Description Required
channelPublicId String Kakao Talk Channel ID. O
Sample
//in ViewController
var safariViewController : SFSafariViewController? // to keep instance
...

self.safariViewController = SFSafariViewController(url: TalkApi.shared.makeUrlForChannelChat(channelPublicId:"{channel-id}")!)

guard (self.safariViewController != nil) else { return }

self.safariViewController?.modalTransitionStyle = .crossDissolve
self.safariViewController?.modalPresentationStyle = .overCurrentContext
self.present(self.safariViewController!, animated: true) {
    print("Succeeded in opening a bridge page to add Kakao Talk Channel.")
}

When the user selects the option to start a Kakao Talk Channel chat on the bridge page, the Kakao Talk app starts through a Custom URL Scheme, and the designated screen of the Kakao Talk Channel is displayed.

When the bridge page is invoked, the Kakao Talk Channel sends the user a message saying "Hello, how can I help you?" with the web page URL that the user requested a chat for.

Check Kakao Talk Channel relationship Login required Consent required

To use this API,

To check if a specific user has added or blocked your Kakao Talk Channel connected to your service app, call the channels() method defined in the TalkApi class.

Make sure that this API only informs the relationship between the user and the Kakao Talk Channel connected to the app that made a request. Thus, you cannot get all Kakao Talk Channels' information that the user has added but the channels related to your service only.

Sample
Swift
RxSwift
TalkApi.shared.channels { (channels, error) in
    if let error = error {
        print(error)
    }
    else {
        print("channels() success.")        
        // Do something
        _ = channels
    }
}
// Class member property
let disposeBag = DisposeBag()

TalkApi.shared.rx.channels()
    .retry(when: Auth.shared.rx.incrementalAuthorizationRequired())
    .subscribe (onSuccess:{ (channels) in
        print("channels() success.")        
        // Do something
        _ = channels
    }, onFailure: {error in
        print(error)
    })
    .disposed(by: disposeBag)
Return data

If the request is successful, channels() returns the Channels object.

Channels
Name Type Description Required
userId Int64 Service user ID. X
channels [Channel] Kakao Talk Channel information. X
Channel
Name Type Description Required
uuid String Kakao Talk Channel ID for search purpose. O
encodedId String Kakao Talk Channel profile ID.
(Example: _ZeUTxl)
O
relation Relation Relationship between a Kakao Talk Channel and a user.
- Added: a user has blocked the channel.
- Blocked: a user has blocked the channel.
- None: a user has not either added or blocked the channel.
O
updatedAt Date Time when a Kakao Talk Channel is added or blocked in UTC*.
Only returned if a Kakao Talk Channel is added (Added) or blocked (Blocked).
X

* The time is based on Coordinated Universal Time(UTC), being 9 hours behind Korean Standard Time(KST). For the format of time, refer to RFC3339: Date and Time on the Internet.

IMPORTANT

To get a notification when a user adds or blocks one of your Kakao Talk Channels linked to you service, use the Kakao Talk Channel callback function.

See more

Legacy

To see how to integrate Kakao Talk Channel using the Legacy Kakao SDK for iOS, see Kakao Talk Channel guide for Legacy iOS SDK.

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.