8. 2. Firebase 프로젝트 생성하기
● https://console.firebase.google.com/
● “프로젝트 추가 버튼” 클릭
● “Google 애널리틱스 사용 설정” off
9. 3. “이메일/비밀번호” 인증 기능 활성화
● “Build(빌드)”탭에서 “Authentication” 클릭
● “Sign-in method”의 “Email/Password” 사용
10. 4. Cloud Firestore 기능 활성화
● “Build(빌드)”탭에서 “Cloud Firestore” 클릭
● “Create database(데이터베이스 만들기)” 클릭
● “Start in test mode(테스트 모드에서 시작)” 클릭
● 다중 지역 “asia-northeast3” 선택
11. 5. firebase 관련 라이브러리 설치 및 설정
// 프로젝트 루트 디렉토리에서 다음 명령어 실행
flutter pub add firebase_core
flutter pub add firebase_auth
flutter pub add cloud_firestore
flutter pub add provider
dart pub global activate flutterfire_cli
flutterfire configure // 4번 슬라이드에서 생성한 파이어베이스 프로젝트 선택
12. 6. 메시지 작성을 위한 보안 규칙 설정
https://firebase.google.com/docs/firestore/security/rules-conditions?hl=ko&authuser=0
// lib/main.dart
_guestBookSubscription = FirebaseFirestore.instance
.collection('guestbook')
.orderBy('timestamp', descending: true)
.snapshots()
.listen((snapshot) {
…
…
});
13. 6.1 메시지 작성을 위한 보안 규칙 설정
https://firebase.google.com/docs/firestore/security/rules-conditions?hl=ko&authuser=0
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /guestbook/{entry} {
allow read: if true;
allow write: if true;
}
}
}
14. 6.2 메시지 작성을 위한 보안 규칙 설정
https://firebase.google.com/docs/firestore/security/rules-conditions?hl=ko&authuser=0
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /guestbook/{entry} {
allow read: if request.auth.uid != null;
allow write:
if request.auth.uid == request.resource.data.userId
&& "name" in request.resource.data
&& "text" in request.resource.data
&& "timestamp" in request.resource.data;
}
}
}
15. 7. 출석 체크를 위한 보안 규칙 설정
// lib/main.dart
_attendingSubscription = FirebaseFirestore.instance
.collection('attendees')
.doc(user.uid)
.snapshots()
.listen((snapshot) {
…
});
16. 7.1 출석 체크를 위한 보안 규칙 설정
rules_version = '2';
service cloud.firestore {
…
match /attendees/{userId} {
allow read: if true;
allow write: if true;
}
}
}
17. 7.2 출석 체크를 위한 보안 규칙 설정
rules_version = '2';
service cloud.firestore {
…
match /attendees/{userId} {
allow read: if true;
allow write: if request.auth.uid == userId
&& "attending" in request.resource.data;
}
}
}
18. 8. 메시지 오른쪽에 삭제 버튼 추가하기
# lib/main.dart
// TODO: 메시지 옆에 삭제 버튼을 삽입해보세요.
19. 9. 삭제 버튼 눌렀을 때, 메시지 삭제시키기
# lib/main.dart
// TODO: 메시지가 눌렸을 때, 실제 firestore의 다큐멘트를 지우는 코드를 작성해보세요!