diff --git a/docs/auth/social.mdx b/docs/auth/social.mdx index 4270ceb03007..9e6d5ada1345 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 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: ```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 f4249a2213dc..82ac3b95dabd 100644 --- a/docs/cli.mdx +++ b/docs/cli.mdx @@ -20,6 +20,21 @@ Once installed, the `flutterfire` command will be globally available. ## Usage +:::note +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 | +| --------- | --- | ------- | --- | ----- | +| Analytics | ✔ | ❌ | ✔ | ✔ | +| Crashlytics | ❌ | ❌ | N/A | ❌ | +| Dynamic Links | ❌ | ✔ | N/A | N/A | +| 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 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_config.dart b/packages/firebase_analytics/firebase_analytics/example/lib/firebase_config.dart new file mode 100644 index 000000000000..066b7dd44862 --- /dev/null +++ b/packages/firebase_analytics/firebase_analytics/example/lib/firebase_config.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..dd59f73a9248 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_config.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()); }