# Firebase Setup

> Create a Firebase project and generate the three files Twinr needs for push notifications and analytics.

Push notifications and Firebase Analytics both run on **Firebase**, Google's app platform. Setting it up means creating one project and generating up to three files from it.

You do this once. The files are shared across features — upload a file under Push and it appears as already uploaded under Analytics, and the other way round.

### What you will generate

<table><thead><tr><th width="260">File</th><th width="130">Platform</th><th>Needed for</th></tr></thead><tbody><tr><td><code>google-services.json</code></td><td>Android</td><td>Push notifications, Firebase Analytics</td></tr><tr><td><code>GoogleService-Info.plist</code></td><td>iOS</td><td>Push notifications, Firebase Analytics</td></tr><tr><td>Service account key</td><td>Both</td><td>Push campaigns sent from <a href="https://help.twinr.dev/push/overview">Engage</a></td></tr></tbody></table>

> **Note:** **Google Sign-In does not use these files.** It needs three OAuth client IDs from Google Cloud Console instead — see [Google Sign-In](https://help.twinr.dev/native-integrations/google-sign-in).

### Before you begin

Firebase needs your app's identifiers, and they must match Twinr exactly.

<table><thead><tr><th width="300">You need</th><th>Where to find it</th></tr></thead><tbody><tr><td><strong>Android package name</strong></td><td><a href="https://help.twinr.dev/app-publishing/publishing-to-the-google-play-store/setup-android-signing-information">Setup Android Signing Information</a></td></tr><tr><td><strong>iOS bundle ID</strong></td><td><a href="https://help.twinr.dev/app-publishing/publishing-to-the-apple-app-store/create-your-apple-bundle-id">Create Your Apple Bundle ID</a></td></tr></tbody></table>

Both look like `com.yourcompany.yourapp`.

> **Warning:** **Copy and paste these values — do not type them.** Firebase accepts whatever you enter and produces config files that upload without complaint. If the identifier is wrong by a single character, notifications simply never arrive, and nothing anywhere tells you why. This is the most common setup failure.

***

## 1. Create a Firebase project

### Open the Firebase console

Go to [console.firebase.google.com](https://console.firebase.google.com/) and sign in with a Google account.

> **Note:** Use a company account rather than a personal one. This project holds your app's messaging and analytics; if it sits in an individual's account and they leave, recovering it is difficult.

### Create the project

Click **Create a project**, enter a name — your app's name is the obvious choice — and continue.

### Choose whether to enable Google Analytics

Firebase offers Google Analytics during setup.

Enable it if you plan to use [Firebase Analytics](https://help.twinr.dev/native-integrations/firebase-analytics). Skip it if you only want push notifications — you can turn it on later.

### Open Project settings

Once the project is created, click the gear icon beside **Project Overview** and choose **Project settings**.

This is where every file in this guide comes from.

***

## 2. Create the Android file

`google-services.json` connects your Android app to the Firebase project.

### Add an Android app

In **Project settings**, scroll to **Your apps** and click the **Android** icon.

### Enter your package name

<table><thead><tr><th width="310">Field</th><th>What to enter</th></tr></thead><tbody><tr><td><strong>Android package name</strong></td><td>Your Twinr Android package name, pasted exactly.</td></tr><tr><td><strong>App nickname</strong></td><td>Optional. A label used only inside Firebase.</td></tr><tr><td><strong>Debug signing certificate SHA-1</strong></td><td>Leave empty. Twinr does not require it.</td></tr></tbody></table>

Click **Register app**.

> **Important:** The package name **cannot be changed** after the app is registered. If you get it wrong, register a second Android app with the correct name — an unused one does no harm.

### Download google-services.json

Click **Download google-services.json**.

Firebase then shows SDK installation instructions. **Skip them** — they are for developers adding Firebase to code by hand. Twinr handles that for you.

### Upload it to Twinr

Open **Integrations → Push → Firebase** (the page is titled Firebase Notifications) or **Integrations → Analytics → Firebase Analytics**. Click **Upload google-services.json** under **Config files**, then **Save as draft**.

The **Analytics** item in the left menu is App Analytics. It has no upload fields.

***

## 3. Create the iOS file

`GoogleService-Info.plist` connects your iOS app to the same Firebase project.

### Add an iOS app

In **Project settings → Your apps**, click the **iOS+** icon.

### Enter your bundle ID

<table><thead><tr><th width="310">Field</th><th>What to enter</th></tr></thead><tbody><tr><td><strong>Apple bundle ID</strong></td><td>Your Twinr iOS bundle ID, pasted exactly.</td></tr><tr><td><strong>App nickname</strong></td><td>Optional. A label used only inside Firebase.</td></tr><tr><td><strong>App Store ID</strong></td><td>Leave empty. It is not needed here.</td></tr></tbody></table>

Click **Register app**.

> **Important:** The bundle ID **cannot be changed** after the app is registered, exactly as with Android.

### Download GoogleService-Info.plist

Click **Download GoogleService-Info.plist**.

Skip the Xcode and SDK steps that follow.

### Upload it to Twinr

Open **Integrations → Push → Firebase** or **Integrations → Analytics → Firebase Analytics**. Click **Upload GoogleService-Info.plist** under **Config files**, then **Save as draft**.

> **Tip:** **Add both platforms, even if you only ship one today.** It costs nothing, and it means the other build works the day you decide to release it instead of sending you back here.

***

## 4. Create the service account key

The two config files let your app **receive** notifications. Sending campaigns from [Engage](https://help.twinr.dev/push/overview) needs one more file: a **service account key**, which authorises Twinr to send on your behalf.

> **Note:** Only required if you run push campaigns from Engage. Push notifications you send yourself from the Firebase console work without it.

### Open the Service accounts tab

In **Project settings**, select the **Service accounts** tab.

### Generate a private key

Click **Generate new private key**, then confirm.

A `.json` file downloads immediately.

### Store it safely

> **Important:** **This file is a credential, not a config file.** Anyone holding it can send notifications to your app's users. Firebase shows it once and cannot show it again — store it somewhere safe, never commit it to a repository, and never put it on a web page.

### Upload it to Twinr

Open **Integrations → Push → Firebase**, click **Upload secret key** under **Firebase secret key**, then **Save as draft**. This file is only on the Push page, not under Firebase Analytics.

If Twinr rejects the file, it is not a valid service account key — generate a fresh one rather than reusing `google-services.json`, which is a different file.

***

## Where the files are used

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Push notifications</strong></td><td>Both config files, plus the service account key for Engage campaigns.</td><td><a href="https://help.twinr.dev/push/firebase-push-notification/enable-push-notification">enable-push-notification.md</a></td></tr><tr><td><strong>Firebase Analytics</strong></td><td>Both config files.</td><td><a href="https://help.twinr.dev/native-integrations/firebase-analytics">README.md</a></td></tr></tbody></table>

## Frequently asked questions

**Do I need a paid Firebase plan?**

No. The free Spark plan covers push notifications and analytics for most apps.

**I already uploaded a file for one feature. Do I upload it again for the other?**

No. `google-services.json` and `GoogleService-Info.plist` are shared. Upload either one under Push and it shows as uploaded under Firebase Analytics, and the other way round.

**I lost a config file.**

Download it again from **Project settings → Your apps**. Config files are not secrets and can be downloaded as often as you like.

The service account key is different — Firebase cannot show it again. Generate a new one and upload that.

**Can I use a Firebase project I already have?**

Yes, provided you add apps matching your Twinr bundle ID and package name. A project created for a website or a different app will not have them.

**I changed my package name or bundle ID in Twinr.**

Register a new app in Firebase with the new identifier, download its config file, and upload that. The old file points at the old identifier and stops working.

**Notifications arrive on Android but not iOS.**

Check that an iOS app is registered in the same Firebase project and that `GoogleService-Info.plist` came from it. A `.plist` from a different project uploads normally and never delivers.

Source: https://help.twinr.dev/push/firebase-push-notification/firebase-setup
