페이지 이동경로
  • 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 ("iOS SDK").

Before you begin

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

Basic information
Permission Prerequisite Kakao Login User consent
- Register platforms - -
Note: Allowlist

To use this feature, add kakaoplus to Allowlist.


Launches Kakao Talk to let the user add the Kakao Talk Channel. Call addChannel() in TalkApi. Pass the profile ID of the Kakao Talk Channel.

Parameter

Name Type Description Required
channelPublicId String Kakao Talk Channel ID. O
Swift
RxSwift
TalkApi.shared.addChannel(channelPublicId: "${CHANNEL_ID}") {
  if let error = error {
    print(error)
  } else {
     print("addChannel() success.")
    // do something
    ...
  }
}
let disposeBag = DisposeBag()

TalkApi.shared.rx.addChannel(channelPublicId: "${CHANNEL_ID}")
  .subscribe(onCompleted:{
    print("addChannel() success")
    //do something
    ...
  }, onError: {error in
    print(error)
  })
  .disposed(by: disposeBag)

This API does not inform 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.

Bridge page

ReactiveX iOS SDK does not support this feature.

To send the user to a bridge page before launching Kakao Talk, use makeUrlForAddChannel(). Pass the profile ID of the Kakao Talk Channel. To open the url, use the present() method in safariViewController.

//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.")
}

Start Kakao Talk Channel chat

Basic information
Permission Prerequisite Kakao Login User consent
- Register platforms - -
Note: Allowlist

To use this feature, add kakaoplus to Allowlist.


Starts a chat with Kakao Talk Channel. Call chatChannel() in TalkApi. Pass the profile ID of the Kakao Talk Channel.

Parameter

Name Type Description Required
channelPublicId String Kakao Talk Channel ID. O
Swift
RxSwift
TalkApi.shared.chatChannel(channelPublicId: "${CHANNEL_ID}") {
  if let error = error {
    print(error)
  } else {
     print("chatChannel() success.")
    // do something
    ...
  }
}
let disposeBag = DisposeBag() 

TalkApi.shared.rx.chatChannel(channelPublicId: "${CHANNEL_ID}")
  .subscribe(onCompleted:{
    print("chatChannel() success")
    //do something
    ...
  }, onError: {error in
    print(error)
  })
  .disposed(by: disposeBag)

Bridge page

ReactiveX iOS SDK does not support this feature.

To send the user to a bridge page before launching Kakao Talk, use makeUrlForChatChannel(). Pass the profile ID of the Kakao Talk Channel. To open the URL, use the present() method in safariViewController.

//in ViewController
var safariViewController : SFSafariViewController? // to keep instance
...

self.safariViewController = SFSafariViewController(url: TalkApi.shared.makeUrlForChatChannel(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.")
}

Check Kakao Talk Channel relationship

Basic information
Permission Prerequisite Kakao Login User consent
- Register platforms
Activate Kakao Login
Manage consent items
Set Kakao Talk Channel
Required Required:
Kakao Talk Channel addition status and details

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)

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.

Note

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