These are the required steps to add Firebase to your Capacitor project.
Prerequisites:
- You have already created a Firebase project (see Step 1: Create a Firebase project)
Note: The steps are based on the official Firebase instructions: Android / iOS / Web.
- Go to the Firebase console.
- In the center of the project overview page, click the Android icon to launch the setup workflow. If you've already added an app to your Firebase project, click Add app to display the platform options.
- Enter your app's package name (
capacitor.config.json
->appId
) in the Android package name field. - (Optional) Enter other app information: App nickname (
capacitor.config.json
->appName
) and Debug signing certificate SHA-1. - Click Register app.
-
Download and then add the Firebase Android configuration file (
google-services.json
) to your app:- Click Download google-services.json to obtain your Firebase Android config file.
- Move your config file into the module (app-level) root directory of your app:
/android/app/google-services.json
-
To make the values in your
google-services.json
config file accessible to Firebase SDKs, you need the Google services Gradle plugin (google-services
).-
In your root-level (project-level) Gradle file (
<project>/build.gradle
), add the Google services plugin as a buildscript dependency: https://github.com/robingenz/capacitor-firebase-plugin-demo/blob/9e0e2b245b1655271c7979357f32580a2a683168/android/build.gradle#L11 -
In your module (app-level) Gradle file (usually
<project>/<app-module>/build.gradle
), add the Google services plugin: https://github.com/robingenz/capacitor-firebase-plugin-demo/blob/9e0e2b245b1655271c7979357f32580a2a683168/android/app/build.gradle#L49
-
- Go to the Firebase console.
- In the center of the project overview page, click the iOS+ icon to launch the setup workflow. If you've already added an app to your Firebase project, click Add app to display the platform options.
- Enter your app's bundle ID (
capacitor.config.json
->appId
) in the bundle ID field. - (Optional) Enter other app information: App nickname (
capacitor.config.json
->appName
) and App Store ID. - Click Register app.
- Click Download GoogleService-Info.plist to obtain your Firebase Apple platforms config file (
GoogleService-Info.plist
). - Move your config file into the App root directory of your app:
/ios/App/App/GoogleService-Info.plist
. - Now register the file in your XCode project by dragging it from
/ios/App/App/GoogleService-Info.plist
into the XCode file explorer into the folder/App/App
. If prompted, select to add the config file to all targets.
- Go to the Firebase console.
- In the center of the project overview page, click the Web+ icon to launch the setup workflow. If you've already added an app to your Firebase project, click Add app to display the platform options.
- Enter your app's nickname. This nickname is an internal, convenience identifier and is only visible to you in the Firebase console.
- Click Register app.
- Follow the on-screen instructions to add and initialize the Firebase SDK in your app.