-
Notifications
You must be signed in to change notification settings - Fork 3
[Feat] #7 - 카카오 로그인 구현 #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
카카오SDK 라이브러리 추가
info.plist 세팅 및 URLschemes 설정
appdelegate 및 scenedeleagate 코드 추가
카카오톡 로그인, 계정 로그인 구현
로그아웃, 연결끊기 구현
토큰 보유 확인 기능 구현
생일, userId, 프로필이미지 받아오기
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LZTM 😎
pod 'KakaoSDKUser' # 카카오 로그인 | ||
pod 'KakaoSDKUser' # 사용자 관리 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# 전체 추가
pod 'KakaoSDK'
# or
# 필요한 모듈 추가
pod 'KakaoSDKCommon' # 필수 요소를 담은 공통 모듈
pod 'KakaoSDKAuth' # 사용자 인증
pod 'KakaoSDKUser' # 카카오 로그인, 사용자 관리
pod 'KakaoSDKTalk' # 친구, 메시지(카카오톡)
pod 'KakaoSDKStory' # 카카오스토리
pod 'KakaoSDKLink' # 메시지(카카오링크)
pod 'KakaoSDKTemplate' # 메시지 템플릿
pod 'KakaoSDKNavi' # 카카오내비
이렇다구 하는데
사용자 인증 역할을 하는 'KakaoSDKAuth' 도 필요해요!
그런데 KakaoSDKUser
만 적어줘도 auth, common, user 이렇게 세개가 인스톨되더라구요 그래서 정상적으로 임포트를 할 수 있었던 것 같습니당!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아아 이런 실수를,,,,ㅋㅋㅋㅋㅋㅋㅋ...
그래도 덕분에 kakaoSDKUser를 임포트하면 auth, common, user가 인스톨된다는 점 알아갑니다!
super.viewDidLoad() | ||
|
||
setText() | ||
// Do any additional setup after loading the view. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이러한 주석은 제거해주셔도 될거 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
주석..제거..메모
let url = profile! | ||
DispatchQueue.global().async { | ||
let data = try? Data(contentsOf: url) | ||
DispatchQueue.main.async { | ||
self.profileImageView.image = UIImage(data: data!) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
비동기로 이미지를 가져오고 뷰를 업데이트하는 코드 좋습니당!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
도약갈겨보자면 킹피셔 사용해서 킹피셔 깃헙에 나와있는 기본예제 공부도 좋겠네여!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
킹피셔로 refactoring 갈겨 보겠..읍니다!
let nickname = user?.kakaoAccount?.profile?.nickname | ||
let email = user?.kakaoAccount?.email | ||
let userId = user?.id | ||
let birthday = user?.kakaoAccount?.birthday | ||
let profile = user?.kakaoAccount?.profile?.profileImageUrl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이렇게 하면 nickname 이 무슨 타입인지 모르니까
let nickname: String? = user?.kakao...
이런식으로 가져가도 좋을거 같네여!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
타입 명시 잘 해놓겠슴당!
private func getUserInfo() { | ||
|
||
// ✅ 사용자 정보 가져오기 | ||
UserApi.shared.me() {(user, error) in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저희는 서버에 이제 회원 고유 값 user.id 를 보내면 됩니당(물론 이 방법은 클라에서 유저 고유 값을 전해주는 방법. 서버로 앞서 얻었던 oauthToken 을 보내주면 서버에서 토큰을 해체하는 방법도 있습니다! 난이도는 전자가 훨씬 쉬워서 앱잼 내에서는 전자의 방법으로 진행하자고 조언했구 클라입장에서는 user.id 를 보내나 oauthToken 을 보내나 코스트는 같기 때문에 동일한 난이도라고 생각되네여!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
클라가 회원의 정보를 얻는 방법
- user.id를 서버에 보내서 정보를 얻어오는 방법
- oauthToken 자체를 보내서 서버에 해체를 부탁하는 방법
- 클라 난이도는 같지만 서버가 힘듬
1의 경우에는 userDefault에 저장해서 진행하는 것이 맞을까요?
@hyun99999
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그것도 방법이지만 애플에는 키체인이라는 것이 있죠! 그래서 토큰 혹은 암호 민감한 정보 같은 경우 키체인이 적합하다고 해여 쓰다보니 이번에는 userDefaults 말고 키체인해 넣어보는건 어떨까요?? @yangsubinn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋슴니다! 더 적합한 것 같아요!
} | ||
} | ||
|
||
private func getUserInfo() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private 좋아요!
제가 만약에 다시 네이밍을 한다면 getUserInfo
라는 네이밍은 화면전환에 대한 의미를 띈다고 생각하지 않아요 그래서 주석을 쓰게 되구여 그런데 주석은 보통 블럭 내에서 보다는 블럭 밖에서 써주는 것이 맞다라고 추천하고 있어여! 블럭내의 코드는 최대한 설명없이 이해될 수 있도록 말이죠!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그런데 이처럼 연습이나 설명을 할때는 좋은 방법 같아요! 그래서 제가 다시 네이밍을 하게 된다면 화면전환 코드를 pushToLogoutVC
라고 따로 빼두고 getUserInfo
안에서 가져다 쓸거 같아여!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
주석은 블럭 밖에... + 함수는 기능별로 잘 정리해서 네이밍~~!
꿀팁 감사합니당!!
@yangsubinn @L-j-h-c
|
🌴 PR 요약
🌱 작업한 브랜치
🌱 작업한 내용
📌 참고 사항
레이아웃은....너그럽게...봐주세요
📸 스크린샷
📮 관련 이슈