사이드 메뉴
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
iOS
This document describes how to integrate Kakao Talk Share APIs into your service with the Kakao SDK for iOS ("iOS SDK").
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 a 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 iOS 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 App execution allowlist. When using Kakao Talk Share and Kakao Talk Message, you need "kakaolink" value in the LSApplicationQueriesSchemes setting. This setting is used to create a custom URL scheme (Custom URL Scheme) in the form of kakao${YOUR_NATIVE_APP_KEY}://kakaolink for app execution.
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 Import modules 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. Or refer to Advanced: Create a message using constructor to create atemplateObjectobject for use when sending messages.- 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 thetemplatableparameter.
//in ViewControllervar safariViewController : SFSafariViewController? // to keep instance//...guard let templatable = try? SdkJSONDecoder.custom.decode(FeedTemplate.self, from: feedTemplateJsonStringData) else {return}// Check if Kakao Talk has been installed.if ShareApi.isKakaoTalkSharingAvailable() {// Kakao Talk Share is available.// For 'templatable' examples, refer to the documentation: https://developers.kakao.com/docs/en/message-template/defaultShareApi.shared.shareDefault(templatable: templatable) {(sharingResult, error) inif let error = error {print(error)}else {print("shareDefault() success.")if let sharingResult = sharingResult {UIApplication.shared.open(sharingResult.url,options: [:], completionHandler: nil)}}}}else {// If Kakao Talk is not installed, it is recommended to share URI via web.// You can use custom webView or default browser.// Example of sharing URI via webif let url = ShareApi.shared.makeDefaultUrl(templatable: templatable) {self.safariViewController = SFSafariViewController(url: url)self.safariViewController?.modalTransitionStyle = .crossDissolveself.safariViewController?.modalPresentationStyle = .overCurrentContextself.present(self.safariViewController!, animated: true) {print("Web present success")}}}
| Reference | App setting |
|---|---|
[SDK, RxSDK] shareCustom()[SDK] isKakaoTalkSharingAvailable()[SDK] makeCustomUrl()[SDK] SharingResult | Install Import modules 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 therequestUrlof that object to open and share 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.
Calling shareCustom() launches the Kakao Talk application and shows the list of user's Kakao Talk friends or chatrooms. When a user selects friends or a chatroom to send the message to, the messages are sent to the selected targets.
shareCustom() returns SharingResult. Because the Kakao Talk Share API does not inform the result of message delivery, implement the Kakao Talk Share webhook function.
let templateId = 12345// Check if Kakao Talk has been installed.if ShareApi.isKakaoTalkSharingAvailable() {// Kakao Talk Share is available.ShareApi.shared.shareCustom(templateId: templateId,templateArgs:["title":"This is title.", "description":"This is description."]) {(sharingResult, error) inif let error = error {print(error)}else {print("shareCustom() success.")if let sharingResult = sharingResult {UIApplication.shared.open(sharingResult.url, options: [:], completionHandler: nil)}}}}else {// If Kakao Talk is not installed, it is recommended to share URI via web.// You can use custom webView or default browser.// Example of sharing URI via webif let url = ShareApi.shared.makeCustomUrl(templateId: templateId,templateArgs:["title":"This is title.", "description":"This is description."]) {self.safariViewController = SFSafariViewController(url: url)self.safariViewController?.modalTransitionStyle = .crossDissolveself.safariViewController?.modalPresentationStyle = .overCurrentContextself.present(self.safariViewController!, animated: true) {print("Web present success")}}}
| Reference | App setting |
|---|---|
[SDK, RxSDK] shareScrap()[SDK] isKakaoTalkSharingAvailable()[SDK] makeScrapUrl()[SDK] SharingResult | Install Import modules 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 therequestUrlparameter. 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.
let requestUrl = "https://developers.kakao.com"// Check if Kakao Talk has been installed.if ShareApi.isKakaoTalkSharingAvailable() {// Kakao Talk Share is available.ShareApi.shared.shareScrap(requestUrl: requestUrl) {(sharingResult, error) inif let error = error {print(error)}else {print("shareScrap() success.")if let sharingResult = sharingResult {UIApplication.shared.open(sharingResult.url, options: [:], completionHandler: nil)}}}}else {// If Kakao Talk is not installed, it is recommended to share URI via web.// You can use custom webView or default browser.// Example of sharing URI via webif let url = ShareApi.shared.makeScrapUrl(requestUrl: requestUrl) {self.safariViewController = SFSafariViewController(url: url)self.safariViewController?.modalTransitionStyle = .crossDissolveself.safariViewController?.modalPresentationStyle = .overCurrentContextself.present(self.safariViewController!, animated: true) {print("Web present success")}}}
let requestUrl = "https://developers.kakao.com"let templateId = 12345// Check if Kakao Talk has been installed.if ShareApi.isKakaoTalkSharingAvailable() {// Kakao Talk Share is available.ShareApi.shared.shareScrap(requestUrl: requestUrl,templateId: templateId) {(sharingResult, error) inif let error = error {print(error)}else {print("shareScrap() success.")if let sharingResult = sharingResult {UIApplication.shared.open(sharingResult.url, options: [:], completionHandler: nil)}}}}else {// If Kakao Talk is not installed, it is recommended to share URI via web.// You can use custom webView or default browser.// Example of sharing URI via webif let url = ShareApi.shared.makeScrapUrl(requestUrl: requestUrl,templateId: templateId) {self.safariViewController = SFSafariViewController(url: url)self.safariViewController?.modalTransitionStyle = .crossDissolveself.safariViewController?.modalPresentationStyle = .overCurrentContextself.present(self.safariViewController!, animated: true) {print("Web present success")}}}
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 Dictionary. 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 IDlet templateId = 12345;// Template Argumentslet templateArgs = ["title": "This is the title area.", "description": "This is the description area."]// Information to receive from server through webhooklet serverCallbackArgs = ["user_id": "abcd", "product_id": "1234"]// Check if Kakao Talk has been installed.if ShareApi.isKakaoTalkSharingAvailable() {// Kakao Talk Share is available.ShareApi.shared.shareCustom(templateId:templateId,templateArgs:templateArgs,serverCallbackArgs: serverCallbackArgs) { (sharingResult, error) inif let error = error {print(error)}else {print("shareCustom() success.")if let sharingResult = sharingResult {UIApplication.shared.open(sharingResult.url, options: [:], completionHandler: nil)}}}}else {// If Kakao Talk is not installed, it is recommended to share URI via web.// You can use custom webView or default browser.// Example of sharing URI via webif let url = ShareApi.shared.makeCustomUrl(templateId:templateId,templateArgs:templateArgs,serverCallbackArgs: serverCallbackArgs) {self.safariViewController = SFSafariViewController(url: url)self.safariViewController?.modalTransitionStyle = .crossDissolveself.safariViewController?.modalPresentationStyle = .overCurrentContextself.present(self.safariViewController!, animated: true) {print("Succeeded in presenting web.")}}}
If the Kakao Talk Share message is successfully sent, Kakao sends a Kakao Talk Share webhook including the specified parameters to the webhook URL of your service server. For more information on the webhook request, refer to Kakao Talk Share webhook.
| Reference | App setting |
|---|---|
[SDK, RxSDK] imageUpload()[SDK, RxSDK] imageScrap()[SDK] ImageUploadResult | Install Import modules 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 a URL issued by the Kakao server after uploading the image. If you are using a custom template, you can also upload images through the Message Template Tool.
You can either:
- Upload an image file directly to the Kakao server (using
imageUpload()), or - Scrape an image URL that is already uploaded to your service server (using
imageScrap()).
When the request succeeds, you receive the image URL as a string value. Use this URL as part of your Talk message content.
- Image file size: up to 5 MB.
- Image storage period: stored on the Kakao server for up to 100 days, then automatically deleted.
if let image = UIImage(named: "sample1") {ShareApi.shared.imageUpload(image:image) { [weak self] (imageUploadResult, error) inif let error = error {print(error)}else {print("imageUpload() success.")}}}
if let url = URL(string:"https://t1.kakaocdn.net/kakaocorp/Service/KakaoTalk/pc/slide/talkpc_theme_01.jpg") {ShareApi.shared.imageScrap(imageUrl: url, completion: { [weak self] (imageUploadResult, error) inif let error = error {print(error)}else {print("imageUpload() success.")}})}
You can also create a message by using a constructor for a template class, as well as configuring a message in JSON format according to message types. With the method using a constructor, you can identify and define components more explicitly. However, you cannot use a template class for each message type directly when requesting to send a message. Instead, you should use it to create the templateObject object to be passed as a parameter (or argument).
let link = Link(webUrl: URL(string:"https://developers.kakao.com"),mobileWebUrl: URL(string:"https://developers.kakao.com"))let appLink = Link(androidExecutionParams: ["key1": "value1", "key2": "value2"],iosExecutionParams: ["key1": "value1", "key2": "value2"])let button1 = Button(title: "View on Web", link: link)let button2 = Button(title: "View on App", link: appLink)let social = Social(likeCount: 286,commentCount: 45,sharedCount: 845)let content = Content(title: "Strawberry Cheese Cake",imageUrl: URL(string:"https://mud-kage.kakao.com/dn/Q2iNx/btqgeRgV54P/VLdBs9cvyn8BJXB3o7N8UK/kakaolink40_original.png")!,description: "#Cake #Strawberry #Sampyeong-dong #Cafe #Vibe #BlindDate",link: link)let feedTemplate = FeedTemplate(content: content, social: social, buttons: [button1, button2])//Encode message templateif let feedTemplateJsonData = (try? SdkJSONEncoder.custom.encode(feedTemplate)) {//Convert the created message template object to a json object.if let templateJsonObject = SdkUtils.toJsonObject(feedTemplateJsonData) {ShareApi.shared.shareDefault(templateObject:templateJsonObject) {(sharingResult, error) inif let error = error {errorHandler(error)}else {print("shareDefault(templateObject:templateJsonObject) success.")//Do somethingguard let sharingResult = sharingResult else { return }UIApplication.shared.open(sharingResult.url, options: [:], completionHandler: nil)}}}}