본문 바로가기

전체 글

(381)
👤 Firebase에 로그인, 회원정보를 FireStore 저장, 회원정보 불러오기 ✅ 로그인 기능 구현 /// 이메일과 비밀번호로 로그인하는 함수func loginUser(email: String, password: String) -> AnyPublisher { return Auth.auth().signIn(withEmail: email, password: password) .map(\.user) // ✅ authResult?.user 만 추출 .eraseToAnyPublisher()}✅ 특징✔️ signIn(withEmail:password:)는 원래 Future 형태로 제공됨 → 따로 감쌀 필요 없음✔️ map(\.user)를 사용해 authResult?.user만 반환하여 더 간결한 코드✔️ .eraseToAnyPublisher()로..
❓ Firebase 로그인 메서드 내 map의 역할 ✅ map(\.user)의 역할func loginUser(with email: String, password: String) -> AnyPublisher { return Auth.auth().signIn(withEmail: email, password: password) .map(\.user) // ✅ 여기서 map이 동작 .eraseToAnyPublisher()} 🔹 Firebase의 signIn(withEmail:password:)가 반환하는 타입➡️ signIn은 AnyPublisher를 반환해.➡️ 즉, AuthDataResult라는 객체가 반환되는데, 우리는 여기서 User 객체만 필요해.func signIn(withEmail email: String, ..
👤 Firebase에 이메일 & 비밀번호 회원가입 기능 (MVVM + Combine) 🔷 SceneDelegate.swift🏆 전체 흐름 정리1️⃣ 앱이 실행되면 scene(_:willConnectTo:options:)이 호출됨.2️⃣ setupWindow()를 통해 UIWindow를 초기화하고, 화면을 표시할 준비를 함.3️⃣ checkAuthentication()에서 현재 로그인 상태를 확인함.로그인이 안 되어 있다면 gotoController(with: OnboardingViewController()) 실행로그인이 되어 있다면 gotoController(with: MainTabBarController()) 실행4️⃣ gotoController(with:)가 rootViewController를 변경하고 애니메이션을 적용하여 화면을 전환함.class SceneDelegate: UIR..
🌟 회원 가입 화면 뷰 관리? 순서?는 어떻게 해야하나? ✅ 현재 코드의 흐름📌 회원가입 성공 시RegisterViewController에서 회원가입이 성공하면 현재 띄워진 모든 모달을 닫음 (dismiss())NotificationCenter를 사용해 SceneDelegate에게 회원가입 성공을 알림 (CreateUserSuccess)SceneDelegate에서 checkAuthentication() 실행checkAuthentication()에서 window?.rootViewController를 MainTabBarController로 변경✔️ 지금 코드의 장점✅ 앱의 전체적인 화면 이동을 SceneDelegate에서 관리해서 중앙 집중식 제어 가능✅ NotificationCenter를 사용해 뷰 컨트롤러 간 의존성을 줄임class SceneDelegate:..
🚀 Future를 사용한 방식 vs map(\.user)을 사용한 방식의 차이점 (Future 는 필수인가?) 두 방식 모두 Firebase의 createUser(withEmail:password:)를 Combine을 활용하여 AnyPublisher 형태로 변환하지만, 비동기 처리 방식이 조금 다릅니다.   ✅ 1. Future를 사용한 방식func registerUser(with email: String, password: String) -> AnyPublisher { return Future { promise in Auth.auth().createUser(withEmail: email, password: password) { authResult, error in if let error = error { promise(.failure(error))..
🔥 MVVM + Combine을 활용한 소셜 로그인 & 이메일 회원가입 https://explorer89.tistory.com/360 AnyPublisher { return Future { promise in Auth.auth().signIn(with: credential) { authResult, error in if let error = error { promise(.failure(error)) // " data-og-host="explorer89.tistory.com" data-og-source-url="https://explorer89.tistory.com/360" data-og-url="https://explorer89.tistory.com/360" data-og-image="https://scrap.kakaocdn.net/dn/bR0F7D/hyYjtptys4/JH..
🤔 소셜 미디어 로그인 방법에서 Future를 사용한 이유? func signIn(with credential: AuthCredential) -> AnyPublisher { return Future { promise in Auth.auth().signIn(with: credential) { authResult, error in if let error = error { promise(.failure(error)) // 에러 처리 } else if let user = authResult?.user { promise(.success(user)) // 성공 } } } .eraseToAnyPublisher()}✅ ..
🤔 Combine에서 Future를 사용하는 이유 https://explorer89.tistory.com/361 🤔 Future란? (Combine의 비동기 처리)https://developer.apple.com/documentation/combine/future Future | Apple Developer DocumentationA publisher that eventually produces a single value and then finishes or fails.developer.apple.com 🚀 Future란? (초보자를 위한 쉬운 설명)Future는explorer89.tistory.com 🤔 Combine에서 Future를 쓰는 의미?Combine은 비동기 이벤트 스트림을 처리하는 프레임워크그런데 Combine의 기본 Publishe..