This document describes how to integrate Kakao Talk Social APIs into your service with the Kakao SDK for Android ("Android SDK").
Reference | App setting |
---|---|
[SDK, RxSDK] profile() [SDK] TalkProfile |
Install 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.
Call profile()
.
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 REST API.
// 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)
Reference | App setting |
---|---|
[SDK, RxSDK] selectFriend() [SDK, RxSDK] selectFriends() [SDK, RxSDK] selectFriendPopup() [SDK, RxSDK] selectFriendsPopup() [SDK] SelectedUsers |
Install 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.
Depending on the selection type and display format of the Friend picker, you need to use a different method.
Display format | Selection type | Method to use |
---|---|---|
Full screen | Single picker | selectFriend() |
Full screen | Multi-picker | selectFriends() |
Popup | Single picker | selectFriendPopup() |
Popup | Multi-picker | selectFriendsPopup() |
The components can be set by parameters.
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.
val openPickerFriendRequestParams = OpenPickerFriendRequestParams(
title = "Single picker", // Name of the picker
viewAppearance = ViewAppearance.AUTO, // Display type
orientation = PickerOrientation.AUTO, // Orientation of the picker
enableSearch = true, // Enables the search function
enableIndex = true, // Enables the index view
showFavorite = true, // Marks on favorite friends
)
PickerClient.instance.selectFriend(
context = context!!,
params = openPickerFriendRequestParams
) { selectedUsers, error ->
if (error != null) {
Log.e(TAG, "Failed to retrieve the selected friend through the picker.", error)
} else {
Log.d(TAG, "Succeeded in retrieving the selected friend through the picker. $selectedUsers")
}
}
val openPickerFriendRequestParams = OpenPickerFriendRequestParams(
title = "Multi-picker", // Name of the picker
viewAppearance = ViewAppearance.AUTO, // Display type
orientation = PickerOrientation.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
)
PickerClient.instance.selectFriends(
context = context!!,
params = openPickerFriendRequestParams
) { selectedUsers, error ->
if (error != null) {
Log.e(TAG, "Failed to retrieve the selected friend(s) through the picker.", error)
} else {
Log.d(TAG, "Succeeded in retrieving the selected friend(s) through the picker. $selectedUsers")
}
}
val openPickerFriendRequestParams = OpenPickerFriendRequestParams(
title = "Single picker", // Name of the picker
viewAppearance = ViewAppearance.AUTO, // Display type
orientation = PickerOrientation.AUTO, // Orientation of the picker
enableSearch = true, // Enables the search function
enableIndex = true, // Enables the index view
showFavorite = true, // Marks on favorite friends
)
PickerClient.rx.selectFriend(
context = context!!,
params = openPickerFriendRequestParams
).subscribe({ selectedUsers ->
Log.d(TAG, "Succeeded in retrieving the selected friend through the picker. $selectedUsers")
}, { error ->
Log.e(TAG, "Failed to retrieve the selected friend through the picker.", error)
}).addTo(disposables)
val openPickerFriendRequestParams = OpenPickerFriendRequestParams(
title = "Multi-picker", // Name of the picker
viewAppearance = ViewAppearance.AUTO, // Display type
orientation = PickerOrientation.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
)
PickerClient.rx.selectFriends(
context = context!!,
params = openPickerFriendRequestParams
).subscribe({ selectedUsers ->
Log.d(TAG, "Succeeded in retrieving the selected friend(s) through the picker. $selectedUsers")
}, { error ->
Log.e(TAG, "Failed to retrieve the selected friend(s) through the picker.", error)
}).addTo(disposables)
val openPickerFriendRequestParams = OpenPickerFriendRequestParams(
title = "Single picker", // Name of the picker
viewAppearance = ViewAppearance.AUTO, // Display type
orientation = PickerOrientation.AUTO, // Orientation of the picker
enableSearch = true, // Enables the search function
enableIndex = true, // Enables the index view
showFavorite = true, // Marks on favorite friends
)
PickerClient.instance.selectFriendPopup(
context = context!!,
params = openPickerFriendRequestParams
) { selectedUsers, error ->
if (error != null) {
Log.e(TAG, "Failed to retrieve the selected friend through the picker.", error)
} else {
Log.d(TAG, "Succeeded in retrieving the selected friend through the picker. $selectedUsers")
}
}
val openPickerFriendRequestParams = OpenPickerFriendRequestParams(
title = "Multi-picker", // Name of the picker
viewAppearance = ViewAppearance.AUTO, // Display type
orientation = PickerOrientation.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
)
PickerClient.instance.selectFriendsPopup(
context = context!!,
params = openPickerFriendRequestParams
) { selectedUsers, error ->
if (error != null) {
Log.e(TAG, "Failed to retrieve the selected friend(s) through the picker.", error)
} else {
Log.d(TAG, "Succeeded in retrieving the selected friend(s) through the picker. $selectedUsers")
}
}
val openPickerFriendRequestParams = OpenPickerFriendRequestParams(
title = "Single picker", // Name of the picker
viewAppearance = ViewAppearance.AUTO, // Display type
orientation = PickerOrientation.AUTO, // Orientation of the picker
enableSearch = true, // Enables the search function
enableIndex = true, // Enables the index view
showFavorite = true, // Marks on favorite friends
)
PickerClient.rx.selectFriendPopup(
context = context!!,
params = openPickerFriendRequestParams
).subscribe({ selectedUsers ->
Log.d(TAG, "Succeeded in retrieving the selected friend through the picker. $selectedUsers")
}, { error ->
Log.e(TAG, "Failed to retrieve the selected friend through the picker.", error)
}).addTo(disposables)
val openPickerFriendRequestParams = OpenPickerFriendRequestParams(
title = "Multi-picker", // Name of the picker
viewAppearance = ViewAppearance.AUTO, // Display type
orientation = PickerOrientation.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
)
PickerClient.rx.selectFriendsPopup(
context = context!!,
params = openPickerFriendRequestParams
).subscribe({ selectedUsers ->
Log.d(TAG, "Succeeded in retrieving the selected friend(s) through the picker. $selectedUsers")
}, { error ->
Log.e(TAG, "Failed to retrieve the selected friend(s) through the picker.", error)
}).addTo(disposables)
Reference | App setting |
---|---|
[SDK, RxSDK] friends() [SDK] Friends |
Install 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.
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.
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:
// 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)