Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] #28 - 유저아이디, 엑세스토큰 UserDefaults 으로 저장 구현 #32

Merged
merged 1 commit into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Spark-iOS/Spark-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
F80A3E57278C1C2700728E07 /* FeedVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = F80A3E56278C1C2700728E07 /* FeedVC.swift */; };
F816F122278E1C760008ED00 /* Login.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F816F121278E1C760008ED00 /* Login.storyboard */; };
F816F125278E1C920008ED00 /* LoginVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = F816F124278E1C920008ED00 /* LoginVC.swift */; };
F82B2E0B278EBC4400219628 /* UserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = F82B2E0A278EBC4400219628 /* UserDefaults.swift */; };
F82B2E0B278EBC4400219628 /* UserDefaultsKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = F82B2E0A278EBC4400219628 /* UserDefaultsKey.swift */; };
F82B2E0E278ED01F00219628 /* Splash.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F82B2E0D278ED01F00219628 /* Splash.storyboard */; };
F82B2E12278F54CD00219628 /* SplashVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = F82B2E11278F54CD00219628 /* SplashVC.swift */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -93,7 +93,7 @@
F80A3E56278C1C2700728E07 /* FeedVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedVC.swift; sourceTree = "<group>"; };
F816F121278E1C760008ED00 /* Login.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Login.storyboard; sourceTree = "<group>"; };
F816F124278E1C920008ED00 /* LoginVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginVC.swift; sourceTree = "<group>"; };
F82B2E0A278EBC4400219628 /* UserDefaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaults.swift; sourceTree = "<group>"; };
F82B2E0A278EBC4400219628 /* UserDefaultsKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultsKey.swift; sourceTree = "<group>"; };
F82B2E0D278ED01F00219628 /* Splash.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Splash.storyboard; sourceTree = "<group>"; };
F82B2E11278F54CD00219628 /* SplashVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashVC.swift; sourceTree = "<group>"; };
F8368FAA278F5DFF00110B74 /* Spark-iOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Spark-iOS.entitlements"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -194,7 +194,7 @@
F8096F3127841FE100B71D38 /* ViewController.swift */,
F8096F432784221900B71D38 /* Xib.swift */,
F8096F452784247100B71D38 /* Notification.swift */,
F82B2E0A278EBC4400219628 /* UserDefaults.swift */,
F82B2E0A278EBC4400219628 /* UserDefaultsKey.swift */,
);
path = Constants;
sourceTree = "<group>";
Expand Down Expand Up @@ -476,7 +476,7 @@
files = (
2BC1726D278E8F1000BA3029 /* UIView+Extension.swift in Sources */,
F8096F422784214900B71D38 /* TempAppModel.swift in Sources */,
F82B2E0B278EBC4400219628 /* UserDefaults.swift in Sources */,
F82B2E0B278EBC4400219628 /* UserDefaultsKey.swift in Sources */,
F8096F3227841FE100B71D38 /* ViewController.swift in Sources */,
F8096F042784107D00B71D38 /* AppDelegate.swift in Sources */,
2B69E7E5278E22F4000F927F /* FeedHeaderView.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ extension Const {
struct UserDefaultsKey {
static let isAppleLogin = "isAppleLogin"
static let isOnboarding = "isOnboarding"
static let userID = "userID"
static let accessToken = "accessToekn"
}
}
7 changes: 3 additions & 4 deletions Spark-iOS/Spark-iOS/Source/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@ import KakaoSDKUser
class AppDelegate: UIResponder, UIApplicationDelegate {

var isLogin = false
// TODO: - 엑세스 토큰 유저 아이디 키체인 넣기
var accessToken = ""
var userID = ""

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

let accessToken = UserDefaults.standard.string(forKey: Const.UserDefaultsKey.accessToken)

if accessToken != nil {
if UserDefaults.standard.bool(forKey: Const.UserDefaultsKey.isAppleLogin) {
// 애플 로그인으로 연동되어 있을 때, -> 애플 ID와의 연동상태 확인 로직
let appleIDProvider = ASAuthorizationAppleIDProvider()
appleIDProvider.getCredentialState(forUserID: userID) { (credentialState, error) in
appleIDProvider.getCredentialState(forUserID: UserDefaults.standard.string(forKey: Const.UserDefaultsKey.userID) ?? "") { (credentialState, error) in
switch credentialState {
case .authorized:
print("해당 ID는 연동되어있습니다.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ extension LoginVC {
if let userID = user?.id {
self.signupWithAPI(userID: String(userID))

// TODO: - 키체인으로 id 등록

UserDefaults.standard.set(String(userID), forKey: Const.UserDefaultsKey.userID)
UserDefaults.standard.set(false, forKey: Const.UserDefaultsKey.isAppleLogin)
}
}
Expand All @@ -127,11 +126,11 @@ extension LoginVC {

extension LoginVC {

// TODO: - 회원가입 로직
// TODO: - Network. 회원가입 서버통신

private func signupWithAPI(userID: String) {

// TODO: - 엑세스 토큰 키체인에 등록하고 화면전환
// TODO: - 엑세스 토큰 userdefaults 등록하고 화면전환

presentToMainTabBar()
}
Expand Down