Google, Apple, 이메일/비밀번호와 같은 인기 제공자와의 원활한 인증을 가능하게 하는 Firebase Auth UI를 통합하는 플러터 플러그인입니다. 안드로이드 및 iOS용 네이티브 SDK를 활용하여 일관되고 플랫폼 최적화된 사용자 경험을 제공합니다. 미리 구축된 UI 컴포넌트를 제공함으로써 구현을 단순화하고 뼈대 코드를 줄입니다. 커스텀 인터페이스를 처음부터 만들지 않고도 빠르고 신뢰할 수 있는 인증 흐름이 필요한 앱에 이상적입니다.
사용 사례
Google 로그인 통합
Apple ID 로그인 활성화
이메일/비밀번호 인증 추가
보안 사용자 온보딩 구축
여러 인증 제공자 지원
로그인 UI 개발 간소화
주요 기능
네이티브 SDK 통합
사전 빌드된 인증 UI
Google, Apple 및 이메일/비밀번호 지원
크로스 플랫폼 호환성
최소한의 설정 필요
보안 인증 흐름
적합한 대상
Firebase를 사용하는 모바일 앱
빠른 인증 구현을 찾는 개발자
다중 공급자 지원이 필요한 앱
사용자 경험을 우선시하는 프로젝트
최소한의 커스텀 UI 코딩을 원하는 팀
고려 사항
Firebase 프로젝트 설정이 필요합니다
UI 컴포넌트의 사용자 정의가 제한적
완전한 기능을 위해 네이티브 SDK에 의존합니다
네이티브 종속성으로 인해 앱 크기가 증가할 수 있습니다
높은 사용자 지정 인증 흐름에는 적합하지 않습니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
firebase_auth_ui
Flutter plugin of Firebase UI which allows to add login/sign-up quickly.
NOTE: This plugin is under development. Please provide Feedback and Pull Requests in order to have your feature(s) integrated.
FirebaseAuthUi.instance()
.launchAuth(
[
AuthProvider.email(), // Login/Sign up with Email and passwordAuthProvider.google(), // Login with GoogleAuthProvider.facebook(), // Login with FacebookAuthProvider.twitter(), // Login with TwitterAuthProvider.phone(), // Login with Phone number
],
tosUrl: "https://my-terms-url", // Optional
privacyPolicyUrl: "https://my-privacy-policy", // Optional,
)
.then((firebaseUser) =>
print("Logged in user is ${firebaseUser.displayName}"))
.catchError((error) => print("Error $error"));
Logout
voidlogout() async {
final result = awaitFirebaseAuthUi.instance().logout();
// ...
}
Delete
voiddelete() async {
final result = awaitFirebaseAuthUi.instance().delete();
// ...
}
Plugin returns FirebaseUser with following details:
Field
Description
uid
UID of authenticated user
displayName
Display name of user
email
Email of user
phoneNumber
Phone number of user
photoUri
URI of user's photo
providerId
Indicates through which provider user was authenticated.
isNewUser
Indicates if user is new
metaData
Object of MetaData
MetaData
Field
Description
creationTimestamp
Timestamp of user's creation
lastSignInTimestamp
Timestamp of user's last sign in
Notes:
Above details may be null depending on the provider user used to sign and user's privacy settings on respective provider.
creationTimestamp seems to return wrong value sometimes on Android.
If you want to have full FirebaseUser object then please add firebase_auth dependency. You can then use FirebaseAuth.instance.currentUser().
Configuration
Create a project on Firebase console and add Android and iOS platform in Settings > Your apps
Open the Authentication section and then navigate to Sign in method. Please enable Email/Password, Google, Facebook, Twitter and Phone method depending on your need and click save.
Navigate back to Settings > Your apps
Download "google-services.json" for Android
Download "GoogleService-Info.plist"for iOS
Android
Open project's build.gradle ([flutter_project]/android/build.gradle) and add following in dependencies{ ... }:
classpath 'com.google.gms:google-services:4.3.2'
Open app module's build.gradle ([flutter_project]/android/app/build.gradle) and add following at the end of file, i.e as a last line:
apply plugin: 'com.google.gms.google-services'
Copy the downloaded google-services.json in [flutter_project]/android/app directory.
iOS
Copy the downloaded GoogleService-Info.plist in [[flutter_project]/ios/Runner directory.
Additional setup for Google, Facebook, Twitter and Phone sign-in
Google
Android
No additional setup required.
iOS
Open the GoogleService-Info.plist and copy REVERSED_CLIENT_ID. It should look like com.googleusercontent.apps.[APP_ID-somevalue]
Now open "Info.plist" ([flutter_project]/ios/Runner and paste following by replacing [REVERSED_CLIENT_ID] with yours copied in above step:
Add fbFACEBOOK_APP_ID as a URL scheme
Open open Info.plist ([flutter_project]/ios/Runner and paste following by replacing [YOUR_FACEBOOK_APP_ID] with yours:
NOTE: If you have configured Google sign-in by following above steps, you already have CFBundleURLSchemes key defined with [REVERSE_CLIENT_ID]. In that case, just add
If you have already configured Google sign-in for iOS following above steps, then you don't need to do anything else. If not, please follow the exact same step.
Phone number
Android
No additional setup required.
iOS
If you have already configured Google sign-in for iOS following above steps, then you don't need to do anything else. If not, please follow the exact same step.
Customization
Add logo
Rename your icon to auth_ui_logo.png then follow below steps:
Android
Place the png file in [flutter_project]/android/app/src/main/res/drawable
iOS
Create an imageset with auth_ui_logo and place the png inside it. For creating the imageset, you can open the iOS project in XCode and then drag and drop the png image in Assets.
Android specific
Actionbar title:
Define your app's name in strings.xml and that'll appear as title in action bar.
Actionbar and status bar color:
Add following in your colors.xml [flutter_project]/android/app/src/main/res/values
Note: If you don't have colors.xml, please create one.
Misc
The order of login buttons depends on the sequence of AuthProviders you passed in launchAuth(). For example if you have Email, Google and Facebook auth configured and would like the Facebook to appear first, you can simply pass the AuthProvider.facebook() as first element in the providers list.