This plugin is only used in Native capacitor(not web implemented)
npm install capacitor-kakao-login-pluginmarkdown
Copy
> Official Kakao Login Plugin for Capacitor. Supports Android, iOS & Web environments.
> Fully compatible with Capacitor 7 β
| Optimized for latest SDK versions π₯
``bash`
npm i capacitor-kakao-login-plugin
npx cap sync
| Version | Platform |
|-------------|:-----------:|
| 3.0.x | Capacitor 7 |
| 2.0.x | Capacitor 6 |
| 1.3.x | Capacitor 5 |
| 1.2.x | Capacitor 4 |
* initForWeb()
* goLogin()
* goLogout()
* getUserInfo()
* sendLinkFeed(...)
* talkInChannel(...)
`typescript`
initForWeb(appkey) => Promise
| Param | Type |
|--------------|:--------------------------------------------------------------------------------:|
| appkey | string
Your JavaScript api key (from Kakao developer console) |
Returns: Promise
--------------------
`typescript`
goLogin() => any // (with openId if you set in console)
Returns: any
--------------------
`typescript`
goLogout() => any
Returns: any
--------------------
`typescript`
getUserInfo() => any
Returns: any
--------------------
`typescript`
sendLinkFeed(options: { title: string; description: string; imageUrl: string; imageLinkUrl: string; buttonTitle: string; imageWidth?: number; imageHeight?: number; }) => any
| Param | Type |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| options | { title: string; description: string; imageUrl: string; imageLinkUrl: string; buttonTitle: string; imageWidth?: number; imageHeight?: number; } |
Returns: any
--------------------
`typescript`
talkInChannel(options: { publicId: string; }) => any
| Param | Type |
| ------------- |------------------------------------|
| options | { publicId: string; } |
Returns: any
--------------------
- Before the plugin can be used initForWeb() must be called your with your JavaScript appkeyinitForWeb()
- After resolves the other methods can be used.
- Set AndroidManifest.xml
`xml
...
+
+
+
...
+
+ android:value="@string/kakao_app_key" />
android:name="org.nerdfriends.ddoit.app.MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/AppTheme.NoActionBarLaunch"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustPan"
>
+
...
+
+ android:exported="true">
+
+
+
+
+
+
+
+
...
`
- Set Kakao Repository to build.gradle
`shell`
allprojects {
repositories {
google()
jcenter()
maven { url 'https://devrepo.kakao.com/nexus/content/groups/public/' }
}
}
- Add Kakao Initialization
`java
public class MainActivity extends BridgeActivity {
private CallbackManager callbackManager;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// μΉ΄μΉ΄μ€
+ KakaoSdk.init(this, getString(R.string.kakao_app_key);
}
}
`
- Add kakao string variables
`xml`
- Add kakao values and schemes to info.plist
`xml`
- Add initial kakao codes to AppDelegate.swift
`swift
import UIKit
import Capacitor
import KakaoSDKAuth
import KakaoSDKCommon
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
...
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
// Initialize Kakao
+ let key = Bundle.main.infoDictionary?["KAKAO_APP_KEY"] as? String
+ KakaoSDK.initSDK(appKey: key!)
return true
}
...
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
// Called when the app was launched with a url. Feel free to add additional processing here,
// but if you want the App API to support tracking app url opens, make sure to keep this call
// Need for Login with KakaoTalk
+ if (AuthApi.isKakaoTalkLoginUrl(url)) {
+ return AuthController.handleOpenUrl(url: url)
+ }
return ApplicationDelegateProxy.shared.application(app, open: url, options: options)
}
...
}
``