package com.DefaultCompany.KakaoTest
import android.app.Application
import com.kakao.sdk.common.KakaoSdk
class GlobalApplication : Application() {
override fun onCreate() {
super.onCreate()
KakaoSdk.init(this,"e07f4a5a3e806afcfed2788cd2073bf2")
}
}
package com.DefaultCompany.KakaoTest
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import com.kakao.sdk.share.ShareClient
import com.kakao.sdk.template.model.Button
import com.kakao.sdk.template.model.Content
import com.kakao.sdk.template.model.FeedTemplate
import com.kakao.sdk.template.model.ItemContent
import com.kakao.sdk.template.model.ItemInfo
import com.kakao.sdk.template.model.Link
import com.kakao.sdk.template.model.Social
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
if (ShareClient.instance.isKakaoTalkSharingAvailable(this)) {
val defaultFeed = FeedTemplate(
content = Content(
title = "오늘의 디저트",
description = "#케익 #딸기 #삼평동 #카페 #분위기 #소개팅",
imageUrl = "https://mud-kage.kakao.com/dn/Q2iNx/btqgeRgV54P/VLdBs9cvyn8BJXB3o7N8UK/kakaolink40_original.png",
link = Link(
webUrl = "https://developers.kakao.com",
mobileWebUrl = "https://developers.kakao.com"
)
),
itemContent = ItemContent(
profileText = "Kakao",
profileImageUrl = "https://mud-kage.kakao.com/dn/Q2iNx/btqgeRgV54P/VLdBs9cvyn8BJXB3o7N8UK/kakaolink40_original.png",
titleImageUrl = "https://mud-kage.kakao.com/dn/Q2iNx/btqgeRgV54P/VLdBs9cvyn8BJXB3o7N8UK/kakaolink40_original.png",
titleImageText = "Cheese cake",
titleImageCategory = "Cake",
items = listOf(
ItemInfo(item = "cake1", itemOp = "1000원"),
ItemInfo(item = "cake2", itemOp = "2000원"),
ItemInfo(item = "cake3", itemOp = "3000원"),
ItemInfo(item = "cake4", itemOp = "4000원"),
ItemInfo(item = "cake5", itemOp = "5000원")
),
sum = "Total",
sumOp = "15000원"
),
social = Social(
likeCount = 286,
commentCount = 45,
sharedCount = 845
),
buttons = listOf(
Button(
"웹으로 보기",
Link(
webUrl = "https://developers.kakao.com",
mobileWebUrl = "https://developers.kakao.com"
)
),
Button(
"앱으로 보기",
Link(
androidExecutionParams = mapOf(
"key1" to "value1",
"key2" to "value2"
),
iosExecutionParams = mapOf("key1" to "value1", "key2" to "value2")
)
)
)
)
}
}
}
}
안드로이드 매니페스트
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<queries>
<package android:name="com.kakao.talk" />
</queries>
<application
android:name=".GlobalApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.KakaoTest"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.KakaoTest">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:host="kakaolink"
android:scheme="kakao$e07f4a5a3e806afcfed2788cd2073bf2" />
</intent-filter>
</activity>
</application>
</manifest>
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
namespace 'com.DefaultCompany.KakaoTest'
compileSdk 33
defaultConfig {
applicationId "com.DefaultCompany.KakaoTest"
minSdk 24
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.3.2'
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
implementation "com.kakao.sdk:v2-all:2.13.0" // 전체 모듈 설치, 2.11.0 버전부터 지원
implementation "com.kakao.sdk:v2-user:2.13.0" // 카카오 로그인
implementation "com.kakao.sdk:v2-talk:2.13.0" // 친구, 메시지(카카오톡)
implementation "com.kakao.sdk:v2-story:2.13.0" // 카카오스토리
implementation "com.kakao.sdk:v2-share:2.13.0" // 메시지(카카오톡 공유)
implementation "com.kakao.sdk:v2-navi:2.13.0" // 카카오내비
implementation "com.kakao.sdk:v2-friend:2.13.0" // 카카오톡 소셜 피커, 리소스 번들 파일 포함
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.5.1'
implementation platform('androidx.compose:compose-bom:2022.10.00')
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.compose.material3:material3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation platform('androidx.compose:compose-bom:2022.10.00')
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
debugImplementation 'androidx.compose.ui:ui-tooling'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
}
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://devrepo.kakao.com/nexus/content/groups/public/'}
}
}
rootProject.name = "KakaoTest"
include ':app'
![KakaoTalk_Photo_2023-05-02-14-48-59|233x500](upload://tFmASmF1W3JugBYOF43JMzrRSkL.jpeg)