From ca0d5928bcc7bde669cd37b1ba6605763490d7b9 Mon Sep 17 00:00:00 2001 From: Mao Date: Tue, 31 May 2022 09:59:39 +0900 Subject: [PATCH 1/3] feat: add firebase config to example --- example/android/app/build.gradle | 4 ++ example/android/app/google-services.json | 39 ++++++++++++++ example/android/build.gradle | 4 ++ example/ios/firebase_app_id_file.json | 7 +++ example/lib/firebase_options.dart | 69 ++++++++++++++++++++++++ 5 files changed, 123 insertions(+) create mode 100644 example/android/app/google-services.json create mode 100644 example/ios/firebase_app_id_file.json create mode 100644 example/lib/firebase_options.dart diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 6f92c449c..09255ea4d 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -22,6 +22,10 @@ if (flutterVersionName == null) { } apply plugin: 'com.android.application' +// START: FlutterFire Configuration +apply plugin: 'com.google.gms.google-services' +apply plugin: 'com.google.firebase.firebase-perf' +// END: FlutterFire Configuration apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" diff --git a/example/android/app/google-services.json b/example/android/app/google-services.json new file mode 100644 index 000000000..fdfa9de3e --- /dev/null +++ b/example/android/app/google-services.json @@ -0,0 +1,39 @@ +{ + "project_info": { + "project_number": "223276840801", + "project_id": "flutter-gen-5b267", + "storage_bucket": "flutter-gen-5b267.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:223276840801:android:8c43b96e396a1781b77720", + "android_client_info": { + "package_name": "com.example.example" + } + }, + "oauth_client": [ + { + "client_id": "223276840801-vd883eedtkum45svga4m9dqpppacohpi.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyBqCLgp5h6_dHlMJzKSsCfnSFawfFjCK1c" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "223276840801-vd883eedtkum45svga4m9dqpppacohpi.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/example/android/build.gradle b/example/android/build.gradle index 0194ec718..74678c2f7 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -7,6 +7,10 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:7.2.0' + // START: FlutterFire Configuration + classpath 'com.google.gms:google-services:4.3.10' + classpath 'com.google.firebase:perf-plugin:1.4.1' + // END: FlutterFire Configuration classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/example/ios/firebase_app_id_file.json b/example/ios/firebase_app_id_file.json new file mode 100644 index 000000000..953acfea1 --- /dev/null +++ b/example/ios/firebase_app_id_file.json @@ -0,0 +1,7 @@ +{ + "file_generated_by": "FlutterFire CLI", + "purpose": "FirebaseAppID & ProjectID for this Firebase app in this directory", + "GOOGLE_APP_ID": "1:223276840801:ios:b5be85aa3c64059db77720", + "FIREBASE_PROJECT_ID": "flutter-gen-5b267", + "GCM_SENDER_ID": "223276840801" +} \ No newline at end of file diff --git a/example/lib/firebase_options.dart b/example/lib/firebase_options.dart new file mode 100644 index 000000000..b76df0c07 --- /dev/null +++ b/example/lib/firebase_options.dart @@ -0,0 +1,69 @@ +// File generated by FlutterFire CLI. +// 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; + +/// Default [FirebaseOptions] for use with your Firebase apps. +/// +/// Example: +/// ```dart +/// import 'firebase_options.dart'; +/// // ... +/// await Firebase.initializeApp( +/// options: DefaultFirebaseOptions.currentPlatform, +/// ); +/// ``` +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; + case TargetPlatform.macOS: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for macos - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.windows: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for windows - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.linux: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for linux - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + default: + throw UnsupportedError( + 'DefaultFirebaseOptions are not supported for this platform.', + ); + } + } + + static const FirebaseOptions android = FirebaseOptions( + apiKey: 'AIzaSyBqCLgp5h6_dHlMJzKSsCfnSFawfFjCK1c', + appId: '1:223276840801:android:8c43b96e396a1781b77720', + messagingSenderId: '223276840801', + projectId: 'flutter-gen-5b267', + storageBucket: 'flutter-gen-5b267.appspot.com', + ); + + static const FirebaseOptions ios = FirebaseOptions( + apiKey: 'AIzaSyChOfD8XNEdGZtB3Gdqg9J5GRLgUuH9jo8', + appId: '1:223276840801:ios:b5be85aa3c64059db77720', + messagingSenderId: '223276840801', + projectId: 'flutter-gen-5b267', + storageBucket: 'flutter-gen-5b267.appspot.com', + iosClientId: '223276840801-p876k56nj46ka6r8bmhkj5s6qiopoe1l.apps.googleusercontent.com', + iosBundleId: 'com.example.example', + ); +} From 900840765a551ae66d1be78b23c754bf009c5912 Mon Sep 17 00:00:00 2001 From: Mao Date: Tue, 31 May 2022 10:03:49 +0900 Subject: [PATCH 2/3] chore: format --- example/ios/Podfile.lock | 6 ++++++ example/lib/firebase_options.dart | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 725f46677..6a6fccb16 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -240,6 +240,8 @@ PODS: - Flutter - in_app_review (0.2.0): - Flutter + - integration_test (0.0.1): + - Flutter - is_firebase_test_lab_activated (0.0.1): - Flutter - libwebp (1.2.1): @@ -336,6 +338,7 @@ DEPENDENCIES: - image_editor (from `.symlinks/plugins/image_editor/ios`) - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) - in_app_review (from `.symlinks/plugins/in_app_review/ios`) + - integration_test (from `.symlinks/plugins/integration_test/ios`) - is_firebase_test_lab_activated (from `.symlinks/plugins/is_firebase_test_lab_activated/ios`) - local_auth_ios (from `.symlinks/plugins/local_auth_ios/ios`) - native_device_orientation (from `.symlinks/plugins/native_device_orientation/ios`) @@ -444,6 +447,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/image_picker_ios/ios" in_app_review: :path: ".symlinks/plugins/in_app_review/ios" + integration_test: + :path: ".symlinks/plugins/integration_test/ios" is_firebase_test_lab_activated: :path: ".symlinks/plugins/is_firebase_test_lab_activated/ios" local_auth_ios: @@ -532,6 +537,7 @@ SPEC CHECKSUMS: image_editor: c1d038630eedea60d2dee9c14f36aa66c7f9cfab image_picker_ios: b786a5dcf033a8336a657191401bfdf12017dabb in_app_review: 4a97249f7a2f539a0f294c2d9196b7fe35e49541 + integration_test: a1e7d09bd98eca2fc37aefd79d4f41ad37bdbbe5 is_firebase_test_lab_activated: 84effe92e5d79a58455a2861b5e1ba688016cf57 libwebp: 98a37e597e40bfdb4c911fc98f2c53d0b12d05fc local_auth_ios: 0d333dde7780f669e66f19d2ff6005f3ea84008d diff --git a/example/lib/firebase_options.dart b/example/lib/firebase_options.dart index b76df0c07..747b24735 100644 --- a/example/lib/firebase_options.dart +++ b/example/lib/firebase_options.dart @@ -63,7 +63,8 @@ class DefaultFirebaseOptions { messagingSenderId: '223276840801', projectId: 'flutter-gen-5b267', storageBucket: 'flutter-gen-5b267.appspot.com', - iosClientId: '223276840801-p876k56nj46ka6r8bmhkj5s6qiopoe1l.apps.googleusercontent.com', + iosClientId: + '223276840801-p876k56nj46ka6r8bmhkj5s6qiopoe1l.apps.googleusercontent.com', iosBundleId: 'com.example.example', ); } From cf0ae238e063c4ebe37bb5878e2a30931be6e973 Mon Sep 17 00:00:00 2001 From: Mao Date: Tue, 31 May 2022 10:08:48 +0900 Subject: [PATCH 3/3] feat: initializeApp at main --- example/lib/main.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 851e8e19e..2948e4528 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,11 +1,18 @@ +import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'package:example_resources/gen/assets.gen.dart' as res; +import 'firebase_options.dart'; import 'gen/assets.gen.dart'; import 'gen/colors.gen.dart'; import 'gen/fonts.gen.dart'; -void main() { +void main() async { + WidgetsFlutterBinding.ensureInitialized(); + await Firebase.initializeApp( + options: DefaultFirebaseOptions.currentPlatform, + ); + runApp(MaterialApp( title: 'Flutter Demo', theme: ThemeData(