diff --git a/docs/outline/chapter5.md b/docs/outline/chapter5.md index cc444c2..c891546 100644 --- a/docs/outline/chapter5.md +++ b/docs/outline/chapter5.md @@ -5,7 +5,52 @@ flutter pub add firebase_core flutter pub add cloud_firestore ``` -[GitHub Discussions](https://github.com/FlutterKaigi/tic_tac_toe_handson/discussions) から `firebase-options.dart` を取得し、Libに追加します。 +`firebase_options.dart` をLibに追加します。 + +```dart +// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members +import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; +import 'package:flutter/foundation.dart' + show defaultTargetPlatform, kIsWeb, TargetPlatform; + +class DefaultFirebaseOptions { + static FirebaseOptions get currentPlatform { + if (kIsWeb) { + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for web - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + } + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return android; + case TargetPlatform.iOS: + return ios; + default: + throw UnsupportedError( + 'DefaultFirebaseOptions are not supported for this platform.', + ); + } + } + + static const FirebaseOptions android = FirebaseOptions( + apiKey: 'AIzaSyCCWnRieFsedimIvgsjNevAdUSb0dm1faY', + appId: '1:807943088200:android:d989c8a1b020562321907d', + messagingSenderId: '807943088200', + projectId: 'tic-tac-toe-handson', + storageBucket: 'tic-tac-toe-handson.appspot.com', + ); + + static const FirebaseOptions ios = FirebaseOptions( + apiKey: 'AIzaSyBZHELrAr4SRfXLYrxc4zF27P0R3sGsbi0', + appId: '1:807943088200:ios:125d7bfaa751582d21907d', + messagingSenderId: '807943088200', + projectId: 'tic-tac-toe-handson', + storageBucket: 'tic-tac-toe-handson.appspot.com', + iosBundleId: 'com.example.ticTacToeHandson', + ); +} +``` 次に `main.dart` を修正します。 ```dart @@ -40,7 +85,7 @@ classpath 'com.google.gms:google-services:4.3.10' ``` ### 2. iOSでのビルド準備を進める -iOSフォルダをXcodeで開いたのちに、Runnerに`google-services.json` を追加します。 +iOSフォルダをXcodeで開いたのちに、Runnerに[GitHub Discussions](https://github.com/FlutterKaigi/tic_tac_toe_handson/discussions) で取得した `GoogleService-Info.plist` を追加します。 このとき、「Copy items if needed」にチェックを入れて追加してください。 ![Alt text](../public/chapter5/add_plist.png)