kakao-login
Kakao Account Login Plugin Wrapper (카카오 계정 연동 플러그인 Wrapper) link: https://github.com/raccoondev85/cordova-plugin-kakaologin
Development Environment and ETC
type | version |
---|---|
ionic (Ionic CLI) | 3.19.1 |
cordova (Cordova CLI) | 8.0.0 |
Cordova Platforms Android | 6.4.0 |
Cordova Platforms IOS | 4.5.4 |
Ionic Framework | ionic-angular 3.9.2 |
KakaoOpenSDK.framework(ios) | 1.7.0 |
com.kakao.sdk:kakaotalk(android) | 1.10.1 |
com.kakao.sdk:kakaolink(android) | 1.10.1 |
How to install
install cordova plugin
// KAKAO_APP_KEY: the app key that you got assigned as a native key in the kakao development console
$ cordova plugin add cordova-plugin-kakaologin --variable KAKAO_APP_KEY=YOUR_KAKAO_APP_KEY
install wrapper for kakao login plugin to interface
$ npm install --save kakao-login
then import KakaoLogin module into app.module.ts
import { KakaoLogin } from 'kakao-login';
@NgModule({
providers: [
KakaoLogin
]
})
Methods
login()
import { KakaoLogin, AuthTypes } from 'kakao-login';
constructor(public _kakaoLogin: KakaoLogin) {
let loginOptions = {};
loginOptions['authTypes'] = [
AuthTypes.AuthTypeTalk,
AuthTypes.AuthTypeStory,
AuthTypes.AuthTypeAccount
];
this._kakaoLogin.login(loginOptions).then((res) => {
console.log(res);
}
);
}
There is an optional parameter you can pass in to give users to choose various login ways through:
options | type | default | iOS | Android | description |
---|---|---|---|---|---|
authTypes |
any[] | AuthTypes.AuthTypeTalk |
yes | yes | Types of Authentication: "AuthTypes.AuthTypeTalk", "AuthTypes.AuthTypeStory", "AuthTypes.AuthTypeAccount", multiple values in this option will show the popup window to choose among the login methods unless one of those apps are not yet installed in the device(except AuthTypeAccount) |
Return values are "id", "accessToken", "email", "emailVerified", "nickname", "profileImagePath", "thumbnailImagePath", and etc(basically everthing that SDK gives but it might be slightly different depending on OS, AuthType, or user's setting, for example "profileImagePath" or "thumbnailImagePath" not be given if user doesn't set up, or "email" might not exist if you did not set up as mandatory parameter in the kakao development console )
logout()
constructor(public _kakaoLogin: KakaoLogin) {
this._kakaoLogin.logout().then(() => {
//do your logout proccess for your app
}
);
}
return null
unlinkApp()
Unregister app for your app service.
constructor(public _kakaoLogin: KakaoLogin) {
this._kakaoLogin.unlinkApp().then(() => {
//do your unregister proccess for your app
}
);
}
getAccessToken()
Get current access token.
constructor(public _kakaoLogin: KakaoLogin) {
this._kakaoLogin.getAccessToken().then((res) => {
console.log(res);
}
);
}
it returns the current access token.