Skip to content

Commit

Permalink
Merge pull request #14 from yungu0010/feature/#4
Browse files Browse the repository at this point in the history
[Feat] 소셜로그인 구현
  • Loading branch information
yungu0010 authored Jul 7, 2022
2 parents c1f4b3e + aac599b commit 20e77d8
Show file tree
Hide file tree
Showing 20 changed files with 747 additions and 396 deletions.
36 changes: 36 additions & 0 deletions HealthFoodMe/HealthFoodMe.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
3BCC441E28745FD800661A12 /* SocialLoginVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3BCC441D28745FD800661A12 /* SocialLoginVC.swift */; };
3BCC442028745FE500661A12 /* SocialLogin.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3BCC441F28745FE500661A12 /* SocialLogin.storyboard */; };
6005A822AEB1A47010D6C01E /* Pods_HealthFoodMe.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DEDECAEA3BF2AEAD960B4B3C /* Pods_HealthFoodMe.framework */; };
EB6A44C7287366DF00749582 /* .swiftlint.yml in Resources */ = {isa = PBXBuildFile; fileRef = EB6A44C6287366DF00749582 /* .swiftlint.yml */; };
EBF66ABC287227F500DE0ED1 /* UserDefaults+.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBF66A51287227F500DE0ED1 /* UserDefaults+.swift */; };
Expand Down Expand Up @@ -87,6 +89,9 @@

/* Begin PBXFileReference section */
26C3E6667A430DB48E0CC0FE /* Pods-HealthFoodMe.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HealthFoodMe.release.xcconfig"; path = "Target Support Files/Pods-HealthFoodMe/Pods-HealthFoodMe.release.xcconfig"; sourceTree = "<group>"; };
3B0B254D28757C7100950539 /* HealthFoodMe.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = HealthFoodMe.entitlements; sourceTree = "<group>"; };
3BCC441D28745FD800661A12 /* SocialLoginVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocialLoginVC.swift; sourceTree = "<group>"; };
3BCC441F28745FE500661A12 /* SocialLogin.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = SocialLogin.storyboard; sourceTree = "<group>"; };
75E42041F59816FF5154CDD3 /* Pods-HealthFoodMe.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HealthFoodMe.debug.xcconfig"; path = "Target Support Files/Pods-HealthFoodMe/Pods-HealthFoodMe.debug.xcconfig"; sourceTree = "<group>"; };
DEDECAEA3BF2AEAD960B4B3C /* Pods_HealthFoodMe.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_HealthFoodMe.framework; sourceTree = BUILT_PRODUCTS_DIR; };
EB085ED628716E1900361837 /* HealthFoodMe.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HealthFoodMe.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -188,6 +193,31 @@
name = Frameworks;
sourceTree = "<group>";
};
3BCC441A28745FA900661A12 /* Auth */ = {
isa = PBXGroup;
children = (
3BCC441B28745FB000661A12 /* SocialLoginScene */,
);
path = Auth;
sourceTree = "<group>";
};
3BCC441B28745FB000661A12 /* SocialLoginScene */ = {
isa = PBXGroup;
children = (
3BCC441C28745FC500661A12 /* VC */,
);
path = SocialLoginScene;
sourceTree = "<group>";
};
3BCC441C28745FC500661A12 /* VC */ = {
isa = PBXGroup;
children = (
3BCC441D28745FD800661A12 /* SocialLoginVC.swift */,
3BCC441F28745FE500661A12 /* SocialLogin.storyboard */,
);
path = VC;
sourceTree = "<group>";
};
E3F60CBC9B890A7FB4D4AAAF /* Pods */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -218,6 +248,7 @@
EB085ED828716E1900361837 /* HealthFoodMe */ = {
isa = PBXGroup;
children = (
3B0B254D28757C7100950539 /* HealthFoodMe.entitlements */,
EBF66A74287227F500DE0ED1 /* Application */,
EBF66A80287227F500DE0ED1 /* Data */,
EBF66AB3287227F500DE0ED1 /* Domain */,
Expand Down Expand Up @@ -435,6 +466,7 @@
EBF66A90287227F500DE0ED1 /* Presentation */ = {
isa = PBXGroup;
children = (
3BCC441A28745FA900661A12 /* Auth */,
EBF66A9F287227F500DE0ED1 /* Common */,
EBF66A91287227F500DE0ED1 /* Home */,
);
Expand Down Expand Up @@ -648,6 +680,7 @@
buildActionMask = 2147483647;
files = (
EB6A44C7287366DF00749582 /* .swiftlint.yml in Resources */,
3BCC442028745FE500661A12 /* SocialLogin.storyboard in Resources */,
EBF66AD0287227F500DE0ED1 /* Assets.xcassets in Resources */,
EBF66AD2287227F500DE0ED1 /* LaunchScreen.storyboard in Resources */,
EBF66AD1287227F500DE0ED1 /* NotoSansSC-Bold.otf in Resources */,
Expand Down Expand Up @@ -762,6 +795,7 @@
EBF66ABE287227F500DE0ED1 /* UITextView+.swift in Sources */,
EBF66AD5287227F500DE0ED1 /* ViewModelType.swift in Sources */,
EBF66ADA287227F500DE0ED1 /* controllerFromStoryBoard.swift in Sources */,
3BCC441E28745FD800661A12 /* SocialLoginVC.swift in Sources */,
EBF66AEC287227F500DE0ED1 /* PostDetailCVLayout.swift in Sources */,
EBF66ABD287227F500DE0ED1 /* UIDevice+.swift in Sources */,
EBF66AE1287227F500DE0ED1 /* BaseService.swift in Sources */,
Expand Down Expand Up @@ -928,6 +962,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = HealthFoodMe/HealthFoodMe.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
Expand Down Expand Up @@ -959,6 +994,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = HealthFoodMe/HealthFoodMe.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
Expand Down
24 changes: 24 additions & 0 deletions HealthFoodMe/HealthFoodMe/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

import UIKit

import AuthenticationServices
import KakaoSDKCommon

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

Expand All @@ -18,8 +21,29 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

KakaoSDK.initSDK(appKey : "8483f545857597ac5a551516e471a131")

let appleIDProvider = ASAuthorizationAppleIDProvider()
appleIDProvider.getCredentialState(forUserID: "00000.abcabcabcabc.0000(로그인에 사용한 UserIdentifier)") { (credentialState, error) in
switch credentialState {
case .authorized: // 이미 증명이 된 경우 (정상)
print("authorized")
// The Apple ID credential is valid.
case .revoked: // 증명을 취소했을 때,
print("revoked")
// 로그인뷰로 이동하기
case .notFound: // 증명이 존재하지 않을 경우
print("notFound")
// 로그인뷰로 이동하기

default:
break
}
}

return true
}


// MARK: UISceneSession Lifecycle

Expand Down
43 changes: 26 additions & 17 deletions HealthFoodMe/HealthFoodMe/Application/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,39 @@

import UIKit

import KakaoSDKAuth

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?

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

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {

if #available(iOS 15.0, *) {
let navigationBarAppearance = UINavigationBarAppearance()
navigationBarAppearance.configureWithOpaqueBackground()
navigationBarAppearance.backgroundColor = .white
navigationBarAppearance.shadowColor = .white

UINavigationBar.appearance().standardAppearance = navigationBarAppearance
UINavigationBar.appearance().scrollEdgeAppearance = navigationBarAppearance
}

guard let windowScene = (scene as? UIWindowScene) else { return }
let rootViewController = PostDetailVC()
let window = UIWindow(windowScene: windowScene)
window.rootViewController = rootViewController
self.window = window
window.backgroundColor = .white
window.makeKeyAndVisible()
// if #available(iOS 15.0, *) {
// let navigationBarAppearance = UINavigationBarAppearance()
// navigationBarAppearance.configureWithOpaqueBackground()
// navigationBarAppearance.backgroundColor = .white
// navigationBarAppearance.shadowColor = .white
//
// UINavigationBar.appearance().standardAppearance = navigationBarAppearance
// UINavigationBar.appearance().scrollEdgeAppearance = navigationBarAppearance
// }
//
// guard let windowScene = (scene as? UIWindowScene) else { return }
// let rootViewController = PostDetailVC()
// let window = UIWindow(windowScene: windowScene)
// window.rootViewController = rootViewController
// self.window = window
// window.backgroundColor = .white
// window.makeKeyAndVisible()
}

func sceneDidDisconnect(_ scene: UIScene) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ struct I18N {
static let myPlan = "마이 플랜"
}

struct Auth {
static let kakaoLoginError = "카카오 로그인에 실패하였습니다."
static let appleLoginError = "애플 로그인에 실패하였습니다."
}

struct Alert {
static let alarm = "알림"
static let error = "오류"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "authSubTitle.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "authSubTitle@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "authSubTitle@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "authTitle.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "authTitle@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "authTitle@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions HealthFoodMe/HealthFoodMe/HealthFoodMe.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-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>com.apple.developer.applesignin</key>
<array>
<string>Default</string>
</array>
</dict>
</plist>
18 changes: 18 additions & 0 deletions HealthFoodMe/HealthFoodMe/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>kakao8483f545857597ac5a551516e471a131</string>
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>kakaokompassauth</string>
<string>kakaolink</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
Expand All @@ -20,6 +36,8 @@
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>SocialLogin</string>
</dict>
</array>
</dict>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Y6W-OH-hqX">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Social LoginVC-->
<scene sceneID="s0d-6b-0kx">
<objects>
<viewController storyboardIdentifier="SocialLoginVC" useStoryboardIdentifierAsRestorationIdentifier="YES" id="Y6W-OH-hqX" customClass="SocialLoginVC" customModule="HealthFoodMe" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="5EZ-qb-Rvc">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<viewLayoutGuide key="safeArea" id="vDu-zF-Fre"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Ief-a0-LHa" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="72" y="106"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
Loading

0 comments on commit 20e77d8

Please sign in to comment.