사이드 메뉴
Getting started
Kakao Developers
Login
Communication
Advertisement
- Concepts
- Ad creation: Ad account
- Ad creation: Campaign
- Ad creation: Ad group
- Targeting for ad group
- Custom audience targeting for ad group
- Ad creation: Creative common
- Ad creation: Display creative
- Ad creation: Message creative
- Ad creation: Personalized message creative
- Bizboard landing settings
- Report
- Message management
- Personalized message management
- Message ad management
- Message ad operation
- Ad View management
- Business Form linkage management
- Pixel & SDK linkage management
- Audience management
- Engagement targeting management
- Customer file management
- Friend group management
- Ad account management
- Reference
- Type information
- Error code
Android
This document describes how to integrate Kakao Talk Share APIs into your service with the Kakao SDK for Android ("Android SDK").
This setting is only required when using Android SDK versions below 2.4.0. In Android 11, package query and interaction settings are required to send messages to Kakao Talk. If your app targets Android 11, you must add the queries element to AndroidManifest.xml as shown below. For details, see Package visibility in Android 11.
<manifest package="com.example.sample"><!--Add Kakao Talk package to queries--><queries><package android:name="com.kakao.talk" /></queries>...</manifest>
1. Select message sending feature
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.
2. Select message type and configuration method
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.
3. Send a message
Call the message sending API. If the request is successful, the Android SDK launches Kakao Talk or lets a user log in with Kakao Account on a web page, and then shows a list of friends or chatrooms. When a user selects friends or a chatroom to send the message to, the messages are sent to the selected targets.
No value is returned when Kakao Talk Share is completed, and transmission success can be checked through Kakao Talk Share webhook.
To make your app launch when a user clicks a button in the Kakao Talk Share message, you need to set AndroidManifest.xml file with custom URL scheme (Custom URL Scheme). For apps targeting Android 12 (API 31) or higher, the exported element must be declared as true. See the example below.
<activityandroid:name=".${YOUR_ACTIVITY_NAME}"android:exported="true"><intent-filter><action android:name="android.intent.action.VIEW" /><category android:name="android.intent.category.DEFAULT" /><category android:name="android.intent.category.BROWSABLE" /><!--Used to set app execution scheme in the format "kakao${YOUR_NATIVE_APP_KEY}://kakaolink"--><data android:host="kakaolink"android:scheme="kakao${YOUR_NATIVE_APP_KEY}" /></intent-filter></activity>
For native apps, you can pass additional information according to service needs when launching the app through custom URL scheme. You can set keys and values to pass when launching the app using androidExecutionParams and iosExecutionParams parameters. When using these parameters, clicking the app execution button in Kakao Talk Share message calls the following scheme.
kakao${YOUR_NATIVE_APP_KEY}://kakaolink?${androidExecutionParams}kakao${YOUR_NATIVE_APP_KEY}://kakaolink?${iosExecutionParams}// Examplekakao${YOUR_NATIVE_APP_KEY}://kakaolink?key1=value1&key2=value2&key3=value3
| Reference | App setting |
|---|---|
[SDK, RxSDK] shareDefault()[SDK] isKakaoTalkSharingAvailable()[SDK] makeDefaultUrl()[SDK] SharingResult | Install Initialize |
| Permission | Prerequisite | Kakao Login | Consent items |
|---|---|---|---|
| - | Native app key Product Link | - | - |
Shares messages through Kakao Talk using predefined default templates.
- Check if Kakao Talk is installed: To check if it is possible to share a message through Kakao Talk, first call
isKakaoTalkSharingAvailable()to check if Kakao Talk is installed on the user's device.- If Kakao Talk is installed: Call
shareDefault()to receive aSharingResultobject. Use theintentof that object to launch an activity and implement sharing the message through Kakao Talk. - If Kakao Talk is not installed: Generate a web sharing URL using
makeDefaultUrl()inWebSharerClient, then implement to open that URL in a default browser or webview.
- If Kakao Talk is installed: Call
- Configure message template: For message creation, implement the
DefaultTemplateinterface, then use one of the classes below according to the desired template type to configure template objects.- Feed template:
FeedTemplate - List template:
ListTemplate - Location template:
LocationTemplate - Commerce template:
CommerceTemplate - Text template:
TextTemplate - Calendar template:
CalendarTemplate
- Feed template:
- Pass template object: When calling
shareDefault()ormakeDefaultUrl(), pass the previously configured template object as thedefaultTemplateparameter.
// Send feed message// Check if Kakao Talk is installedif (ShareClient.instance.isKakaoTalkSharingAvailable(context)) {// Kakao Talk Share is availableShareClient.instance.shareDefault(context = context,defaultTemplate = defaultFeed,) { sharingResult, error ->if (error != null) {Log.e(TAG, "Kakao Talk Share failed", error)}else if (sharingResult != null) {Log.d(TAG, "Kakao Talk Share success ${sharingResult.intent}")startActivity(sharingResult.intent)// Even if Kakao Talk Share succeeds, if the warning messages below exist, some content may not work properly.Log.w(TAG, "Warning Msg: ${sharingResult.warningMsg}")Log.w(TAG, "Argument Msg: ${sharingResult.argumentMsg}")}}} else {// Kakao Talk not installed: Use web sharing// Web sharing example codeval sharerUrl = WebSharerClient.instance.makeDefaultUrl(defaultFeed)// Open web browser with CustomTabs// 1. Open browser supporting CustomTabsServiceConnection// ex) Chrome, Samsung Internet, FireFox, Whale, etc.try {KakaoCustomTabsClient.openWithDefault(context, sharerUrl)} catch(e: UnsupportedOperationException) {// Exception handling when no browser supports CustomTabsServiceConnection}// 2. Open browser not supporting CustomTabsServiceConnection// ex) Daum, Naver, etc.try {KakaoCustomTabsClient.open(context, sharerUrl)} catch (e: ActivityNotFoundException) {// Exception handling when no internet browser is installed on the device}}
| Reference | App setting |
|---|---|
[SDK, RxSDK] shareCustom()[SDK] isKakaoTalkSharingAvailable()[SDK] SharingResult[SDK] makeCustomUrl() | Install Initialize |
Shares messages through Kakao Talk using custom templates configured in [Tools] > [Message Template].
- Check if Kakao Talk is installed: To check if it is possible to share a message through Kakao Talk, first call
isKakaoTalkSharingAvailable()to check if Kakao Talk is installed on the user's device.- If Kakao Talk is installed: Call
shareCustom()to receive aSharingResultobject. Use theintentof that object to launch an activity and implement sharing the message through Kakao Talk. - If Kakao Talk is not installed: Generate a web sharing URL using
makeCustomUrl(), then implement to open that URL in a default browser or webview.
- If Kakao Talk is installed: Call
- Configure message template: Configure the message template in [Tools] > [Message Template]. For template configuration methods, refer to Custom template.
- Specify template: When calling
shareCustom()ormakeCustomUrl(), pass the template ID configured in the message template tool as thetemplateIdparameter. - Pass user arguments (optional): To include variable information in a message, add user arguments to the custom template, then pass key-value pairs to the
templateArgsparameter. For detailed usage and precautions, see Directly inputting user arguments.
// Template ID created in [Tools] > [Message Template]val templateId = templateIds["customMemo"] as Long// Check if Kakao Talk is installedif (ShareClient.instance.isKakaoTalkSharingAvailable(context)) {// Kakao Talk Share is availableShareClient.instance.shareCustom(context = context,templateId = templateId,) { sharingResult, error ->if (error != null) {Log.e(TAG, "Kakao Talk Share failed", error)}else if (sharingResult != null) {Log.d(TAG, "Kakao Talk Share success ${sharingResult.intent}")startActivity(sharingResult.intent)// Even if Kakao Talk Share succeeds, if the warning messages below exist, some content may not work properly.Log.w(TAG, "Warning Msg: ${sharingResult.warningMsg}")Log.w(TAG, "Argument Msg: ${sharingResult.argumentMsg}")}}} else {// Kakao Talk not installed: Use web sharing// Web sharing example codeval sharerUrl = WebSharerClient.instance.makeCustomUrl(templateId)// Open web browser with CustomTabs// 1. Open browser supporting CustomTabsServiceConnection// ex) Chrome, Samsung Internet, FireFox, Whale, etc.try {KakaoCustomTabsClient.openWithDefault(context, sharerUrl)} catch(e: UnsupportedOperationException) {// Exception handling when no browser supports CustomTabsServiceConnection}// 2. Open browser not supporting CustomTabsServiceConnection// ex) Daum, Naver, etc.try {KakaoCustomTabsClient.open(context, sharerUrl)} catch (e: ActivityNotFoundException) {// Exception handling when no internet browser is installed on the device}}
| Reference | App setting |
|---|---|
[SDK, RxSDK] shareScrap()[SDK] isKakaoTalkSharingAvailable()[SDK] makeScrapUrl()[SDK] SharingResult | Install Initialize |
| Permission | Prerequisite | Kakao Login | Consent items |
|---|---|---|---|
| - | Native app key Product Link | - | - |
Shares messages through Kakao Talk by configuring a scrap message with information from a specified web page.
- Check if Kakao Talk is installed: To check if it is possible to share a message through Kakao Talk, first call
isKakaoTalkSharingAvailable()to check if Kakao Talk is installed on the user's device.- If Kakao Talk is installed: Call
shareScrap()to receive aSharingResultobject. Use theintentof that object to launch an activity and implement sharing the message through Kakao Talk. - If Kakao Talk is not installed: Generate a web sharing URL using
makeScrapUrl()inWebSharerClient, then implement to open that URL in a default browser or webview.
- If Kakao Talk is installed: Call
- Specify web page URL for scraping: When calling
shareScrap()ormakeScrapUrl(), you must pass the URL of the web page to be scraped as theurlparameter. The domain of the web page to be scraped must be registered in [App] > [Product Link] > [Web domain] on the app management page. - Apply custom template (optional): If you want to send scrape messages based on service-defined message templates, you must pass the ID of the template configured in [Tools] > [Message Template] as the
templateIdparameter. For template configuration methods, refer to Custom template. - Pass user arguments (optional): To include variable information in a message, add user arguments to the custom template, then pass key-value pairs to the
templateArgsparameter. For detailed usage and precautions, see Directly inputting user arguments.
// Web page URL to share// * Note: The domain of the URL to share must be registered in the [Product Link] on the developer site.val url = "https://developers.kakao.com"// Check if Kakao Talk is installedif (ShareClient.instance.isKakaoTalkSharingAvailable(context)) {// Kakao Talk Share is availableShareClient.instance.shareScrap(context = context,url = url,) { sharingResult, error ->if (error != null) {Log.e(TAG, "Kakao Talk Share failed", error)}else if (sharingResult != null) {Log.d(TAG, "Kakao Talk Share success ${sharingResult.intent}")startActivity(sharingResult.intent)// Even if Kakao Talk Share succeeds, if the warning messages below exist, some content may not work properly.Log.w(TAG, "Warning Msg: ${sharingResult.warningMsg}")Log.w(TAG, "Argument Msg: ${sharingResult.argumentMsg}")}}} else {// Kakao Talk not installed: Use web sharing// Web sharing example codeval sharerUrl = WebSharerClient.instance.makeScrapUrl(url)// Open web browser with CustomTabs// 1. Open browser supporting CustomTabsServiceConnection// ex) Chrome, Samsung Internet, FireFox, Whale, etc.try {KakaoCustomTabsClient.openWithDefault(context, sharerUrl)} catch(e: UnsupportedOperationException) {// Exception handling when no browser supports CustomTabsServiceConnection}// 2. Open browser not supporting CustomTabsServiceConnection// ex) Daum, Naver, etc.try {KakaoCustomTabsClient.open(context, sharerUrl)} catch (e: ActivityNotFoundException) {// Exception handling when no internet browser is installed on the device}}
// Web page URL to share// * Note: The domain of the URL to share must be registered in the [Product Link] on the developer site.val url = "https://developers.kakao.com"val templateId = templateIds["customMemo"] as Long// Check if Kakao Talk is installedif (ShareClient.instance.isKakaoTalkSharingAvailable(context)) {// Kakao Talk Share is availableShareClient.instance.shareScrap(context = context,url = url,templateId = templateId,) { sharingResult, error ->if (error != null) {Log.e(TAG, "Kakao Talk Share failed", error)}else if (sharingResult != null) {Log.d(TAG, "Kakao Talk Share success ${sharingResult.intent}")startActivity(sharingResult.intent)// Even if Kakao Talk Share succeeds, if the warning messages below exist, some content may not work properly.Log.w(TAG, "Warning Msg: ${sharingResult.warningMsg}")Log.w(TAG, "Argument Msg: ${sharingResult.argumentMsg}")}}} else {// Kakao Talk not installed: Use web sharing// Web sharing example codeval sharerUrl = WebSharerClient.instance.makeScrapUrl(url, templateId)// Open web browser with CustomTabs// 1. Open browser supporting CustomTabsServiceConnection// ex) Chrome, Samsung Internet, FireFox, Whale, etc.try {KakaoCustomTabsClient.openWithDefault(context, sharerUrl)} catch(e: UnsupportedOperationException) {// Exception handling when no browser supports CustomTabsServiceConnection}// 2. Open browser not supporting CustomTabsServiceConnection// ex) Daum, Naver, etc.try {KakaoCustomTabsClient.open(context, sharerUrl)} catch (e: ActivityNotFoundException) {// Exception handling when no internet browser is installed on the device}}
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. This function is only available for Kakao Talk Share API, not for Kakao Talk Message API. 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:
- Set the webhook URL and request method by referring to Prerequisites > Set Kakao Talk Share webhook.
- Build a server to receive a Kakao Talk Share webhook.
- Set a custom parameter to pass additional information when requesting the Kakao Talk Share API.
- Implement a process to handle the webhook delivered to your service server's webhook URL.
When your service server receives a Kakao Talk Share webhook, you can figure out additional information through the predefined custom parameters, such as what content the user has shared. The notification sent to the service server does not include detailed message transmission information, so you need to configure parameters with additional information needed by the service, such as which message's transmission result it is and what information the user shared. Even if you set up a Kakao Talk Share webhook in the app management page, the webhook will not be delivered if there are no custom parameters.
To use the Kakao Talk Share webhook function, you must specify a custom parameter through serverCallbackArgs. Otherwise, you cannot receive Kakao Talk Share webhooks even though you registered a webhook URL for Kakao Talk Share in [App] > [Webhook] > [Kakao Talk Share webhook] on the app management page. When your service server receives a Kakao Talk Share webhook, you can figure out additional information through the predefined custom parameters, such as what content the user has shared.
To pass additional information when requesting the Kakao Talk Share API, declare serverCallbackArgs, and pass keys and values as a Map. You cannot use the system reserved words CHAT_TYPE, HASH_CHAT_ID and TEMPLATE_ID as keys for the serverCallbackArgs. The key is included in the notification with the value defined in the specification of Kakao Talk Share webhook.
Below is an example of setting Kakao Talk Share webhook parameters.
// Template ID created in [Tools] > [Message Template]val templateId = templateIds["customMemo"] as Long// Webhook parameter settingsval serverCallbackArgs = mapOf(templateId to "templateId")// Check if Kakao Talk is installedif (ShareClient.instance.isKakaoTalkSharingAvailable(context)) {// Kakao Talk Share is availableShareClient.instance.shareCustom(context = context,templateId = templateId,serverCallbackArgs = serverCallbackArgs,) { sharingResult, error ->if (error != null) {Log.e(TAG, "Kakao Talk Share failed", error)}else if (sharingResult != null) {Log.d(TAG, "Kakao Talk Share success ${sharingResult.intent}")startActivity(sharingResult.intent)// Even if Kakao Talk Share succeeds, if the warning messages below exist, some content may not work properly.Log.w(TAG, "Warning Msg: ${sharingResult.warningMsg}")Log.w(TAG, "Argument Msg: ${sharingResult.argumentMsg}")}}} else {// Kakao Talk not installed: Use web sharing// Web sharing example codeval sharerUrl = WebSharerClient.instance.makeCustomUrl(templateId, serverCallbackArgs)// Open web browser with CustomTabs// 1. Open browser supporting CustomTabsServiceConnection// ex) Chrome, Samsung Internet, FireFox, Whale, etc.try {KakaoCustomTabsClient.openWithDefault(context, sharerUrl)} catch(e: UnsupportedOperationException) {// Exception handling when no browser supports CustomTabsServiceConnection}// 2. Open browser not supporting CustomTabsServiceConnection// ex) Daum, Naver, etc.try {KakaoCustomTabsClient.open(context, sharerUrl)} catch (e: ActivityNotFoundException) {// Exception handling when no internet browser is installed on the device}}
The parameters set above are passed to the notification sent to the service server's webhook URL in the form of request parameters. For the Kakao Talk Share webhook request details sent by Kakao, see Kakao Talk Share webhook.
| Reference | App setting |
|---|---|
[SDK, RxSDK] uploadImage()[SDK, RxSDK] scrapImage()[SDK] ImageUploadResult | Install Initialize |
| Permission | Prerequisite | Kakao Login | Consent items |
|---|---|---|---|
| - | Native app key | - | - |
Uploads image files to the Kakao server or scrapes image URLs.
To add an image to a Kakao Talk message, you must use the URL issued after uploading the image file to the Kakao server. If you are using a custom template, you can also upload the image through the Message Template Tool.
- Image file size: up to 5 MB.
- Image storage period: stored on the Kakao server for up to 100 days, then automatically deleted.
// Upload image// Local image file// In this example, we used an image file added as a project resource.// Prepare photo files needed for your service, such as from gallery.val bitmap = BitmapFactory.decodeResource(resources, R.drawable.sample1)val file = File(context.cacheDir, "sample1.png")val stream = FileOutputStream(file)bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream)stream.close()// Upload to Kakao image serverShareClient.instance.uploadImage(file) { imageUploadResult, error ->if (error != null) {Log.e(TAG, "Image upload failed", error)}else if (imageUploadResult != null) {Log.i(TAG, "Image upload success \n${imageUploadResult.infos.original}")}}
// Scrape image// Original remote image URLval url = "https://t1.kakaocdn.net/kakaocorp/Service/KakaoTalk/pc/slide/talkpc_theme_01.jpg"// Upload to Kakao image serverShareClient.instance.scrapImage(url) { imageUploadResult, error ->if (error != null) {Log.e(TAG, "Image scraping failed", error)}else if (imageUploadResult != null) {Log.i(TAG, "Image scraping success \n${imageUploadResult.infos.original}")}}