From 6d1b55f7f6c2d3e6449be599ab97384a38b295d1 Mon Sep 17 00:00:00 2001 From: pr_Mais Date: Fri, 31 Dec 2021 17:44:41 +0300 Subject: [PATCH 01/11] feat: anlytics example app initialization on Android --- .../example/android/app/build.gradle | 1 + .../example/lib/firebase_cofig.dart | 43 +++++++++++++++++++ .../firebase_analytics/example/lib/main.dart | 20 ++++----- 3 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 packages/firebase_analytics/firebase_analytics/example/lib/firebase_cofig.dart diff --git a/packages/firebase_analytics/firebase_analytics/example/android/app/build.gradle b/packages/firebase_analytics/firebase_analytics/example/android/app/build.gradle index a0bf0145a797..a6d359587145 100755 --- a/packages/firebase_analytics/firebase_analytics/example/android/app/build.gradle +++ b/packages/firebase_analytics/firebase_analytics/example/android/app/build.gradle @@ -23,6 +23,7 @@ if (flutterVersionName == null) { apply plugin: 'com.android.application' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" +apply plugin: 'com.google.gms.google-services' android { compileSdkVersion 29 diff --git a/packages/firebase_analytics/firebase_analytics/example/lib/firebase_cofig.dart b/packages/firebase_analytics/firebase_analytics/example/lib/firebase_cofig.dart new file mode 100644 index 000000000000..066b7dd44862 --- /dev/null +++ b/packages/firebase_analytics/firebase_analytics/example/lib/firebase_cofig.dart @@ -0,0 +1,43 @@ +import 'dart:developer'; +import 'dart:io'; + +import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter/foundation.dart'; + +class DefaultFirebaseConfig { + static FirebaseOptions? get platformOptions { + if (kIsWeb) { + // Web + return const FirebaseOptions( + apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0', + authDomain: 'react-native-firebase-testing.firebaseapp.com', + databaseURL: 'https://react-native-firebase-testing.firebaseio.com', + projectId: 'react-native-firebase-testing', + storageBucket: 'react-native-firebase-testing.appspot.com', + messagingSenderId: '448618578101', + appId: '1:448618578101:web:0b650370bb29e29cac3efc', + measurementId: 'G-F79DJ0VFGS', + ); + } else if (Platform.isIOS || Platform.isMacOS) { + // iOS and MacOS + return const FirebaseOptions( + appId: '1:448618578101:ios:cc6c1dc7a65cc83c', + apiKey: 'AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0', + projectId: 'react-native-firebase-testing', + messagingSenderId: '448618578101', + iosBundleId: 'com.invertase.testing', + iosClientId: + '448618578101-28tsenal97nceuij1msj7iuqinv48t02.apps.googleusercontent.com', + androidClientId: + '448618578101-a9p7bj5jlakabp22fo3cbkj7nsmag24e.apps.googleusercontent.com', + databaseURL: 'https://react-native-firebase-testing.firebaseio.com', + storageBucket: 'react-native-firebase-testing.appspot.com', + ); + } else { + // Android + log("Analytics Dart-only initializer doesn't work on Android, please make sure to add the config file."); + + return null; + } + } +} diff --git a/packages/firebase_analytics/firebase_analytics/example/lib/main.dart b/packages/firebase_analytics/firebase_analytics/example/lib/main.dart index 3535bc694b21..9fd0d4c27a66 100755 --- a/packages/firebase_analytics/firebase_analytics/example/lib/main.dart +++ b/packages/firebase_analytics/firebase_analytics/example/lib/main.dart @@ -8,22 +8,12 @@ import 'package:firebase_analytics/firebase_analytics.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; +import 'firebase_cofig.dart'; import 'tabs_page.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); - await Firebase.initializeApp( - options: const FirebaseOptions( - apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0', - authDomain: 'react-native-firebase-testing.firebaseapp.com', - databaseURL: 'https://react-native-firebase-testing.firebaseio.com', - projectId: 'react-native-firebase-testing', - storageBucket: 'react-native-firebase-testing.appspot.com', - messagingSenderId: '448618578101', - appId: '1:448618578101:web:772d484dc9eb15e9ac3efc', - measurementId: 'G-0N1G9FLDZE', - ), - ); + await Firebase.initializeApp(options: DefaultFirebaseConfig.platformOptions); runApp(const MyApp()); } @@ -70,6 +60,12 @@ class MyHomePage extends StatefulWidget { class _MyHomePageState extends State { String _message = ''; + @override + void initState() { + FirebaseAnalytics.instance.setUserProperty(name: "key", value: null); + super.initState(); + } + void setMessage(String message) { setState(() { _message = message; From 8f98a47b082f7850e0646bf6e219e8bf93a8aabb Mon Sep 17 00:00:00 2001 From: pr_Mais Date: Fri, 31 Dec 2021 18:16:45 +0300 Subject: [PATCH 02/11] docs: add the Dart initialization support status --- docs/cli.mdx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/cli.mdx b/docs/cli.mdx index f4249a2213dc..6ce694195ede 100644 --- a/docs/cli.mdx +++ b/docs/cli.mdx @@ -20,6 +20,17 @@ Once installed, the `flutterfire` command will be globally available. ## Usage +:::note +Some plugins or platforms doesn't support Dart-only initialization **yet**, for which you will use the platform +config files through the [manual installation](./manual-installation.mdx), the following table shows the current +status of support, the plugins not in this table are fully supported. +::: +| Plugin | iOS | Android | Web | macOS | +| --------- | --- | ------- | --- | ----- | +| Analytics | ✔ | ❌ | ✔ | ✔ | +| Crashlytics | ❌ | ❌ | N/A | ✔ | +| Dynamic Links | ❌ | ✔ | N/A | N/A | + ### Generating Firebase Options FlutterFire can now be initialized from Dart on all platforms using `Firebase.initializeApp`, however From 9971f10a69d09b88066f50d078038ea7e770643e Mon Sep 17 00:00:00 2001 From: pr_Mais Date: Fri, 31 Dec 2021 18:34:38 +0300 Subject: [PATCH 03/11] chore: remove uneeded code --- .../firebase_analytics/example/lib/main.dart | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/firebase_analytics/firebase_analytics/example/lib/main.dart b/packages/firebase_analytics/firebase_analytics/example/lib/main.dart index 9fd0d4c27a66..77596c6a91d7 100755 --- a/packages/firebase_analytics/firebase_analytics/example/lib/main.dart +++ b/packages/firebase_analytics/firebase_analytics/example/lib/main.dart @@ -60,12 +60,6 @@ class MyHomePage extends StatefulWidget { class _MyHomePageState extends State { String _message = ''; - @override - void initState() { - FirebaseAnalytics.instance.setUserProperty(name: "key", value: null); - super.initState(); - } - void setMessage(String message) { setState(() { _message = message; From 1ad2f0c4f881160f57337a6c7c6588cb1cfca8da Mon Sep 17 00:00:00 2001 From: pr_Mais Date: Fri, 31 Dec 2021 19:10:00 +0300 Subject: [PATCH 04/11] chore: update support status --- docs/cli.mdx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/cli.mdx b/docs/cli.mdx index 6ce694195ede..822c5a4b79f0 100644 --- a/docs/cli.mdx +++ b/docs/cli.mdx @@ -28,8 +28,10 @@ status of support, the plugins not in this table are fully supported. | Plugin | iOS | Android | Web | macOS | | --------- | --- | ------- | --- | ----- | | Analytics | ✔ | ❌ | ✔ | ✔ | -| Crashlytics | ❌ | ❌ | N/A | ✔ | +| Crashlytics | ❌ | ❌ | N/A | ❌ | | Dynamic Links | ❌ | ✔ | N/A | N/A | +| In-App Messaging | ❌ | ✔ | N/A | ❌ | +| Performance Monitoring | ✔ | ❌ | ❌ | N/A | ### Generating Firebase Options From fb7b76c947552c18b94ee2ce7badbe7be0ede2e0 Mon Sep 17 00:00:00 2001 From: pr_Mais Date: Mon, 3 Jan 2022 11:24:55 +0300 Subject: [PATCH 05/11] docs: note on initialization for google sign in --- docs/auth/social.mdx | 20 ++++++++++++-------- docs/cli.mdx | 2 ++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/docs/auth/social.mdx b/docs/auth/social.mdx index 4270ceb03007..6fcd0c100c13 100644 --- a/docs/auth/social.mdx +++ b/docs/auth/social.mdx @@ -37,9 +37,13 @@ Install the official [`google_sign_in`](https://pub.dev/packages/google_sign_in) ```yaml title="pubspec.yaml" dependencies: - google_sign_in: "{{ external.google_sign_in }}" + google_sign_in: '{{ external.google_sign_in }}' ``` +:::caution +Dart-only initialization isn't yet support by `google_sign_in` plugin, in which case you still have to do the [manual installation](./manual-installation.mdx) if you're using Google as an auth provider. +::: + Once installed, trigger the sign-in flow and create a new credential: ```dart @@ -127,7 +131,7 @@ Install the [`flutter_facebook_auth`](https://pub.dev/packages/flutter_facebook_ ```yaml title="pubspec.yaml" dependencies: - flutter_facebook_auth: "{{ external.flutter_facebook_auth }}" + flutter_facebook_auth: '{{ external.flutter_facebook_auth }}' ``` You will need to follow the steps in the plugin documentation to ensure that both the Android & iOS Facebook SDKs have been initialized @@ -199,7 +203,6 @@ to `true` if your user logs in with Facebook. Should your user login using a pro For further information, see this [issue](https://github.com/FirebaseExtended/flutterfire/issues/4612#issuecomment-782107867). ::: - ## Apple Apple [announced](https://developer.apple.com/news/?id=09122019b) that any applications using 3rd party login @@ -283,12 +286,13 @@ Future signInWithApple() async { return await FirebaseAuth.instance.signInWithCredential(oauthCredential); } ``` + - At the moment, the preferable solution is blocked by this - [issue](https://github.com/FirebaseExtended/flutterfire/issues/2691). +At the moment, the preferable solution is blocked by this +[issue](https://github.com/FirebaseExtended/flutterfire/issues/2691). @@ -313,6 +317,7 @@ Future signInWithApple() async { An alternative is to use `signInWithRedirect`. In that case the browser will navigate away from your app and you have to use `getRedirectResult` to check for authentication results during app startup. + @@ -370,7 +375,7 @@ Future signInWithTwitter() async { On the web, the Twitter SDK provides support for automatically handling the authentication flow using the -Twitter application details provided on the Firebase console. Ensure that the callback URL in the Firebase console is added +Twitter application details provided on the Firebase console. Ensure that the callback URL in the Firebase console is added as a callback URL in your Twitter application on their developer console. For example: @@ -401,7 +406,6 @@ Ensure that you have setup an OAuth App from your [GitHub Developer Settings](ht that the "GitHub" sign-in provider is enabled on the [Firebase Console](https://console.firebase.google.com/project/_/authentication/providers) with the Client ID and Secret are set, with the callback URL set in the GitHub app. - signInWithGitHub() async { On the web, the GitHub SDK provides support for automatically handling the authentication flow using the -GitHub application details provided on the Firebase console. Ensure that the callback URL in the Firebase console is added +GitHub application details provided on the Firebase console. Ensure that the callback URL in the Firebase console is added as a callback URL in your GitHub application on the developer console. For example: diff --git a/docs/cli.mdx b/docs/cli.mdx index 822c5a4b79f0..000af4a486f4 100644 --- a/docs/cli.mdx +++ b/docs/cli.mdx @@ -33,6 +33,8 @@ status of support, the plugins not in this table are fully supported. | In-App Messaging | ❌ | ✔ | N/A | ❌ | | Performance Monitoring | ✔ | ❌ | ❌ | N/A | +In addition, [`google_sign_in` plugin](./auth/social#google) which is used by `firebase_auth` also requires manual installation. + ### Generating Firebase Options FlutterFire can now be initialized from Dart on all platforms using `Firebase.initializeApp`, however From aa5a883e8cbaf5d46b467c5ac4859394c7af6783 Mon Sep 17 00:00:00 2001 From: Mais Alheraki Date: Tue, 4 Jan 2022 16:03:10 +0300 Subject: [PATCH 06/11] Update docs/cli.mdx Co-authored-by: Russell Wheatley --- docs/cli.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cli.mdx b/docs/cli.mdx index 000af4a486f4..0c9e1604f915 100644 --- a/docs/cli.mdx +++ b/docs/cli.mdx @@ -22,7 +22,7 @@ Once installed, the `flutterfire` command will be globally available. :::note Some plugins or platforms doesn't support Dart-only initialization **yet**, for which you will use the platform -config files through the [manual installation](./manual-installation.mdx), the following table shows the current +config files through the [manual installation](./manual-installation.mdx). The following table shows the current status of support, the plugins not in this table are fully supported. ::: | Plugin | iOS | Android | Web | macOS | From addc4015dd73c32af413f74699362f063bb5b480 Mon Sep 17 00:00:00 2001 From: Mais Alheraki Date: Tue, 4 Jan 2022 16:03:20 +0300 Subject: [PATCH 07/11] Update docs/auth/social.mdx Co-authored-by: Russell Wheatley --- docs/auth/social.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/auth/social.mdx b/docs/auth/social.mdx index 6fcd0c100c13..e56b6c5e3931 100644 --- a/docs/auth/social.mdx +++ b/docs/auth/social.mdx @@ -41,7 +41,7 @@ dependencies: ``` :::caution -Dart-only initialization isn't yet support by `google_sign_in` plugin, in which case you still have to do the [manual installation](./manual-installation.mdx) if you're using Google as an auth provider. +Dart-only initialization isn't yet supported by `google_sign_in` plugin, in which case you still have to do the [manual installation](./manual-installation.mdx) if you're using Google as an auth provider. ::: Once installed, trigger the sign-in flow and create a new credential: From 7dfcc1afb70203914aa5693c4f44a269fbff5be2 Mon Sep 17 00:00:00 2001 From: Mais Alheraki Date: Tue, 4 Jan 2022 16:03:25 +0300 Subject: [PATCH 08/11] Update docs/cli.mdx Co-authored-by: Russell Wheatley --- docs/cli.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cli.mdx b/docs/cli.mdx index 0c9e1604f915..ad9d1d1d6650 100644 --- a/docs/cli.mdx +++ b/docs/cli.mdx @@ -21,7 +21,7 @@ Once installed, the `flutterfire` command will be globally available. ## Usage :::note -Some plugins or platforms doesn't support Dart-only initialization **yet**, for which you will use the platform +Some plugins or platforms do not support Dart-only initialization **yet**, for which you will use the platform config files through the [manual installation](./manual-installation.mdx). The following table shows the current status of support, the plugins not in this table are fully supported. ::: From d49d75228691a1b4bbc4a16e1d1bf797060f78a0 Mon Sep 17 00:00:00 2001 From: pr_Mais Date: Tue, 4 Jan 2022 16:06:17 +0300 Subject: [PATCH 09/11] chore: file name typo --- .../example/lib/{firebase_cofig.dart => firebase_config.dart} | 0 .../firebase_analytics/firebase_analytics/example/lib/main.dart | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename packages/firebase_analytics/firebase_analytics/example/lib/{firebase_cofig.dart => firebase_config.dart} (100%) diff --git a/packages/firebase_analytics/firebase_analytics/example/lib/firebase_cofig.dart b/packages/firebase_analytics/firebase_analytics/example/lib/firebase_config.dart similarity index 100% rename from packages/firebase_analytics/firebase_analytics/example/lib/firebase_cofig.dart rename to packages/firebase_analytics/firebase_analytics/example/lib/firebase_config.dart diff --git a/packages/firebase_analytics/firebase_analytics/example/lib/main.dart b/packages/firebase_analytics/firebase_analytics/example/lib/main.dart index 77596c6a91d7..dd59f73a9248 100755 --- a/packages/firebase_analytics/firebase_analytics/example/lib/main.dart +++ b/packages/firebase_analytics/firebase_analytics/example/lib/main.dart @@ -8,7 +8,7 @@ import 'package:firebase_analytics/firebase_analytics.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; -import 'firebase_cofig.dart'; +import 'firebase_config.dart'; import 'tabs_page.dart'; Future main() async { From 81e8f75747218bb7ec9864637949284a46aaa38d Mon Sep 17 00:00:00 2001 From: Mike Diarmid Date: Wed, 5 Jan 2022 13:21:03 +0000 Subject: [PATCH 10/11] Update docs/cli.mdx --- docs/cli.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/cli.mdx b/docs/cli.mdx index ad9d1d1d6650..82ac3b95dabd 100644 --- a/docs/cli.mdx +++ b/docs/cli.mdx @@ -21,9 +21,9 @@ Once installed, the `flutterfire` command will be globally available. ## Usage :::note -Some plugins or platforms do not support Dart-only initialization **yet**, for which you will use the platform -config files through the [manual installation](./manual-installation.mdx). The following table shows the current -status of support, the plugins not in this table are fully supported. +Some plugins or platforms do not fully support Dart-only Firebase initialization **yet**, if you need to use the plugins then the [manual installation](./manual-installation.mdx) steps should be followed first. + +The following table shows the current status of these plugins (plugins not shown in this table are fully supported via Dart-only Firebase initialization): ::: | Plugin | iOS | Android | Web | macOS | | --------- | --- | ------- | --- | ----- | From a34cc44a13d857a6c235f10d255573c34c41c171 Mon Sep 17 00:00:00 2001 From: Mike Diarmid Date: Wed, 5 Jan 2022 13:22:46 +0000 Subject: [PATCH 11/11] Update docs/auth/social.mdx --- docs/auth/social.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/auth/social.mdx b/docs/auth/social.mdx index e56b6c5e3931..9e6d5ada1345 100644 --- a/docs/auth/social.mdx +++ b/docs/auth/social.mdx @@ -41,7 +41,7 @@ dependencies: ``` :::caution -Dart-only initialization isn't yet supported by `google_sign_in` plugin, in which case you still have to do the [manual installation](./manual-installation.mdx) if you're using Google as an auth provider. +Dart-only Firebase initialization isn't yet supported by `google_sign_in` plugin, if you're using Google as an auth provider you'll still have to do the [manual installation](./manual-installation.mdx) steps to integrate the Firebase configuration files. ::: Once installed, trigger the sign-in flow and create a new credential: