본문 바로가기

Ios

Ios - Firebase의 Authentication 사용하기

Firebase

 

Firebase

Firebase는 고품질 앱을 빠르게 개발하고 비즈니스를 성장시키는 데 도움이 되는 Google의 모바일 플랫폼입니다.

firebase.google.com

Firebase는 Backend as a Service — BaaS 이다.

 

모바일 애플리케이션을 위한 인증, 데이터베이스 등의 서비스를 제공하는데 이번에는 인증(Authentication)에 대해 정리해본다.

 

1. firebase 페이지에서의 준비 작업들을 진행한다.

 

2. AppDelegate.swift 파일에서 didFinishLaunchingWithOptions: 메소드의 내부에 FirebaseApp.configure() 코드를 작성한다.

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        FirebaseApp.configure()
        return true
    }

 

3. Sign up

sign up, sign in, sign out의 과정을 아래와 같은 메소드들을 추가하는 것으로 쉽게 구현 할 수 있다.

Auth.auth().createUser(withEmail: email, password: password) { authResult, error in
	// 코드 작성
}

비밀번호는 6자리 이상이어야함!

 

4. Sign in

Auth.auth().signIn(withEmail: email, password: password) { authResult, error in
	// 코드 작성
}

 

5. Sign out

do {
          try Auth.auth().signOut()
          // 코드 작성
            
        } catch let signOutError as NSError {
          print ("Error signing out: %@", signOutError)
        }

'Ios' 카테고리의 다른 글

Ios - 간단히 알아보는 UIAlert  (0) 2020.02.11
Ios - UITableView 기본  (0) 2020.02.10
Ios - CocoaPods  (0) 2020.01.23
Ios - CoreLocation  (0) 2020.01.15
Ios - API와 찰떡궁합 DispatchQueue.main.async  (0) 2020.01.14