diff --git a/Runnect-iOS/Podfile b/Runnect-iOS/Podfile index dbe1d303..3544d927 100644 --- a/Runnect-iOS/Podfile +++ b/Runnect-iOS/Podfile @@ -10,6 +10,9 @@ target 'Runnect-iOS' do pod 'SnapKit', '~> 5.6.0' pod 'Moya', '~> 15.0' pod 'Then' + pod 'KakaoSDKCommon' + pod 'KakaoSDKAuth' + pod 'KakaoSDKUser' # Pods for Runnect-iOS diff --git a/Runnect-iOS/Podfile.lock b/Runnect-iOS/Podfile.lock index 9bff01ba..ea7f5972 100644 --- a/Runnect-iOS/Podfile.lock +++ b/Runnect-iOS/Podfile.lock @@ -1,5 +1,16 @@ PODS: - Alamofire (5.6.4) + - KakaoSDKAuth (2.14.0): + - KakaoSDKCommon (= 2.14.0) + - KakaoSDKCommon (2.14.0): + - KakaoSDKCommon/Common (= 2.14.0) + - KakaoSDKCommon/Network (= 2.14.0) + - KakaoSDKCommon/Common (2.14.0) + - KakaoSDKCommon/Network (2.14.0): + - Alamofire (~> 5.1) + - KakaoSDKCommon/Common (= 2.14.0) + - KakaoSDKUser (2.14.0): + - KakaoSDKAuth (= 2.14.0) - Kingfisher (7.4.1) - Moya (15.0.0): - Moya/Core (= 15.0.0) @@ -12,6 +23,9 @@ PODS: - Then (3.0.0) DEPENDENCIES: + - KakaoSDKAuth + - KakaoSDKCommon + - KakaoSDKUser - Kingfisher (~> 7.0) - Moya (~> 15.0) - NMapsMap @@ -21,6 +35,9 @@ DEPENDENCIES: SPEC REPOS: trunk: - Alamofire + - KakaoSDKAuth + - KakaoSDKCommon + - KakaoSDKUser - Kingfisher - Moya - NMapsGeometry @@ -30,6 +47,9 @@ SPEC REPOS: SPEC CHECKSUMS: Alamofire: 4e95d97098eacb88856099c4fc79b526a299e48c + KakaoSDKAuth: 8fca87815de22062a23297983f327613b087b8bb + KakaoSDKCommon: 0ce638f7a2e49704943c0b74a087a9f8067bba1c + KakaoSDKUser: 2ca18314ce72e6690f76cb1f6f9fbc771d31a803 Kingfisher: cd762a593a61b2fbecf7645c00f9a801a3ebfc9c Moya: 138f0573e53411fb3dc17016add0b748dfbd78ee NMapsGeometry: 53c573ead66466681cf123f99f698dc8071a4b83 @@ -37,6 +57,6 @@ SPEC CHECKSUMS: SnapKit: e01d52ebb8ddbc333eefe2132acf85c8227d9c25 Then: 844265ae87834bbe1147d91d5d41a404da2ec27d -PODFILE CHECKSUM: bec9bfadf42d34524a80ccc0e46829d1fe943ddb +PODFILE CHECKSUM: fd71a741af1234cbd39c9117a0768b376c78640a COCOAPODS: 1.11.3 diff --git a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj index 32d003c4..52b9a2f1 100644 --- a/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj +++ b/Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ A3BC2F3F2964706100198261 /* UploadedCourseInfoCVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3BC2F3E2964706100198261 /* UploadedCourseInfoCVC.swift */; }; A3BC2F4129667A0D00198261 /* NicknameEditorVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3BC2F4029667A0D00198261 /* NicknameEditorVC.swift */; }; A3BC2F432966A93100198261 /* CourseDetailVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3BC2F422966A93100198261 /* CourseDetailVC.swift */; }; + A3E55BA029C815B10000D85D /* SignInSocialLoginVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3E55B9F29C815B10000D85D /* SignInSocialLoginVC.swift */; }; A3F67AE2296D33AC001598A2 /* MyPageDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3F67AE1296D33AC001598A2 /* MyPageDto.swift */; }; A3F67AEA296E4936001598A2 /* ActivityRecordInfoDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = A3F67AE9296E4936001598A2 /* ActivityRecordInfoDto.swift */; }; CE09037D296E9ED900BEA710 /* ScrapCourseResponseDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE09037C296E9ED900BEA710 /* ScrapCourseResponseDto.swift */; }; @@ -155,6 +156,8 @@ A3BC2F3E2964706100198261 /* UploadedCourseInfoCVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadedCourseInfoCVC.swift; sourceTree = ""; }; A3BC2F4029667A0D00198261 /* NicknameEditorVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NicknameEditorVC.swift; sourceTree = ""; }; A3BC2F422966A93100198261 /* CourseDetailVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseDetailVC.swift; sourceTree = ""; }; + A3E55B9F29C815B10000D85D /* SignInSocialLoginVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignInSocialLoginVC.swift; sourceTree = ""; }; + A3E55BA529C8AB0A0000D85D /* Runnect-iOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Runnect-iOS.entitlements"; sourceTree = ""; }; A3F67AE1296D33AC001598A2 /* MyPageDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageDto.swift; sourceTree = ""; }; A3F67AE9296E4936001598A2 /* ActivityRecordInfoDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityRecordInfoDto.swift; sourceTree = ""; }; CE09037C296E9ED900BEA710 /* ScrapCourseResponseDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrapCourseResponseDto.swift; sourceTree = ""; }; @@ -731,6 +734,7 @@ CE4545C7295D7AF4003201E1 /* Runnect-iOS */ = { isa = PBXGroup; children = ( + A3E55BA529C8AB0A0000D85D /* Runnect-iOS.entitlements */, CE6655AA295D7FAE00C64E12 /* Global */, CE6655A9295D7FAA00C64E12 /* Network */, CE6655A8295D7F7D00C64E12 /* Presentation */, @@ -993,6 +997,7 @@ isa = PBXGroup; children = ( CEC2A68629629B9B00160BF7 /* SignInVC.swift */, + A3E55B9F29C815B10000D85D /* SignInSocialLoginVC.swift */, ); path = VC; sourceTree = ""; @@ -1329,6 +1334,7 @@ CEC2A6852961F92C00160BF7 /* CustomButton.swift in Sources */, CE6B63D3296725E6003F900F /* CourseListCVC.swift in Sources */, CEF3CD9A296DB305002723A1 /* CourseDetailResponseDto.swift in Sources */, + A3E55BA029C815B10000D85D /* SignInSocialLoginVC.swift in Sources */, CE29D584296416D800F47542 /* caculateStatusBarHeight.swift in Sources */, CE66560C295D928300C64E12 /* setRootViewController.swift in Sources */, CE6655D9295D871B00C64E12 /* URL+.swift in Sources */, @@ -1505,6 +1511,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = "Runnect-iOS/Runnect-iOS.entitlements"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 1; @@ -1512,10 +1519,14 @@ "DEVELOPMENT_TEAM[sdk=iphoneos*]" = 9K86FQHDLU; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = "Runnect-iOS/Info.plist"; + INFOPLIST_KEY_NSLocationAlwaysAndWhenInUseUsageDescription = "위치 정보 권한이 필요합니다."; + INFOPLIST_KEY_NSLocationAlwaysUsageDescription = "위치 정보 권한이 필요합니다."; + INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "위치 정보 권한이 필요합니다."; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UIUserInterfaceStyle = Light; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1537,6 +1548,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = "Runnect-iOS/Runnect-iOS.entitlements"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 1; @@ -1544,10 +1556,14 @@ "DEVELOPMENT_TEAM[sdk=iphoneos*]" = 9K86FQHDLU; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = "Runnect-iOS/Info.plist"; + INFOPLIST_KEY_NSLocationAlwaysAndWhenInUseUsageDescription = "위치 정보 권한이 필요합니다."; + INFOPLIST_KEY_NSLocationAlwaysUsageDescription = "위치 정보 권한이 필요합니다."; + INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "위치 정보 권한이 필요합니다."; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UIUserInterfaceStyle = Light; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/Runnect-iOS/Runnect-iOS/Global/Literal/ImageLiterals.swift b/Runnect-iOS/Runnect-iOS/Global/Literal/ImageLiterals.swift index 8e418060..ae8c8e9d 100644 --- a/Runnect-iOS/Runnect-iOS/Global/Literal/ImageLiterals.swift +++ b/Runnect-iOS/Runnect-iOS/Global/Literal/ImageLiterals.swift @@ -10,6 +10,7 @@ import NMapsMap enum ImageLiterals { // icon + static var icApple: UIImage { .load(named: "ic_apple") } static var icArrowBack: UIImage { .load(named: "ic_arrow_back") } static var icArrowMaximize: UIImage { .load(named: "ic_arrow_maximize") } static var icArrowPageback: UIImage { .load(named: "ic_arrow_pageback") } @@ -23,6 +24,7 @@ enum ImageLiterals { static var icEdit: UIImage { .load(named: "ic_edit") } static var icHeartFill: UIImage { .load(named: "ic_heart_fill") } static var icHeart: UIImage { .load(named: "ic_heart") } + static var icKakao: UIImage { .load(named: "ic_kakao") } static var icMapDeparture: UIImage { .load(named: "ic_map_departure") } static var icMapLocation: UIImage { .load(named: "ic_map_location") } static var icMapPoint: UIImage { .load(named: "ic_map_point") } diff --git a/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_apple.imageset/Apple.png b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_apple.imageset/Apple.png new file mode 100644 index 00000000..cfa0cccb Binary files /dev/null and b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_apple.imageset/Apple.png differ diff --git a/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_apple.imageset/Apple@2x.png b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_apple.imageset/Apple@2x.png new file mode 100644 index 00000000..851c5d1a Binary files /dev/null and b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_apple.imageset/Apple@2x.png differ diff --git a/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_apple.imageset/Apple@3x.png b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_apple.imageset/Apple@3x.png new file mode 100644 index 00000000..134ef371 Binary files /dev/null and b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_apple.imageset/Apple@3x.png differ diff --git a/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_apple.imageset/Contents.json b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_apple.imageset/Contents.json new file mode 100644 index 00000000..4d141d0c --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_apple.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "Apple.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Apple@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Apple@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_kakao.imageset/Contents.json b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_kakao.imageset/Contents.json new file mode 100644 index 00000000..dd12fd34 --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_kakao.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "Kakao.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Kakao@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Kakao@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_kakao.imageset/Kakao.png b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_kakao.imageset/Kakao.png new file mode 100644 index 00000000..93a99d22 Binary files /dev/null and b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_kakao.imageset/Kakao.png differ diff --git a/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_kakao.imageset/Kakao@2x.png b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_kakao.imageset/Kakao@2x.png new file mode 100644 index 00000000..59075544 Binary files /dev/null and b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_kakao.imageset/Kakao@2x.png differ diff --git a/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_kakao.imageset/Kakao@3x.png b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_kakao.imageset/Kakao@3x.png new file mode 100644 index 00000000..18ec2450 Binary files /dev/null and b/Runnect-iOS/Runnect-iOS/Global/Resource/Assets.xcassets/ic_kakao.imageset/Kakao@3x.png differ diff --git a/Runnect-iOS/Runnect-iOS/Global/Supports/AppDelegate.swift b/Runnect-iOS/Runnect-iOS/Global/Supports/AppDelegate.swift index 16053ea3..902b8147 100644 --- a/Runnect-iOS/Runnect-iOS/Global/Supports/AppDelegate.swift +++ b/Runnect-iOS/Runnect-iOS/Global/Supports/AppDelegate.swift @@ -8,9 +8,19 @@ import UIKit import NMapsMap +import KakaoSDKAuth +import KakaoSDKCommon @main class AppDelegate: UIResponder, UIApplicationDelegate { + + func scene(_ scene: UIScene, openURLContexts URLContexts: Set) { + if let url = URLContexts.first?.url { + if (AuthApi.isKakaoTalkLoginUrl(url)) { + _ = AuthController.handleOpenUrl(url: url) + } + } + } func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { // 세로방향 고정 @@ -20,6 +30,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { NMFAuthManager.shared().clientId = Config.naverMapClientId + KakaoSDK.initSDK(appKey: Config.kakaoNativeAppKey) return true } diff --git a/Runnect-iOS/Runnect-iOS/Global/Supports/SceneDelegate.swift b/Runnect-iOS/Runnect-iOS/Global/Supports/SceneDelegate.swift index f2baba80..3080cf84 100644 --- a/Runnect-iOS/Runnect-iOS/Global/Supports/SceneDelegate.swift +++ b/Runnect-iOS/Runnect-iOS/Global/Supports/SceneDelegate.swift @@ -16,7 +16,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { guard let windowScene = (scene as? UIWindowScene) else { return } let window = UIWindow(windowScene: windowScene) - let nav = UINavigationController(rootViewController: SplashVC()) + let nav = UINavigationController(rootViewController: SignInSocialLoginVC()) window.rootViewController = nav self.window = window window.makeKeyAndVisible() diff --git a/Runnect-iOS/Runnect-iOS/Info.plist b/Runnect-iOS/Runnect-iOS/Info.plist index 6e4730da..38c87e54 100644 --- a/Runnect-iOS/Runnect-iOS/Info.plist +++ b/Runnect-iOS/Runnect-iOS/Info.plist @@ -2,6 +2,22 @@ + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLSchemes + + kakao27d01e20b51e5925bf386a6c5465849f + + + + LSApplicationQueriesSchemes + + kakaokompassauth + kakaolink + UIAppFonts Pretendard-Bold.otf @@ -9,14 +25,6 @@ Pretendard-Medium.otf Pretendard-Regular.otf - UIUserInterfaceStyle - Light - NSLocationWhenInUseUsageDescription - 위치 정보 권한이 필요합니다. - NSLocationAlwaysUsageDescription - 위치 정보 권한이 필요합니다. - NSLocationAlwaysAndWhenInUseUsageDescription - 위치 정보 권한이 필요합니다. UIApplicationSceneManifest UIApplicationSupportsMultipleScenes diff --git a/Runnect-iOS/Runnect-iOS/Presentation/SignIn/VC/SignInSocialLoginVC.swift b/Runnect-iOS/Runnect-iOS/Presentation/SignIn/VC/SignInSocialLoginVC.swift new file mode 100644 index 00000000..aa2ff75e --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Presentation/SignIn/VC/SignInSocialLoginVC.swift @@ -0,0 +1,190 @@ +// +// SignInSocialLoginVC.swift +// Runnect-iOS +// +// Created by 몽이 누나 on 2023/03/20. +// + +import UIKit + +import SnapKit +import Then +import AuthenticationServices +import KakaoSDKAuth +import KakaoSDKUser +import KakaoSDKCommon + +final class SignInSocialLoginVC: UIViewController { + + // MARK: - Properties + + let screenWidth = UIScreen.main.bounds.width + + // MARK: - UI Components + + private let backgroundImageView = UIImageView().then { + $0.image = ImageLiterals.imgBackground + $0.contentMode = .scaleAspectFill + } + + private let logoImageView = UIImageView().then { + $0.image = ImageLiterals.imgLogo + $0.contentMode = .scaleAspectFill + } + + private lazy var kakaoLoginButton = UIButton(type: .system).then { + $0.setTitle("카카오로 로그인", for: .normal) + $0.titleLabel?.font = .b3 + $0.setTitleColor(.black, for: .normal) + $0.setBackgroundColor(UIColor(hex: "FEE500"), for: .normal) + $0.layer.cornerRadius = 7 + $0.setImage(ImageLiterals.icKakao, for: .normal) + $0.imageEdgeInsets = .init(top: 0, left: 0, bottom: 0, right: self.screenWidth * 0.5) + $0.tintColor = .black + } + + private lazy var appleLoginButton = UIButton(type: .system).then { + $0.setTitle("Apple로 로그인", for: .normal) + $0.titleLabel?.font = .b3 + $0.setTitleColor(.white, for: .normal) + $0.setBackgroundColor(.black, for: .normal) + $0.layer.cornerRadius = 7 + $0.setImage(ImageLiterals.icApple, for: .normal) + $0.imageEdgeInsets = .init(top: 0, left: 0, bottom: 0, right: self.screenWidth * 0.5) + $0.tintColor = .white + } + + override func viewDidLoad() { + super.viewDidLoad() + setUI() + setNavigationBar() + setLayout() + setAddTarget() + } +} + +// MARK: - @objc Function + +extension SignInSocialLoginVC { + @objc func touchUpAppleLoginButton() { + pushToAppleLogin() + } + + @objc func pushToAppleLogin() { + let appleIDProvider = ASAuthorizationAppleIDProvider() + let request = appleIDProvider.createRequest() + request.requestedScopes = [.fullName, .email] + + let authorizationController = ASAuthorizationController(authorizationRequests: [request]) + authorizationController.delegate = self + authorizationController.presentationContextProvider = self + authorizationController.performRequests() + } + + @objc func kakaoLoginButtonDidTap(_ sender: Any) { + // isKakaoTalkLoginAvailable() : 카톡 설치 되어있으면 true + if (UserApi.isKakaoTalkLoginAvailable()) { //카톡 설치되어있으면 -> 카톡으로 로그인 + UserApi.shared.loginWithKakaoTalk {(oauthToken, error) in + if let error = error { + print(error) + } else { + print("카카오 톡으로 로그인 성공") + + _ = oauthToken + /// 로그인 관련 메소드 추가 + + } + } + } else { + + // 카톡 없으면 -> 계정으로 로그인 + UserApi.shared.loginWithKakaoAccount { (oauthToken, error) in + if let error = error { + print(error) + } else { + print("카카오 계정으로 로그인 성공") + + _ = oauthToken + // 관련 메소드 추가 + } + } + } + } +} + +// MARK: - Methods + +extension SignInSocialLoginVC { + private func setAddTarget() { + self.appleLoginButton.addTarget(self, action: #selector(touchUpAppleLoginButton), for: .touchUpInside) + self.kakaoLoginButton.addTarget(self, action: #selector(kakaoLoginButtonDidTap), for: .touchUpInside) + } +} + +// MARK: - UI & Layout + +extension SignInSocialLoginVC { + private func setUI() { + view.backgroundColor = .m1 + } + + private func setNavigationBar() { + self.navigationController?.isNavigationBarHidden = true + } + + private func setLayout() { + view.addSubviews(backgroundImageView, logoImageView, kakaoLoginButton, appleLoginButton) + + backgroundImageView.snp.makeConstraints { make in + make.edges.equalToSuperview() + } + + logoImageView.snp.makeConstraints { make in + make.center.equalTo(view.safeAreaLayoutGuide) + } + + kakaoLoginButton.snp.makeConstraints { make in + make.bottom.equalToSuperview().inset(54) + make.height.equalTo(55) + make.leading.trailing.equalToSuperview().inset(15) + } + + appleLoginButton.snp.makeConstraints { make in + make.bottom.equalTo(kakaoLoginButton.snp.top).offset(-10) + make.height.equalTo(55) + make.leading.trailing.equalToSuperview().inset(15) + } + } +} + +// MARK: - ASAuthorizationControllerPresentationContextProviding, ASAuthorizationControllerDelegate + +extension SignInSocialLoginVC: ASAuthorizationControllerPresentationContextProviding, ASAuthorizationControllerDelegate { + func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor { + return self.view.window! + } + + /// Apple ID 연동 성공 시 + func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) { + switch authorization.credential { + /// Apple ID + case let appleIDCredential as ASAuthorizationAppleIDCredential: + + /// 계정 정보 가져오기 + let userIdentifier = appleIDCredential.user + let idToken = appleIDCredential.identityToken! + let tokeStr = String(data: idToken, encoding: .utf8) + + print("User ID : \(userIdentifier)") + print("token : \(String(describing: tokeStr))") + + default: + break + } + } + + /// Apple ID 연동 실패 시 + func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) { + print("Apple Login error") + } +} diff --git a/Runnect-iOS/Runnect-iOS/Runnect-iOS.entitlements b/Runnect-iOS/Runnect-iOS/Runnect-iOS.entitlements new file mode 100644 index 00000000..a812db50 --- /dev/null +++ b/Runnect-iOS/Runnect-iOS/Runnect-iOS.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.developer.applesignin + + Default + + +