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

Retrieve Kakao Talk profile

Basic information
Reference App setting
[SDK, RxSDK] profile()
[SDK] TalkProfile
Install
Import modules
Initialize
Permission Prerequisite Kakao Login User consent
- Register platforms
Activate Kakao Login
Manage consent items
Required Required:
Profile Info(nickname/profile image)
Nickname
Profile image

Retrieves the Kakao Talk profile of the user currently logged in.

Request

Call profile().

Response

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.

Sample

Swift
RxSwift
TalkApi.shared.profile {(profile, error) in
    if let error = error {
        print(error)
    else {
        print("profile() success.")

        // Implement service logics
        _ = profile                
    }
}
// Class member property
let disposeBag = DisposeBag()

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

        // Implement service logics
        _ = profile   

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

Retrieve friends through picker

Basic information
Reference App setting
[SDK, RxSDK] selectFriend()
[SDK] OpenPickerFriendRequestParams
[SDK] SelectedUsers
Install
Import modules
Initialize
Permission Prerequisite Kakao Login User consent
Required Register platforms
Activate Kakao Login
Manage consent items
Required Required:
Friends List in Kakao Service(Including profile image, nickname, and favorites)

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

Request

When calling selectFriend(), you can choose the display format and selection type of the Friend picker by specifying the corresponding parameters.

To use the full screen type Friend picker, set viewType to FULL. To use the popup view type, set it to POPUP.

To use the multi picker, set enableMulti to true. To use the single picker, set enableMulti to false. If not set, the multi picker is applied by default.

Other detailed settings such as picker orientation and search function can be modified by specifying OpenPickerFriendRequestParams. For more information on parameters, refer to the reference and Friend picker custom elements.

Response

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 Error code.

Sample

Full screen
Single picker: Swift
Multi picker: Swift
Single picker: RxSwift
Multi picker: RxSwift
let openPickerFriendRequestParams = OpenPickerFriendRequestParams(
    title: "Single picker", // Name of the picker
    viewAppearance: .auto, // Display type
    orientation: .auto, // Orientation of the picker
    enableSearch: true, // Enables the search function
    enableIndex: true, // Enables the index view
    showFavorite: true // Marks on favorite friends
)

PickerApi.shared.selectFriend(params: openPickerFriendRequestParams, viewType: .full, enableMulti:false){ [weak self] selectedUsers, error in
  if let error = error {
        print(error)
    }
    else {
        print("selectFriend(params:) success.")
        
        //do something
        _ = selectedUsers 
    }
}
let openPickerFriendRequestParams = OpenPickerFriendRequestParams(
    title: "Multi-picker", // Name of the picker
    viewAppearance: .auto, // Display type
    orientation: .auto, // Orientation of the picker
    enableSearch: true, // Enables the search function
    enableIndex: true, // Enables the index view
    showFavorite: true, // Marks on favorite friends
    showPickedFriend: true, // Displays selected friends for multi-picker
    maxPickableCount: 5, // Maximum pickable count
    minPickableCount: 1 // Minimum pickable count
)

PickerApi.shared.selectFriend(params: openPickerFriendRequestParams, viewType: .full, enableMulti:true){ [weak self] selectedUsers, error in
  if let error = error {
        print(error)
    }
    else {
        print("selectFriend(params:) success.")
        
        // Implement actions on success
        _ = selectedUsers 
    }
}
// Class member property
let disposeBag = DisposeBag()

let openPickerFriendRequestParams = OpenPickerFriendRequestParams(
    title: "Single picker", // Name of the picker
    viewAppearance: .auto, // Display type
    orientation: .auto, // Orientation of the picker
    enableSearch: true, // Enables the search function
    enableIndex: true, // Enables the index view
    showFavorite: true // Marks on favorite friends
)

PickerApi.shared.rx.selectFriend(params: openPickerFriendRequestParams, viewType: .full, enableMulti: false))
    .subscribe (onNext:{ (selectedUsers) in
        print("selectFriend(params:) success.")

        // Implement actions on success
        _ = selectedUsers 

    }, onError: {error in
        print(error)
    })
    .disposed(by: disposeBag)
// Class member property
let disposeBag = DisposeBag()

let openPickerFriendRequestParams = OpenPickerFriendRequestParams(
    title: "Multi-picker", // Name of the picker
    viewAppearance: .auto, // Display type
    orientation: .auto, // Orientation of the picker
    enableSearch: true, // Enables the search function
    enableIndex: true, // Enables the index view
    showFavorite: true, // Marks on favorite friends
    showPickedFriend: true, // Displays selected friends for multi-picker
    maxPickableCount: 5, // Maximum pickable count
    minPickableCount: 1 // Minimum pickable count
)

PickerApi.shared.rx.selectFriend(params: openPickerFriendRequestParams, viewType: .full, enableMulti: true))
    .subscribe (onNext:{ (selectedUsers) in
        print("selectFriend(params:) success.")

        // Implement actions on success
        _ = selectedUsers 

    }, onError: {error in
        print(error)
    })
    .disposed(by: disposeBag) 
Popup
Single picker: Swift
Multi picker: Swift
Single picker: RxSwift
Multi picker: RxSwift
let openPickerFriendRequestParams = OpenPickerFriendRequestParams(
    title: "Single picker", // Name of the picker
    viewAppearance: .auto, // Display type
    orientation: .auto, // Orientation of the picker
    enableSearch: true, // Enables the search function
    enableIndex: true, // Enables the index view
    showFavorite: true // Marks on favorite friends
)

PickerApi.shared.selectFriend(params: openPickerFriendRequestParams, viewType: .popup, enableMulti:false){ [weak self] selectedUsers, error in
  if let error = error {
        print(error)
    }
    else {
        print("selectFriend(params:) success.")
        
        // Implement actions on success
        _ = selectedUsers 
    }
}

</div>
<div class="swift-multi">

```swift
let openPickerFriendRequestParams = OpenPickerFriendRequestParams(
    title: "Multi-picker", // Name of the picker
    viewAppearance: .auto, // Display type
    orientation: .auto, // Orientation of the picker
    enableSearch: true, // Enables the search function
    enableIndex: true, // Enables the index view
    showFavorite: true, // Marks on favorite friends
    showPickedFriend: true, // Displays selected friends for multi-picker
    maxPickableCount: 5, // Maximum pickable count
    minPickableCount: 1 // Minimum pickable count
)

PickerApi.shared.selectFriend(params: openPickerFriendRequestParams, viewType: .popup, enableMulti:true){ [weak self] selectedUsers, error in
  if let error = error {
        print(error)
    }
    else {
        print("selectFriend(params:) success.")
        
        // Implement actions on success
        _ = selectedUsers 
    }
}
// Class member property
let disposeBag = DisposeBag()

let openPickerFriendRequestParams = OpenPickerFriendRequestParams(
    title: "Single picker", // Name of the picker
    viewAppearance: .auto, // Display type
    orientation: .auto, // Orientation of the picker
    enableSearch: true, // Enables the search function
    enableIndex: true, // Enables the index view
    showFavorite: true // Marks on favorite friends
)

PickerApi.shared.rx.selectFriend(params: openPickerFriendRequestParams, viewType: .popup, enableMulti: false))
    .subscribe (onNext:{ (selectedUsers) in
        print("selectFriend(params:) success.")

        // Implement actions on success
        _ = selectedUsers 

    }, onError: {error in
        print(error)
    })
    .disposed(by: disposeBag) 
// Class member property
let disposeBag = DisposeBag()

let openPickerFriendRequestParams = OpenPickerFriendRequestParams(
    title: "Multi-picker", // Name of the picker
    viewAppearance: .auto, // Display type
    orientation: .auto, // Orientation of the picker
    enableSearch: true, // Enables the search function
    enableIndex: true, // Enables the index view
    showFavorite: true, // Marks on favorite friends
    showPickedFriend: true, // Displays selected friends for multi-picker
    maxPickableCount: 5, // Maximum pickable count
    minPickableCount: 1 // Minimum pickable count
)

PickerApi.shared.rx.selectFriend(params: openPickerFriendRequestParams, viewType: .popup, enableMulti: true))
    .subscribe (onNext:{ (selectedUsers) in
        print("selectFriend(params:) success.")

        // Implement actions on success
        _ = selectedUsers 

    }, onError: {error in
        print(error)
    })
    .disposed(by: disposeBag)

Retrieve list of friends

Basic information
Reference App setting
[SDK, RxSDK] friends()
[SDK] Friends
Install
Import modules
Initialize
Permission Prerequisite Kakao Login User consent
Required Register platforms
Activate Kakao Login
Manage consent items
Required Required:
Friends List in Kakao Service (Including profile image, nickname, and favorites)

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.

Request

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.

Response

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.

Sample

Swift
RxSwift
TalkApi.shared.friends {(friends, error) in
    if let error = error {
        print(error)
    }
    else {
        // Implement service logics
        _ = friends        
    }
}
// Class member property
let disposeBag = DisposeBag()

TalkApi.shared.rx.friends()
    .retry(when: Auth.shared.rx.incrementalAuthorizationRequired())
    .subscribe (onSuccess:{ (friends) in
        // Implement service logics
        _ = friends        
        
    }, onFailure: {error in
        print(error)
    })
    .disposed(by: disposeBag)

Additional feature

Paging

To retrieve the response in the page format, use FriendsContext. FriendsContext includes same paramaeters. When the number of Kakao Talk friends is more than the specified value or default value(100), the response will be returned in the page format. After the first page, use FriendsContext to retrieve the second page.