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 2153376 commit de3892d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 17 deletions.
16 changes: 16 additions & 0 deletions ChaRo-iOS/ChaRo-iOS/Source/Support/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import UIKit
import GoogleSignIn

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
Expand All @@ -15,6 +16,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return true
}

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {

var handled: Bool

handled = GIDSignIn.sharedInstance.handle(url)
if handled {
return true
}

// Handle other custom URL types.

// If not handled by this app, return false.
return false

}
// MARK: UISceneSession Lifecycle

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import UIKit
import SnapKit
import Then
import GoogleSignIn

//컬렉션 뷰 안에 뷰 만들기 컬렉션 뷰 위에 차 만들어서 인덱스 ?? 해서 움직이게 하면 될듯
class JoinVC: UIViewController {
Expand Down
43 changes: 26 additions & 17 deletions ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SignScene/SNSLoginVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import UIKit
import SnapKit
import Then
import GoogleSignIn

class SNSLoginVC: UIViewController {

let signInConfig = GIDConfiguration.init(clientID: "com.googleusercontent.apps.278013610969-pmisnn93vofvfhk25q9a86eeu84ns1ll")
static let identifier = "SNSLoginVC"

override func viewDidLoad() {
Expand Down Expand Up @@ -65,10 +67,31 @@ class SNSLoginVC: UIViewController {
$0.layer.borderWidth = 1
$0.layer.cornerRadius = 10
$0.clipsToBounds = true
$0.addTarget(self, action: #selector(testlogin), for: .touchUpInside)
$0.addTarget(self, action: #selector(googleLogin), for: .touchUpInside)
}

@objc func testlogin() {
let kakaoLoginBtn = UIButton().then {
$0.setImage(UIImage(named: "kakaoLogo"), for: .normal)
$0.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 210)
$0.titleEdgeInsets = UIEdgeInsets(top: 0, left: -40, bottom: 0, right: 0)
$0.backgroundColor = UIColor(red: 254.0 / 255.0, green: 229.0 / 255.0, blue: 0.0, alpha: 1.0)
$0.setTitle("카카오 로그인", for: .normal)
$0.setTitleColor(.mainBlack, for: .normal)
$0.titleLabel?.font = UIFont.notoSansMediumFont(ofSize: 14)
$0.layer.cornerRadius = 10
$0.clipsToBounds = true
}

@objc func googleLogin() {
GIDSignIn.sharedInstance.signIn(with: signInConfig, presenting: self) { user, error in
guard error == nil else { return }
print("로긘 성공")
let userEmail = user?.profile?.email
print("사용자 이메일은 \(userEmail)")
}
}

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

switch(response)
Expand All @@ -90,22 +113,8 @@ class SNSLoginVC: UIViewController {
}

}


let kakaoLoginBtn = UIButton().then {
$0.setImage(UIImage(named: "kakaoLogo"), for: .normal)
$0.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 210)
$0.titleEdgeInsets = UIEdgeInsets(top: 0, left: -40, bottom: 0, right: 0)
$0.backgroundColor = UIColor(red: 254.0 / 255.0, green: 229.0 / 255.0, blue: 0.0, alpha: 1.0)
$0.setTitle("카카오 로그인", for: .normal)
$0.setTitleColor(.mainBlack, for: .normal)
$0.titleLabel?.font = UIFont.notoSansMediumFont(ofSize: 14)
$0.layer.cornerRadius = 10
$0.clipsToBounds = true
}

let googleLogoImageView = UIImageView().then {
$0.image = UIImage(named: "googleLogo")
}

let emailLoginBtn = UIButton().then {
$0.setTitle("이메일 로그인", for: .normal)
Expand Down

0 comments on commit de3892d

Please sign in to comment.