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

Kakao Talk Social

Android

This document describes how to integrate Kakao Talk Social APIs into your service with the Kakao SDK for Android (hereinafter referred to as 'Android 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 Android Platform

To use the Android SDK, you must register the Android platform in advance. Go to [My Application] > [Platform] and register the Android platform by specifying its package name and key hashes.

Add modules

To use this API, you must add both v2-user (Kakao Login module) and v2-talk (Kakao Talk module that provides TalkApiClient in the module-level build.gradle file by referring to Add modules.

Implement Kakao Login

To use the Kakao Talk Social API,

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

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 TalkApiClient 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
Kotlin
RxKotlin
// Retrieve Kakao Talk profile
TalkApiClient.instance.profile { profile, error ->
    if (error != null) {
        Log.e(TAG, "Failed to retrieve Kakao Talk profile", error)
    }
    else if (profile != null) {
        Log.i(TAG, "Succeeded in retrieving Kakao Talk profile" +
                "\nNickname: ${profile.nickname}" +
                "\nProfile Thumbnail: ${profile.thumbnailUrl}"
    }
}
var disposables = CompositeDisposable()

// Retrieve Kakao Talk profile
TalkApiClient.rx.profile()
    .subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe({ profile ->
        Log.i(TAG, "Succeeded in retrieving Kakao Talk profile" +
                "\nNickname: ${profile.nickname}" +
                "\nProfile Thumbnail: ${profile.thumbnailUrl}" 
    }, { error ->
        Log.e(TAG, "Failed to retrieve Kakao Talk profile", error)
    }).addTo(disposables)
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 Understand Concepts.

TalkProfile
Name Type Description Required
nickname String Kakao Talk nickname.

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

Required user consent: Profile Info(nickname/profile image) or Profile image
X
thumbnailUrl String 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 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. To see the difference of profile information between Kakao Talk and Kakao Account, refer to Understand 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 TalkApiClient 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 Search direction for pages.
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
Kotlin
RxKotlin
// Retrieve a list of friends (Default)
TalkApiClient.instance.friends { friends, error ->
    if (error != null) {
        Log.e(TAG, "Failed to retrieve a list of friends.", error)
    }
    else if (friends != null) {
        Log.i(TAG, "Succeeded in retrieving a list of friends. \n${friends.elements.joinToString("\n")}")

        // You can send a message to the friends using their UUIDs.
    }
}
var disposables = CompositeDisposable()

// Retrieve a list of friends (Default)
TalkApiClient.rx.friends()
    .retryWhen(
        // Retry the request the list of friends after requesting additional consent to the consent item that the InsufficientScope error occurs. 
        RxAuthOperations.instance.incrementalAuthorizationRequired(context)
    )
    .subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe({ friends ->
        Log.i(TAG, "Succeeded in retrieving a list of friends \n${friends.elements.joinToString("\n")}")

        // You can send a message to the friends using their UUIDs.
    }, { error ->
        Log.e(TAG, "Failed to retrieve a list of friends.", error)
    })
    .addTo(disposables)
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 in Kakao Service(Including profile image, nickname, and favorites) scope, 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)'.
Friends
Name Type Description Required
elements List<Friend> List of Kakao Talk profile information of each friend. X
totalCount Int Total number of Kakao Talk friends. O
beforeUrl String Previous page URL.
If there is no previous page, null is returned.
X
afterUrl String Next page URL.
If there is no next page, null is returned.
X
favoriteCount Int Number of friends added as favorite. X
Friend
Name Type Description Required
uuid String User's unique ID.
Used when sending a Kakao Talk message.
Do not use this value to identify users since this value may change depending on user's account status.
O
id Int Service user ID. X
profileNickname String Friend's profile nickname. X
profileThumbnailImage String Friend's profile thumbnail image. X
favorite Boolean 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.

Legacy

To see how to integrate Kakao Talk Social using the Legacy Kakao SDK for Android, click this button. It is highly recommended to migrate to the new version of Android SDK as soon as possible because the Legacy version may not be supported anymore. The Legacy guide is not provided in the English version. Refer to the original Korean documentation.

See more