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

Kakao Talk Social

iOS

This document describes how to integrate Kakao Talk Social 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.

Implement Kakao Login

To use the Kakao Talk Social APIs,

  • You must implement Kakao Login beforehand.
  • A user has been logged in with a Kakao Account.

Add modules

  1. Add KakaoSDKAuth (Authentication and token management module), KakaoSDKUser (Kakao Login module) and KakaoSDKTalk (Kakao Talk Social module that provides UserApi) in the Podfile by referring to Install SDK. To implement the Friend picker, you must also add KakaoSDKFriend module that provides PickerApi.
  2. Add the import statements for the required modules as follows.
Sample
Swift
RxSwift
import KakaoSDKAuth
import KakaoSDKUser
import KakaoSDKTalk
import KakaoSDKFriend // Only used when implementing the Friend picker
import KakaoSDKAuth
import RxKakaoSDKAuth

import KakaoSDKUser
import RxKakaoSDKUser

import KakaoSDKTalk
import RxKakaoSDKTalk

// Only used when implementing the Friend picker
import KakaoSDKFriend 
import RxKakaoSDKFriend

Retrieve Kakao Talk profile Login required Consent required

To retrieve the Kakao Talk profile of the user currently logged in, call the profile() method in the TalkApi class.

To use this API,

  • You must enable the 'Profile' scope in [My Application] > [Kakao Login] > [Consent items].
  • A user must consent to the scope. Otherwise, an empty value is returned.
Sample
Swift
RxSwift
TalkApi.shared.profile {(profile, error) in
    if let error = error {
        print(error)
    else {
        print("profile() success.")

        // Do something
        _ = profile                
    }
}
// Class member property
let disposeBag = DisposeBag()

TalkApi.shared.rx.profile()
    .retry(when: Auth.shared.rx.incrementalAuthorizationRequired())
    .subscribe (onSuccess:{ (profile) in
        print("success.")

        // Do something
        _ = profile   

    }, onFailure: {error in
        print(error)
    })
    .disposed(by: disposeBag)
Return data

profile() returns the TalkProfile object which contains the user's Kakao Talk profile information.

The Kakao Talk profile obatained though profile() is different from the profile of Kakao Account. Refer to Concepts.

TalkProfile
Name Type Description Required
nickname String Kakao Talk nickname.

Required user consent: Profile Info(nickname/profile image) or Nickname
X
profileImageUrl URL Kakao Talk profile image URL.

Required user consent: Profile Info(nickname/profile image) or Profile image
X
thumbnailUrl URL Kakao Talk profile thumbnail image URL.

Required user consent: Profile Info(nickname/profile image) or Profile image
X
countryISO String Code of country where the user is using Kakao Talk. X

Retrieve friends through picker Login requiredConsent required

This API displays the Friend picker and provides the information of the Kakao Talk friends that a user selects through the picker.

To use this API,

  • Import the KakaoSDKFriend module, and then complete Cocoapods settings for picker.
  • You must enable the 'Friends List in Kakao Service(Including profile image, nickname, and favorites)' scope in [My Application] > [Kakao Login] > [Consent items].
  • A user must consent to the 'Friends List in Kakao Service(Including profile image, nickname, and favorites)' scope.

Depending on the selection type and display format of the Friend picker, you need to use a different method.

Method
Selection type Display format Method to use
Only one friend (Single picker) Full screen selectFriend()
Multiple friends (Multi-picker) Full screen selectFriends()
Only one friend (Single picker) Popup screen selectFriendPopup()
Multiple friends (Multi-picker) Popup screen selectFriendsPopup()
Parameter
Name Type Description Required
title String Text to be displayed in the title area of the Friend picker.
(Default: "Select Friends")
X
viewAppearance ViewAppearance Dispaly mode of the Friend picker.

One of the followings:
- light: Light mode.
- dark: Dark mode.
- auto: The mode set in the system display settings is automatically applied.
(Default: auto)
X
orientation PickerOrientation Orientiation of the Friend picker screen.

One of the followings:
- portrait: Portrait mode.
- landscape: Landscape mode.
- auto: Orientation set in the system settings is automatically applied.
(Default: auto)
X
enableSearch Bool Whether to show the Search box for friends.
(Default: true)
X
enableIndex Bool Whether to show the Index by the first letter of profile nickname.
(Default: true)
X
showMyProfile Bool Whether to show my profile.
It set to true, users can also select their own profile themselves.
(Default: true)
X
showFavorite Bool Whether to show the friends added as Favorite.
(Default: true)
X
showPickedFriend Bool Only for the multi-picker.
Whether to show the selected friends.
(Default: true)
X
maxPickableCount Int Only for the multi-picker.
Maximum number of the seletable friends.
This value must be greater than or equal to minPickableCount.
(Default: 30, Maximum: 100)
X
minPickableCount Int Only for the multi-picker.
Minimum number of the seletable friends.
This value must be less than or equal to minPickableCount.
(Default: 1, Maximum: 100)
X
Sample
Single picker in full screen
Swift
RxSwift
let openPickerFriendRequestParams = OpenPickerFriendRequestParams(
    title: "Single picker in full screen", //default "Select friends"                                                
    viewAppearance: .auto,                  //default .auto
    orientation: .auto,                     //default .auto
    enableSearch: true,                     //default true
    enableIndex: true,                      //default true
    showMyProfile: true,                    //default true
    showFavorite: true                      //default true     
)

PickerApi.shared.selectFriend(params: openPickerFriendRequestParams) { selectedUsers, error in
    if let error = error {
        print(error)
    }
    else {
        print("selectFriend(params:) success.")
        
        //do something
        _ = selectedUsers 
    }
}
// Class member property
let disposeBag = DisposeBag()

let openPickerFriendRequestParams = OpenPickerFriendRequestParams(
    title: "Single picker in full screen", //default "Select friends"                                                
    viewAppearance: .auto,                  //default .auto
    orientation: .auto,                     //default .auto
    enableSearch: true,                     //default true
    enableIndex: true,                      //default true
    showMyProfile: true,                    //default true
    showFavorite: true                      //default true
)

PickerApi.shared.rx.selectFriend(params:openPickerFriendRequestParams)
    .subscribe (onNext:{ (selectedUsers) in
        print("selectFriend(params:) success.")

        //do something
        _ = selectedUsers 

    }, onError: {error in
        print(error)
    })
    .disposed(by: disposeBag) 
Single picker in popup screen
Swift
RxSwift
let openPickerFriendRequestParams = OpenPickerFriendRequestParams(
    title: "Single picker in popup screen", //default "Select friends"                                                
    viewAppearance: .auto,                  //default .auto
    orientation: .auto,                     //default .auto
    enableSearch: true,                     //default true
    enableIndex: true,                      //default true
    showMyProfile: true,                    //default true
    showFavorite: true                      //default true       
)

PickerApi.shared.selectFriendPopup(params: openPickerFriendRequestParams) { selectedUsers, error in
    if let error = error {
        print(error)
    }
    else {
        print("selectFriendPopup(params:) success.")
        
        //do something
        _ = selectedUsers 
    }
}
// Class member property
let disposeBag = DisposeBag()

let openPickerFriendRequestParams = OpenPickerFriendRequestParams(
    title: "Single picker in popup screen", //default "Select friends"
    viewAppearance: .auto,                  //default .auto
    orientation: .auto,                     //default .auto
    enableSearch: true,                     //default true
    enableIndex: true,                      //default true
    showMyProfile: true,                    //default true
    showFavorite: true                      //default true
)

PickerApi.shared.rx.selectFriendPopup(params:openPickerFriendRequestParams)
    .subscribe (onNext:{ (selectedUsers) in
        print("selectFriendPopup(params:) success.")

        //do something
        _ = selectedUsers 

    }, onError: {error in
        print(error)
    })
    .disposed(by: disposeBag)
Multi-picker in full screen
Swift
RxSwift
let openPickerFriendRequestParams = OpenPickerFriendRequestParams(
    title: "Multi-picker in full screen", //default "Select friends"                                                
    viewAppearance: .auto,                  //default .auto
    orientation: .auto,                     //default .auto
    enableSearch: true,                     //default true
    enableIndex: true,                      //default true
    showMyProfile: true,                    //default true
    showFavorite: true,                     //default true
    showPickedFriend: nil,                  //default true
    maxPickableCount: nil,                  //default 30
    minPickableCount: nil                   //default 1   
)

PickerApi.shared.selectFriends(params: openPickerFriendRequestParams) { selectedUsers, error in
    if let error = error {
        print(error)
    }
    else {
        print("selectFriends(params:) success.")
        
        //do something
        _ = selectedUsers 
    }
}
// Class member property
let disposeBag = DisposeBag()

let openPickerFriendRequestParams = OpenPickerFriendRequestParams(
    title: "Multi-picker in full screen", //default "Select friends"                                                
    viewAppearance: .auto,                  //default .auto
    orientation: .auto,                     //default .auto
    enableSearch: true,                     //default true
    enableIndex: true,                      //default true
    showMyProfile: true,                    //default true
    showFavorite: true,                     //default true
    showPickedFriend: nil,                  //default true
    maxPickableCount: nil,                  //default 30
    minPickableCount: nil                   //default 1 
)

PickerApi.shared.rx.selectFriends(params:openPickerFriendRequestParams)
    .subscribe (onNext:{ (selectedUsers) in
        print("selectFriends(params:) success.")

        //do something
        _ = selectedUsers        

    }, onError: {error in
        print(error)
    })
    .disposed(by: disposeBag)
Multi-picker in popup screen
Swift
RxSwift
let openPickerFriendRequestParams = OpenPickerFriendRequestParams(
    title: "Multi-picker in popup screen", //default "Select friends"                                                
    viewAppearance: .auto,                  //default .auto
    orientation: .auto,                     //default .auto
    enableSearch: true,                     //default true
    enableIndex: true,                      //default true
    showMyProfile: true,                    //default true
    showFavorite: true,                     //default true
    showPickedFriend: nil,                  //default true
    maxPickableCount: nil,                  //default 30
    minPickableCount: nil                   //default 1                  
)

PickerApi.shared.selectFriendsPopup(params: openPickerFriendRequestParams) { selectedUsers, error in
    if let error = error {
        print(error)
    }
    else {
        print("selectFriendsPopup(params:) success.")
        
        //do something
        _ = selectedUsers 
    }
}
// Class member property
let disposeBag = DisposeBag()

let openPickerFriendRequestParams = OpenPickerFriendRequestParams(
    title: "Multi-picker in popup screen", //default "Select friends"                                                
    viewAppearance: .auto,                  //default .auto
    orientation: .auto,                     //default .auto
    enableSearch: true,                     //default true
    enableIndex: true,                      //default true
    showMyProfile: true,                    //default true
    showFavorite: true,                     //default true
    showPickedFriend: nil,                  //default true
    maxPickableCount: nil,                  //default 30
    minPickableCount: nil                   //default 1 
)

PickerApi.shared.rx.selectFriendsPopup(params:openPickerFriendRequestParams)
    .subscribe (onNext:{ (selectedUsers) in
        print("selectFriendsPopup(params:) success.")

        //do something
        _ = selectedUsers 

    }, onError: {error in
        self.errorHandler(error: error)
    })
    .disposed(by: disposeBag)
Return data

If the request is successful, the information of the friends that a user selects from the Friend picker is returned through SelectedUsers. If you encounter errors, refer to Troubleshooting.

SelectedUsers: Selected friends data
Name Type Description Required
totalCount Int Number of friends who a user selected on the Friend picker.
Refer to If the number of friends passed in response is less than the number of selected friends.
O
users SelectedUser[] List of friends data that is passed in the response.
Refer to SelectedUser.
X

SelectedUser: Each friend data
Name Type Description Required
uuid String User's unique ID used to identify users in a service and used to send a Kakao Talk message.
This value may change if a user deletes and then re-creates the Kakao Talk account.
O
id Int64 Friend's service user ID. Only the friends who are linked to the app have a service user ID. X
profileNickname String Friend's profile nickname set in Kakao Talk. X
profileThumbnailImage URL Friend's profile thumbnail image set in Kakao Talk. X
favorite Bool Whether the friend is added as Favorite. X

Retrieve list of friends Login required Consent required

This API enables you to get the list of Kakao Talk friends of the user currently logged in. Note that Kakao Talk profiles may be different from Kakao Account profiles. Refer to Concepts.

To use this API,

  1. Get permission. Before permission is granted to your app, you can call this API only for the team members.
  2. Enable the 'Friends List in Kakao Service(Including profile image, nickname, and favorites)' scope in [My Application] > [Kakao Login] > [Consent items]. A user must also consent to the scope. To see more about the conditions for providing friend information, refer to Usage policy.

To get the list of Kakao Talk friends of the user currently logged in, call the friends() method in the TalkApi class. You can also pass optional parameters through arguments. If you make a request without any parameters, the default settings are applied.

Parameter
Name Type Description Required
offset Int Offset value that the list of friends starts from.
(Default: 0)
X
limit Int Maximum number of friends to be retrieved per page.
(Maximum: 100, Default: 10)
X
order Order Sort order of friends list.
Asc or Desc.
- Asc: sort in ascending order.
- Desc: sort in descending order.
(Default: Asc)
X
friendOrder FriendOrder Method to sort friends in the list.
- Nickname: sort by Kakao Talk nickname in ascending or descending order according to the set value of order.
- Favorite: user's favorite friends appear ahead in the sort order according to the set value of order and then the rest friends are sorted with the same priority.
(Default: Favorite)
X
Sample
Swift
RxSwift
TalkApi.shared.friends {(friends, error) in
    if let error = error {
        print(error)
    }
    else {
        // Do something
        _ = friends        
    }
}
// Class member property
let disposeBag = DisposeBag()

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

friends() returns Friends which contains a list of the user's Kakao Talk friends.

If the request fails because the user has not agreed to provide the Friends list, proceed the followings:

  • Check if 'Friends List in Kakao Service(Including profile image, nickname, and favorites)' is set to 'Consent during use' in Consent items.
  • Request additional consent to the 'Friends List in Kakao Service(Including profile image, nickname, and favorites)' scope.
Friends
Name Type Description Required
elements [Friend] List of Kakao Talk profile information of each friend. X
totalCount Int Total number of Kakao Talk friends. O
beforeUrl URL Previous page URL.
If there is no previous page, nil is returned.
X
afterUrl URL Next page URL.
If there is no next page, nil is returned.
X
favoriteCount Int Number of friends added as favorite. X
Friend
Name Type Description Required
id Int64 Service user ID. X
uuid String User's unique ID used to send a Kakao Talk message.
Do not use this value to identify users because this value may change depending on user's account status.
O
profileNickname String Friend's profile nickname. X
profileThumbnailImage URL Friend's profile thumbnail image. X
favorite Bool Whether or not the friend is added as a favorite.
true: Added as favorite.
false: Not added as favorite.
X

* Deprecated 'allowedMsg' that indicates whether or not the friend allows to receive Kakao Talk messages from the app as Profile visibility option is provided. For more details, refer to DevTalk.

See more

Legacy

To see how to integrate Kakao Talk Social using the Legacy Kakao SDK for iOS, see Kakao Talk Social 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.