Skip to content

Commit

Permalink
Merge pull request #21 from FlutterKaigi/topic/add_firebae_options.dart
Browse files Browse the repository at this point in the history
📚 firebase_optionsのコピペを追加
  • Loading branch information
okaryo committed Oct 21, 2023
2 parents 8da21a7 + e1128e1 commit 593a35f
Showing 1 changed file with 47 additions and 2 deletions.
49 changes: 47 additions & 2 deletions docs/outline/chapter5.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 593a35f

Please sign in to comment.