Skip to content

Latest commit

 

History

History
89 lines (51 loc) · 5.15 KB

File metadata and controls

89 lines (51 loc) · 5.15 KB
  1. If you have a Firebase account, sign in to it. If you don't have one, you'll need to create a Firebase account A free plan is sufficient for this codelab (and most development for most apps).

  2. In the Firebase console, click Add project.

  3. Enter a name for your Firebase project (for example, "Flutter Essentials"), then set the country/region to the location of your company or organization. Click Create project.

  4. After a minute or so, your Firebase project will be ready. Click Continue.

  5. After you've created a Firebase project, you can configure one (or more) apps to use that Firebase project. All you need to do is:

    • Register your app's platform-specific ID with Firebase
    • Generate configuration files for your app, then add them to your project folders

If you're developing your Flutter app for both iOS and Android, you need to register both the iOS and Android versions within the same Firebase project. If you're just developing for one platform, just skip the unneeded section.

In the top-level directory of your Flutter app, there are subdirectories called ios and android. These directories hold the platform-specific configuration files for iOS and Android, respectively.

Configure iOS

  1. In the Firebase console, select Project Overview in the left nav, then click the iOS button under "Get started by adding Firebase to your app".

  2. The important value to provide is the iOS bundle ID, which you'll obtain using the following three steps. ( Read here for more information about iOS bundle IDs.)

  3. In the command line tool, go to the top-level directory of your Flutter app.

  4. Run the command open ios/Runner.xcworkspace to open Xcode. (Read here for more information about Xcode property lists.)

  5. In Xcode, click the top-level Runner in the left pane to show the General tab in the right pane. Copy the Bundle Identifier value.

  6. Back in the Firebase dialog, paste the copied Bundle Identifier into the iOS bundle ID field, then click Register App. (The actual values of yourcompany and yourproject depend on what you named your Flutter app.)

  7. Continuing in Firebase, follow the instructions to download the config file GoogleService-Info.plist.

  8. Go back to Xcode. Notice that Runner has a subfolder also called Runner.

  9. Drag the GoogleService-Info.plist file (that you just downloaded) into that Runner subfolder.

  10. In the dialog that appears in Xcode, click Finish.

  11. Go back to the Firebase console. In the setup step, click Next, then skip the remaining steps and go back to the main page of the Firebase console.

You're done configuring your Flutter app for iOS!

Configure Android

  1. In the Firebase Console, select Project Overview in the left nav, then click the Android button under "Get started by adding Firebase to your app". (If you've already added an app (for example, the iOS app from the preceding section), click Add app.)

  2. The important value to provide is the Android package name, which you'll obtain using the following two steps. (Read here for more information about package and application IDs.)

  3. In your Flutter app directory, open the file android/app/src/main/AndroidManifest.xml.

  4. In the manifest element, find the string value of the package attribute. This value is the Android package name (something like com.yourcompany.yourproject). Copy this value.

  5. In the Firebase dialog, paste the copied package name into the Android package name field.

  6. Click Register App.

  7. Continuing in Firebase, follow the instructions to download the config file google-services.json.

  8. Go to your Flutter app directory, then move the google-services.json file (that you just downloaded) into the android/app directory.

  9. Back in the Firebase console, skip the remaining steps and go back to the main page of the Firebase console.

  10. Finally, you need the Google Services Gradle plugin to read the google-services.json file that was generated by Firebase.

apply plugin: 'com.google.gms.google-services'
  1. Open android/build.gradle, then inside the buildscript tag, add a new dependency:
buildscript {
   repositories {
       // ...
   }

   dependencies {
       // ...
       classpath 'com.google.gms:google-services:3.2.1'   // new
   }
}

This line specifies version 3.2.1 of the plugin (do not use higher version). For more information, see the Add the SDK section of the Add Firebase to Your Android Project documentation.

You're done configuring your Flutter app for Android!