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

Kakao Talk Social

Flutter

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

Before using Kakao Talk Social APIs with the Flutter SDK,

  1. Complete the prerequisites.
  2. Implement Kakao Login for the token-based APIs. To obtain the tokens, a user also must be logged in with Kakao. For more information, refer to Concepts > Kakao Login.
  3. After adding kakao_flutter_sdk_talk and kakao_flutter_sdk_user in pubspec.yaml by referring to Install SDK, add the following libraries in your dart file.
import 'package:kakao_flutter_sdk_talk/kakao_flutter_sdk_talk.dart';
import 'package:kakao_flutter_sdk_user/kakao_flutter_sdk_user.dart';

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 'Profile' scope. Otherwise, an empty value is returned.
Sample
try {
  TalkProfile profile = await TalkApi.instance.profile();
  print('Succeeded in retrieving Kakao Talk profile.\nNickname: ${profile.nickname}\nProfile image: ${profile.thumbnailUrl}\nCountry code: ${profile.countryISO}');
} catch (error) {
  print('Failed to retrieve Kakao Talk profile. $error');
}
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 String Kakao Talk profile image URL with a size of 640x640 pixels.
Only HTTPS is supported.

Required user consent: Profile Info(nickname/profile image) or Profile image
X
thumbnailUrl String Kakao Talk profile thumbnail image URL with a size of 110x110 pixels.
Only HTTPS is supported.

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,

  • 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.

Implementation method for picker

The picker of the Flutter SDK has a different mechanism depending on the environment. Refer to the description and examples below.

  • Native app (Android, iOS)

    • Needs to pass BuildContext object (context) as an argument to the picker call function. Refer to the example.
  • Web

    • Supports pop-up and redirect methods.

See the below to check the difference between pop-up and redirect methods.

  • Pop-up method
    • The picker appears as the pop-up window.
    • The selected friends data is returned through Future.
    • Pop-up window-related settings are required when using Webview. See Set up for hybrid app.
  • Redirect method
    • The picker appears on the current window. 
    • The information about the selected friends is passed to the returnUrl of your service server as a query string through redirection (HTTP 302 Redirect).
    • For this, you must register the domain of returnUrl in [My Appliction] > [Platform] > [Web].

Depending on the selection type of the Friend picker, you need to use a different function.

Function type
Number of selectable friends Function to use
Only one friend (Single picker) selectFriend()
Multiple friends (Multi-picker) selectFriends()
Parameter
Name Type Description Required
title String Text to be displayed in the title area of the Friend picker.
(Default: "Select Friends")
X
enableSearch Boolean Whether to show the Search box for friends.
(Default: true)
X
showMyProfile Boolean Whether to show my profile.
It set to true, users can also select their own profile.
(Default: true)
X
showFavorite Boolean Whether to show the friends added as Favorite.
(Default: true)
X
showPickedFriend Boolean Only for the multi-picker.
Whether to show the selected friends.
(Default: true)
X
maxPickableCount Number 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 Number 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
returnUrl String Required when implementing with the Flutter web redirect method.
Service URL that the information of the selected friends are passed to.

IMPORTANT: Only allowed the domain registered in [My Appliction] > [Platform] > [Web].
X
enableBackButton Boolean Flutter web pop-up method is not available.
Whether to show the back (←) button.
- true: the Back button displayed.
- false: the Back button no displayed.
(Default: true)
X
Sample
Native App
// Parameter setting
var params = PickerFriendRequestParams(
    title: 'Multi-Picker',
    enableSearch: true,
    showMyProfile: true,
    showFavorite: true,
    showPickedFriend: null,
    maxPickableCount: null,
    minPickableCount: null,
    enableBackButton: true,
);

// Call the picker
try {
    SelectedUsers users = await PickerApi.instance.selectFriends(params: params, context: context);
    print('Success: ${users.users!.length}');
} catch(e) {
    print('Failure: $e');
}
Web: Redirect Method
// Parameter setting (redirect method)
PickerFriendRequestParams params = PickerFriendRequestParams(
    title: 'Multi-Picker',
    enableSearch: true,
    showMyProfile: true,
    showFavorite: true,
    showPickedFriend: null,
    maxPickableCount: null,
    minPickableCount: null,
    returnUrl: 'https://developers.kakao.com', // Essential
    enableBackButton: true,
);

// Call the picker
// Success: ${returnUrl}?selected=${SelectedUsers}
// Failure: ${returnUrl}?error=${Error}
await PickerApi.instance.selectFriends(params: params);
Web: Pop-up Method
// Parameter setting (pop-up method)
PickerFriendRequestParams params = PickerFriendRequestParams(
    title: 'Multi-Picker',
    enableSearch: true,
    showMyProfile: true,
    showFavorite: true,
    showPickedFriend: null,
    maxPickableCount: null,
    minPickableCount: null,
);

// Call the picker
try {
    SelectedUsers users = await PickerApi.instance.selectFriends(params: params);
    print('Success: ${users.users!.length}'):
} catch(e) {
    print('Failure: $e');
}
Response

If a user selects friends on the picker display, the information of the friends that a user selects from the Friend picker is returned through SelectedUsers. If the request failed or a problem occurred, refer to the Troubleshooting to check the cause.


SelectedUsers: Selected friends data
Name Type Description Required
selectedTotalCount Number 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. 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 String 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 String Friend's profile thumbnail image set in Kakao Talk. X
favorite Boolean Whether the friend is added as Favorite. X
Error

If the request is failed, error code and message are returned. To check its cause and solution, refer to Troubleshooting.

Name Type Description Required
code Number Error code. O
msg String Error message. O

Retrieve list of friends Login required Consent required

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 also must 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 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. Sort order is decided depending on the set value of order.
- nickname: sort by Kakao Talk nickname.
- 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
try {
  Friends friends = await TalkApi.instance.friends();
  print('Succeeded in retrieving a list of friends.\n${friends.elements?.map((error) => error.profileNickname).join('\n')}');
  // You can send a message to the friends using their UUIDs.
} catch (error) {
  print('Failed to retrieve a list of friends. $error');
}
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 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
id Int 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 String 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