Skip to content

Commit

Permalink
✨[FEAT] : #139 카카오 로그인 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
comeheredart committed Oct 12, 2021
1 parent 5ab36fc commit bdaab40
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 5 deletions.
2 changes: 2 additions & 0 deletions ChaRo-iOS/ChaRo-iOS/Resource/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSApplicationQueriesSchemes</key>
<string></string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
Expand Down
66 changes: 66 additions & 0 deletions ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SignScene/SNSLoginVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import UIKit
import SnapKit
import Then
import GoogleSignIn
import KakaoSDKUser

class SNSLoginVC: UIViewController {

Expand Down Expand Up @@ -80,6 +81,7 @@ class SNSLoginVC: UIViewController {
$0.titleLabel?.font = UIFont.notoSansMediumFont(ofSize: 14)
$0.layer.cornerRadius = 10
$0.clipsToBounds = true
$0.addTarget(self, action: #selector(kakaoLogin), for: .touchUpInside)
}

@objc func googleLogin() {
Expand All @@ -91,6 +93,70 @@ class SNSLoginVC: UIViewController {
}
}

@objc func kakaoLogin() {
// if (UserApi.isKakaoTalkLoginAvailable()) {
// UserApi.shared.loginWithKakaoTalk {(oauthToken, error) in
// if let error = error {
// print(error)
// }
// else {
// print("loginWithKakaoTalk() success.")
// _ = oauthToken
// let accessToken = oauthToken?.accessToken
// }
// }
// }

print("카카오 로그인 called")

if (UserApi.isKakaoTalkLoginAvailable()) {
UserApi.shared.loginWithKakaoTalk { (oauthToken, error) in
if let error = error {
print(error)
}

else {
print("login success")
print(oauthToken) //토큰 정보
print(UserApi.shared.me() { (user, error) in
if let error = error {
print(error)
}
else {

var scopes = [String]()
if (user?.kakaoAccount?.emailNeedsAgreement == true) { scopes.append("account_email") }
if scopes.count != 0 {
UserApi.shared.loginWithKakaoAccount(scopes: scopes) { (_, error) in
if let error = error {
print(error)
} else {
UserApi.shared.me() { (user, error) in
if let error = error {
print(error)
} else {

}
}
}

}
}
else {
print("사용자 이메일은 \(user?.kakaoAccount?.email!)")
}
}

})
}

}
}
else {
print("미설치")
}
}

@objc func socialLogin() {
SocialLoginService.shared.socialLogin(email: "[email protected]") { (response) in

Expand Down
3 changes: 1 addition & 2 deletions ChaRo-iOS/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ target 'ChaRo-iOS' do
pod 'RxSwift', '6.2.0'
pod 'RxCocoa', '6.2.0'
pod 'GoogleSignIn'
pod 'KakaoSDKCommon'
pod 'KakaoSDKAuth'
pod 'KakaoSDKUser'
end

9 changes: 6 additions & 3 deletions ChaRo-iOS/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ PODS:
- KakaoSDKCommon/Network (2.6.0):
- Alamofire (~> 5.1)
- KakaoSDKCommon/Common (= 2.6.0)
- KakaoSDKUser (2.6.0):
- KakaoSDKAuth (= 2.6.0)
- Kingfisher (6.3.0)
- lottie-ios (3.2.3)
- RxCocoa (6.2.0):
Expand All @@ -37,8 +39,7 @@ PODS:
DEPENDENCIES:
- Alamofire (~> 5.4)
- GoogleSignIn
- KakaoSDKAuth
- KakaoSDKCommon
- KakaoSDKUser
- Kingfisher (~> 6.0)
- lottie-ios
- RxCocoa (= 6.2.0)
Expand All @@ -56,6 +57,7 @@ SPEC REPOS:
- GTMSessionFetcher
- KakaoSDKAuth
- KakaoSDKCommon
- KakaoSDKUser
- Kingfisher
- lottie-ios
- RxCocoa
Expand All @@ -73,6 +75,7 @@ SPEC CHECKSUMS:
GTMSessionFetcher: b3503b20a988c4e20cc189aa798fd18220133f52
KakaoSDKAuth: 037e6260f4468cbc3bde89a802864d6b58c5271c
KakaoSDKCommon: 38154188336a1118f1b757f0fec54ff989365ddc
KakaoSDKUser: ff9d7436ccbf0d65615bc56f3f4e31fb06830db2
Kingfisher: 6c3df386db71d82c0817a429d2c9421a77396529
lottie-ios: c058aeafa76daa4cf64d773554bccc8385d0150e
RxCocoa: 4baf94bb35f2c0ab31bc0cb9f1900155f646ba42
Expand All @@ -82,6 +85,6 @@ SPEC CHECKSUMS:
SwiftyJSON: 6faa0040f8b59dead0ee07436cbf76b73c08fd08
Then: acfe0be7e98221c6204e12f8161459606d5d822d

PODFILE CHECKSUM: 416ad9d788c2788fd97938da1aa7e590974c3c44
PODFILE CHECKSUM: ec17c5f07753cf4bbf1f7fb4490fdd0feeeba151

COCOAPODS: 1.10.2

0 comments on commit bdaab40

Please sign in to comment.