ionic 으로 앱 개발 중인데
전 버전으로는 카카오톡 정보들을 전부 가지고 오는데
최근 업데이트한 버전으로는 카카오톡 정보들을 가져오지 못하는 것 같습니다.
현재 오류는 로그인 시 로그인 이 되지 않고
회원가입을 안한 계정으로 로그인 시도시 카카오톡 계정 동의 페이지는 나오지만 동의 버튼을 누르면 다시 홈으로 넘어갑니다.
또한 카카오톡 공유 버튼을 누르면 아무 작동을 하지 않는데
chrome 에서 콘솔을 확인하면 넘어가야할 정보들은 console.log을 통해 확인이 됩니다.
카카오톡.java 관련 코드는
if (action.equals("login")) {
this.login();
//requestMe(callbackContext);
return true;
} else if (action.equals("logout")) {
this.logout(callbackContext);
return true;
} else if (action.equals("getAccessToken")) {
this.getAccessToken(callbackContext);
return true;
} else if (action.equals("share")) {
try {
this.share(options, callbackContext);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
return false;
}
페이지 로그인 관련 코드는 이렇습니다.
goLogin() {
this.stopMenuSlide();
this.menuCtrl.close();
this.kakaoProvider.login().then((res:any) => {
this.serverLogin(res);
});
}
serverLogin(userprofile) {
let userProfile:any = {};
userProfile.kakaoid = userprofile.id;
userProfile.email = userprofile.email;
userProfile.nickname = userprofile.nickname;
this.userApi.login("auth/login", userProfile).subscribe((res:any) => {
console.log("LOGIN RES", res);
this.storage.set("isLogin", true);
this.storage.set("userProfile", userProfile);
this.userApi.token = res.token;
this.userApi.user = userProfile;
this.showToastWithCloseButton(userProfile.nickname + "님이 로그인 하였습니다.");
},
(err:any) => { console.log("LOGIN ERROR", err); });
}
카카오톡 provider
login(){
return new Promise((resolve,reject)=>{
this.kakaologin(this).then((res:any)=>{
resolve(res);
}, (err)=>{
reject(err);
});
});
}
kakaologin(kakaoProvider){
return new Promise((resolve,reject)=>{
if(this.platform.is(“android”) || this.platform.is(‘ios’)) {
KakaoTalk.login(
(userProfile)=>{
console.log(“userProfile:”+JSON.stringify(userProfile));
var id;
if(typeof userProfile === “string”){
id=userProfile;
}else{ // humm… userProfile data type changes. Why?
id=userProfile.id;
}
console.log(‘Successful kakaotalk login with’+id);
resolve(userProfile);
},
(err)=> {
console.log(‘Error logging in’);
console.log(JSON.stringify(err));
let reason={stage:“login_err”,msg:err};
reject(reason);
}
);
}
});
}