Skip to content

Commit

Permalink
[FEAT] TeamNADA#101 - 카카오 로그인 표출까지 뷰컨에 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
mini-min committed Dec 1, 2021
1 parent fafb43f commit 686fd2d
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 44 deletions.
4 changes: 2 additions & 2 deletions NADA-iOS-forRelease.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = T3VFJ764ZC;
DEVELOPMENT_TEAM = 4QG3GC35LA;
INFOPLIST_FILE = "NADA-iOS-forRelease/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -1142,7 +1142,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = T3VFJ764ZC;
DEVELOPMENT_TEAM = 4QG3GC35LA;
INFOPLIST_FILE = "NADA-iOS-forRelease/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
33 changes: 16 additions & 17 deletions NADA-iOS-forRelease/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIAppFonts</key>
<array>
<string>NotoSansCJKkr-Bold.otf</string>
<string>NotoSansCJKkr-Medium.otf</string>
<string>NotoSansCJKkr-Regular.otf</string>
<string>Spoqa Han Sans Neo Bold.otf</string>
<string>Spoqa Han Sans Neo Regular.otf</string>
</array>
<key>LSApplicationCategoryType</key>
<string></string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
Expand All @@ -33,10 +18,26 @@
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>5b8dd8cc878344bb7532eeca4365a4aa</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>kakaokompassauth</string>
<string>kakaolink</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
Expand Down Expand Up @@ -90,7 +91,5 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIUserInterfaceStyle</key>
<string></string>
</dict>
</plist>
8 changes: 6 additions & 2 deletions NADA-iOS-forRelease/Resouces/Storyboards/Login.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5pM-UL-MTg">
<rect key="frame" x="0.0" y="0.0" width="327" height="48"/>
<color key="backgroundColor" name="background"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="3RT-Mz-xhr"/>
</constraints>
<fontDescription key="fontDescription" name="NotoSansCJKkr-Regular" family="Noto Sans CJK KR" pointSize="14"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="75" maxY="0.0"/>
<inset key="titleEdgeInsets" minX="0.0" minY="0.0" maxX="15" maxY="0.0"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="163" maxY="0.0"/>
<state key="normal" title="카카오 로그인" image="icnKakao">
<color key="titleColor" name="primary"/>
</state>
Expand All @@ -55,8 +57,10 @@
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="CFr-2z-xuP">
<rect key="frame" x="0.0" y="62" width="327" height="48"/>
<color key="backgroundColor" name="background"/>
<fontDescription key="fontDescription" name="NotoSansCJKkr-Regular" family="Noto Sans CJK KR" pointSize="14"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="68" maxY="0.0"/>
<inset key="titleEdgeInsets" minX="0.0" minY="0.0" maxX="15" maxY="0.0"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="150" maxY="0.0"/>
<state key="normal" title="Apple로 로그인" image="icnApple">
<color key="titleColor" name="primary"/>
</state>
Expand Down
16 changes: 9 additions & 7 deletions NADA-iOS-forRelease/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,33 @@
//

import UIKit
import KakaoSDKCommon

@main
class AppDelegate: UIResponder, UIApplicationDelegate {



func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
KakaoSDKCommon.initSDK(appKey: "5b8dd8cc878344bb7532eeca4365a4aa")
return true
}

// MARK: UISceneSession Lifecycle

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}

func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}


}

34 changes: 22 additions & 12 deletions NADA-iOS-forRelease/Sources/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,66 @@

import UIKit
import IQKeyboardManagerSwift
import KakaoSDKAuth

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?


func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let windowScene = (scene as? UIWindowScene) else { return }

window = UIWindow(frame: windowScene.coordinateSpace.bounds)
window?.windowScene = windowScene
window?.rootViewController = UIStoryboard(name: Const.Storyboard.Name.tabBar, bundle: nil).instantiateViewController(withIdentifier: Const.ViewController.Identifier.tabBarViewController)
window?.windowScene = windowScene
// window?.rootViewController = UIStoryboard(name: Const.Storyboard.Name.tabBar, bundle: nil).instantiateViewController(withIdentifier: Const.ViewController.Identifier.tabBarViewController)
window?.rootViewController = UIStoryboard(name: Const.Storyboard.Name.login, bundle: nil).instantiateViewController(withIdentifier: Const.ViewController.Identifier.loginViewController)
window?.makeKeyAndVisible()

IQKeyboardManager.shared.enable = true
IQKeyboardManager.shared.enableAutoToolbar = false
IQKeyboardManager.shared.shouldResignOnTouchOutside = true
}


func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
if let url = URLContexts.first?.url {
if (AuthApi.isKakaoTalkLoginUrl(url)) {
_ = AuthController.handleOpenUrl(url: url)
}
}
}

func sceneDidDisconnect(_ scene: UIScene) {
// Called as the scene is being released by the system.
// This occurs shortly after the scene enters the background, or when its session is discarded.
// Release any resources associated with this scene that can be re-created the next time the scene connects.
// The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
}

func sceneDidBecomeActive(_ scene: UIScene) {
// Called when the scene has moved from an inactive state to an active state.
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}

func sceneWillResignActive(_ scene: UIScene) {
// Called when the scene will move from an active state to an inactive state.
// This may occur due to temporary interruptions (ex. an incoming phone call).
}

func sceneWillEnterForeground(_ scene: UIScene) {
// Called as the scene transitions from the background to the foreground.
// Use this method to undo the changes made on entering the background.
}

func sceneDidEnterBackground(_ scene: UIScene) {
// Called as the scene transitions from the foreground to the background.
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.
}


}

Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
//

import UIKit
import KakaoSDKCommon
import KakaoSDKAuth
import KakaoSDKUser

class LoginViewController: UIViewController {

// MARK: - View Life Cycle
override func viewDidLoad() {
super.viewDidLoad()

// FIXME: - 서버 연결 테스트, 추후 위치 수정 필요
// getUserIDFetchWithAPI(userID: "nada")
// getUserTokenFetchWithAPI(userID: "nada")
Expand All @@ -23,7 +26,35 @@ class LoginViewController: UIViewController {
// MARK: - IBAction Properties
// 카카오톡으로 로그인 버튼 클릭 시
@IBAction func kakaoLoginButton(_ sender: Any) {

// 카카오톡 설치 여부 확인
if (UserApi.isKakaoTalkLoginAvailable()) {
// 카카오톡 로그인. api 호출 결과를 클로저로 전달.
UserApi.shared.loginWithKakaoTalk {(oauthToken, error) in
if let error = error {
// 예외 처리 (로그인 취소 등)
print(error)
}
else {
print("loginWithKakaoTalk() success.")
// do something
_ = oauthToken
// 어세스토큰
let accessToken = oauthToken?.accessToken
}
}
} else {
// 웹 브라우저로 카카오 로그인
UserApi.shared.loginWithKakaoAccount {(oauthToken, error) in
if let error = error {
print(error)
} else {
print("loginWithKakaoAccount() success.")

// do something
_ = oauthToken
}
}
}
}

// Apple로 로그인 버튼 클릭 시
Expand Down
2 changes: 2 additions & 0 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ pod 'Moya', '~> 14.0'
pod 'SkeletonView'
pod 'SwiftLint'
pod 'VerticalCardSwiper'
pod 'KakaoSDKCommon'
pod 'KakaoSDKUser'
pod 'KakaoSDKAuth'
pod 'IQKeyboardManagerSwift'
end
4 changes: 3 additions & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ PODS:

DEPENDENCIES:
- IQKeyboardManagerSwift
- KakaoSDKAuth
- KakaoSDKCommon
- KakaoSDKUser
- Moya (~> 14.0)
- SkeletonView
Expand Down Expand Up @@ -51,6 +53,6 @@ SPEC CHECKSUMS:
SwiftLint: 99f82d07b837b942dd563c668de129a03fc3fb52
VerticalCardSwiper: 68df635b354500f86934ea044ade37a264c044c6

PODFILE CHECKSUM: 176ec86a8b34d679a9bdc17fac73e683359a616f
PODFILE CHECKSUM: 6a31cd7bb220f2d3023d8f8d8cbc676e47f4ea89

COCOAPODS: 1.11.2

0 comments on commit 686fd2d

Please sign in to comment.