This document describes how to integrate Kakao Talk Share APIs into your service with the Kakao SDK for Flutter ("Flutter SDK").
Kakao Developers provides two types of message sending features: Kakao Talk Share and Kakao Talk Message. Select the feature to use by referring to Message sending features. If you want to use Kakao Talk Share, check the content after Step 2.
Decide which message template to use by referring to Template types.
Decide how to configure a message by referring to Configuration method comparison. You can configure a message in object format based on predefined default templates or use custom templates configured directly for your service.
Kakao Talk Share basically provides functionality to share messages through Kakao Talk, but it also supports web sharing functionality, so it can be used regardless of whether Kakao Talk is installed on the device.
Kakao Talk installation status | Message sharing method |
---|---|
Installed | Kakao Talk message transmission available Operation sequence: 1. Generate a Uri to launch the Kakao Talk Share screen by referring to each functionality development guide2. Execute the Uri using ShareClient 's launchKakaoTalk() method to display the share screen in Kakao Talk |
Not installed | Web sharing functionality message transmission available Operation sequence: 1. Generate a Uri to execute web sharing functionality by referring to each functionality development guide2. Display the share screen on the web using the launchBrowserTab() method |
If you want to support sharing only through Kakao Talk according to your service needs, you can check whether Kakao Talk execution is possible using ShareClient
's isKakaoTalkSharingAvailable()
. The meaning of the method call result is as follows.
true
: One of the followingfalse
To support Kakao Talk Share on devices where Kakao Talk is not installed or in web browser environments, use the web sharing functionality. Refer to the example below.
bool isKakaoTalkSharingAvailable = await ShareClient.instance.isKakaoTalkSharingAvailable();
if (isKakaoTalkSharingAvailable) {
print('Sharing through Kakao Talk available');
} else {
print('Kakao Talk not installed: Web sharing functionality recommended');
}
No value is returned when Kakao Talk Share is completed, and transmission success can be checked through Kakao Talk Share webhook.
To use Kakao Talk Share APIs in native app services, you need to set up Custom URL Scheme. Refer to the device environment-specific project configuration methods below.
Reference | App setting |
---|---|
shareDefault() makeDefaultUrl() SharingResult |
Install Initialize |
Permission | Prerequisite | Kakao Login | Consent items |
---|---|---|---|
- | Register platforms | - | - |
This API enables you to share messages through Kakao Talk using predefined default templates.
isKakaoTalkSharingAvailable()
to check if Kakao Talk is installed on the user's device.ShareClient
's shareDefault()
. When the request is successful, a Uri
is returned that allows you to navigate to the screen for sharing messages with default templates in Kakao Talk. Execute sharing by calling ShareClient
's launchKakaoTalk()
method with the returned Uri
.WebSharerClient
's makeDefaultUrl()
. When the request is successful, a Uri
is returned that executes web sharing functionality. Execute sharing by calling the launchBrowserTab()
method with the returned Uri
. In web environments, you can open the Kakao Talk Share page as a popup by setting the popupOpen
parameter value to true
when calling launchBrowserTab()
.DefaultTemplate
interface, then use one of the classes below according to the desired template type to configure template objects.FeedTemplate
ListTemplate
LocationTemplate
CommerceTemplate
TextTemplate
CalendarTemplate
shareDefault()
or makeDefaultUrl()
, pass the previously configured template object as the template
parameter.// Check if Kakao Talk execution is available
bool isKakaoTalkSharingAvailable = await ShareClient.instance.isKakaoTalkSharingAvailable();
if (isKakaoTalkSharingAvailable) {
try {
Uri uri =
await ShareClient.instance.shareDefault(template: defaultFeed);
await ShareClient.instance.launchKakaoTalk(uri);
print('Kakao Talk Share completed');
} catch (error) {
print('Kakao Talk Share failed $error');
}
} else {
try {
Uri shareUrl = await WebSharerClient.instance
.makeDefaultUrl(template: defaultFeed);
await launchBrowserTab(shareUrl, popupOpen: true);
} catch (error) {
print('Kakao Talk Share failed $error');
}
}
Reference | App setting |
---|---|
shareCustom() makeCustomUrl() SharingResult |
Install Initialize |
Permission | Prerequisite | Kakao Login | Consent items |
---|---|---|---|
- | Register platforms Message template |
- | - |
This API enables you to customize a template in [Tools] > [Message Template] and send a message through Kakao Talk. For message configuration methods, refer to Custom template.
isKakaoTalkSharingAvailable()
to check if Kakao Talk is installed on the user's device.ShareClient
's shareCustom()
. When the request is successful, a Uri
is returned that allows you to navigate to the screen for sharing messages with default templates in Kakao Talk. Execute sharing by calling ShareClient
's launchKakaoTalk()
method with the returned Uri
.WebSharerClient
's makeCustomUrl()
. When the request is successful, a Uri
is returned that executes web sharing functionality. Execute sharing by calling the launchBrowserTab()
method with the returned Uri
. In web environments, you can open the Kakao Talk Share page as a popup by setting the popupOpen
parameter value to true
when calling launchBrowserTab()
.shareCustom()
or makeCustomUrl()
, pass the template ID configured in the message template tool as the templateId
parameter.templateArgs
parameter. If you do not use this parameter even though the custom template includes user arguments, the part specified as user arguments will be exposed in the message as ${KEY}
format.// Custom template ID
int templateId = '${YOUR_CUSTOM_TEMPLATE_ID}';
// Check if Kakao Talk execution is available
bool isKakaoTalkSharingAvailable = await ShareClient.instance.isKakaoTalkSharingAvailable();
if (isKakaoTalkSharingAvailable) {
try {
Uri uri =
await ShareClient.instance.shareCustom(templateId: templateId);
await ShareClient.instance.launchKakaoTalk(uri);
print('Kakao Talk Share completed');
} catch (error) {
print('Kakao Talk Share failed $error');
}
} else {
try {
Uri shareUrl = await WebSharerClient.instance.makeCustomUrl(
templateId: templateId, templateArgs: {'key1': 'value1'});
await launchBrowserTab(shareUrl, popupOpen: true);
} catch (error) {
print('Kakao Talk Share failed $error');
}
}
Reference | App setting |
---|---|
shareScrap() makeScrapUrl() SharingResult |
Install Initialize |
Permission | Prerequisite | Kakao Login | Consent items |
---|---|---|---|
- | Register platforms | - | - |
This API enables you to share a Kakao Talk message by scraping the specified web page and configuring a scrap message with the scraped information.
isKakaoTalkSharingAvailable()
to check if Kakao Talk is installed on the user's device.ShareClient
's shareScrap()
. When the request is successful, a Uri
is returned that allows you to navigate to the screen for sharing messages with default templates in Kakao Talk. Execute sharing by calling ShareClient
's launchKakaoTalk()
method with the returned Uri
.WebSharerClient
's makeScrapUrl()
. When the request is successful, a Uri
is returned that executes web sharing functionality. Execute sharing by calling the launchBrowserTab()
method with the returned Uri
. In web environments, you can open the Kakao Talk Share page as a popup by setting the popupOpen
parameter value to true
when calling launchBrowserTab()
.shareScrap()
or makeScrapUrl()
, you must pass the URL of the web page to be scraped as the url
parameter. The domain of the web page to be scraped must be registered in [App] > [General] > [Platform] > [Web] on the app management page.templateId
parameter. For template configuration methods, refer to Custom template. To include variable information in messages, use user arguments. In this case, you must pass keys and values as the templateArgs
parameter.// Web page URL to be scraped
String url = "https://developers.kakao.com";
// Check if Kakao Talk execution is available
bool isKakaoTalkSharingAvailable = await ShareClient.instance.isKakaoTalkSharingAvailable();
if (isKakaoTalkSharingAvailable) {
try {
Uri uri = await ShareClient.instance.shareScrap(url: url);
await ShareClient.instance.launchKakaoTalk(uri);
print('Kakao Talk Share completed');
} catch (error) {
print('Kakao Talk Share failed $error');
}
} else {
try {
Uri shareUrl = await WebSharerClient.instance
.makeScrapUrl(url: url, templateArgs: {'key1': 'value1'});
await launchBrowserTab(shareUrl, popupOpen: true);
} catch (error) {
print('Kakao Talk Share failed $error');
}
}
// Custom template ID
int templateId = '${YOUR_CUSTOM_TEMPLATE_ID}';
// Web page URL to be scraped
String url = "https://developers.kakao.com";
// Check if Kakao Talk execution is available
bool isKakaoTalkSharingAvailable = await ShareClient.instance.isKakaoTalkSharingAvailable();
if (isKakaoTalkSharingAvailable) {
try {
Uri uri = await ShareClient.instance.shareScrap(url: url, templateId: templateId);
await ShareClient.instance.launchKakaoTalk(uri);
print('Kakao Talk Share completed');
} catch (error) {
print('Kakao Talk Share failed $error');
}
} else {
try {
Uri shareUrl = await WebSharerClient.instance
.makeScrapUrl(url: url, templateId: templateId, templateArgs: {'key1': 'value1'});
await launchBrowserTab(shareUrl, popupOpen: true);
} catch (error) {
print('Kakao Talk Share failed $error');
}
}
Kakao Talk Share webhook is a function to send a webhook request to the URL specified on Kakao Developers when a Kakao Talk Share message is successfully sent to friends or a chatroom selected by a user.
Kakao Talk Share webhook can only be used when sending Kakao Talk Share messages and is not supported for Kakao Talk Message transmission. Kakao Talk Share is sent by users through Kakao Talk, so services cannot directly confirm whether the message was sent successfully. Therefore, a webhook function is provided to notify when message transmission is successful.
To use this feature, you need to:
The Kakao Talk Share webhook sent to your service server does not include detailed message transmission information. To figure out additional information needed by the service, such as which message's transmission result it is and what content the user shared, you must use custom (Custom) parameters. Also, Kakao Talk Share messages without custom parameters will not deliver Kakao Talk Share webhooks.
Custom parameters must be passed as the serverCallbackArgs
parameter when making Kakao Talk Share requests, and you cannot use system reserved words CHAT_TYPE
, HASH_CHAT_ID
, and TEMPLATE_ID
as keys. These keys are included in the notification with the values defined in the specification of Kakao Talk Share webhook.
Below is an example of a Kakao Talk Share request including custom parameters.
try {
// Pass custom parameters through serverCallbackArgs parameter
// If this parameter is not used, Kakao Talk Share webhook will not be delivered
Uri uri =
await ShareClient.instance.defaultTemplate(template: defaultFeed, serverCallbackArgs: {'key1': 'value1'});
await ShareClient.instance.launchKakaoTalk(uri);
print('Kakao Talk Share completed');
} catch (error) {
print('Kakao Talk Share failed $error');
}
Reference | App setting |
---|---|
uploadImage() scrapImage() ImageUploadResult ImageInfo |
Install Initialize |
Permission | Prerequisite | Kakao Login | Consent items |
---|---|---|---|
- | Register platforms | - | - |
You can attach images to a message by passing an image URL when configuring a message template or uploading images in the Message Template Tool in advance. Image files must be uploaded to the Kakao server or scraped to be used for message transmission.
You can upload or scrape images to the Kakao server using methods provided by ShareClient
. You can only upload images with a file size of 5 MB or less. The images uploaded to the Kakao server are stored for up to 100 days and automatically deleted after the period.
To upload an image file to the Kakao server, call uploadImage()
. Pass the image file to upload using one of the following parameters.
image
: Pass image as File
format to uploadbyteData
: Pass image as ByteData
format to uploadTo scrape an image on the web to the Kakao server, call scrapImage()
.
When the request is successful, an ImageUploadResult
object is returned. You can check the uploaded image information, such as the image URL to use for message transmission, from the ImageInfo
inside that object.
// Local image file
// This example uses an image file added as a project resource.
// Prepare photo files needed for your service, such as from gallery.
ByteData byteData = await rootBundle.load('assets/images/cat1.png');
// This example saves project resources as image files using path_provider.
File tempFile =
File('${(await getTemporaryDirectory()).path}/cat1.png');
File file = await tempFile.writeAsBytes(byteData.buffer
.asUint8List(byteData.offsetInBytes, byteData.lengthInBytes));
try {
// Upload to Kakao image server
ImageUploadResult imageUploadResult =
await ShareClient.instance.uploadImage(image: file);
print('Image upload successful'
'\n${imageUploadResult.infos.original}');
} catch (error) {
print('Image upload failed $error');
}
// This sample uses file_picker to get image files.
var filePickerResult = await FilePicker.platform.pickFiles();
if (filePickerResult != null) {
var byteData = filePickerResult.files.first.bytes;
try {
// Upload to Kakao image server
ImageUploadResult imageUploadResult =
await ShareClient.instance.uploadImage(byteData: byteData);
Log.i(context, tag,
'Image upload successful\n${imageUploadResult.infos.original}');
} catch (e) {
Log.e(context, tag, 'Image upload failed', e);
}
}
// Original image URL
String url =
'https://t1.kakaocdn.net/kakaocorp/Service/KakaoTalk/pc/slide/talkpc_theme_01.jpg';
try {
// Scrape image to Kakao server
ImageUploadResult imageUploadResult =
await ShareClient.instance.scrapImage(imageUrl: url);
print('Image scraping successful'
'\n${imageUploadResult.infos.original}');
} catch (error) {
print('Image scraping failed $error');
}
```