페이지 이동경로
  • 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 Understand 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 (e) {
  print('Failed to retrieve Kakao Talk profile. $e');
}

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 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 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((e) => e.profileNickname).join('\n')}');
  // You can send a message to the friends using their UUIDs.
} catch (e) {
  print('Failed to retrieve a list of friends.');
}

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
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 since 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