# Get your Apple and Firebase keys

Source: https://kirora.io/docs/guides/getting-started/get-push-keys

Create the Firebase project and Apple push key your apps need, step by step, even if you've never set up push before.

Kirora sends mobile push through the same services every app uses: Firebase Cloud Messaging for Android, and Apple Push Notification service (APNs) for iOS. Each one needs a key that proves you own the app. This guide walks through creating both, from an empty account to a key uploaded in Kirora.

| Platform | Where the key comes from | What you upload to Kirora | Cost |
| --- | --- | --- | --- |
| Android | A Firebase project | A service account file (`.json`) | Free. Firebase's free plan is enough. |
| iOS | Your Apple developer account | A push key file (`.p8`), its Key ID, your Team ID and the app's Bundle ID | Needs a paid Apple Developer Program membership |

iOS doesn't need Firebase. If your iOS app already uses Firebase for push, Kirora can send through it instead; see [Set up push](https://kirora.io/docs/guides/getting-started/set-up-push#finish-each-platforms-setup).

## Before you start

**Pick your app identifiers first.** Your iOS bundle ID and Android package name, such as `com.juniperkitchen.app`, get registered with Apple and Firebase, and you can't change them there afterwards. Use exactly the identifier your app is built with. For a demo or test app, use an identifier that's clearly separate from your live app, such as `com.juniperkitchen.demo`.

You'll need the **owner, admin or developer role** in Kirora, and a push app for each platform. For iOS, that's a **Production** app, plus a **Sandbox** app if you run builds straight from Xcode or `npx expo run:ios`. See [Add your first app](https://kirora.io/docs/guides/getting-started/set-up-push#add-your-first-app).

The keys only let Kirora send. To receive pushes, your app also needs one of Kirora's [mobile SDKs](https://kirora.io/docs/sdks#in-your-app) and a server route that signs user tokens.

## Android: set up Firebase

### 1. Create a Firebase project

1. Go to the [Firebase console](https://console.firebase.google.com) and sign in with a Google account.
2. Choose **Create a project**, or **Get started by setting up a Firebase project** if you have none yet. Give it a name, accept the Firebase terms and continue. Google Analytics is optional; you can turn it off.

*Screenshot: The Firebase console asking for a project name, with Juniper Kitchen entered*

### 2. Add your Android app

1. In the project, choose **Add app**, then the Android icon.
2. Enter your app's **Android package name**: the `applicationId` in your app's Gradle file, or `android.package` in an Expo app config. It must match exactly. If it's wrong, add a new Android app with the right one.
3. Choose **Register app**, then download **google-services.json**.

*Screenshot: Firebase's Add Firebase to your Android app form, with the package name com.juniperkitchen.demo entered*

This file tells your app which Firebase project to register with. It isn't a secret, but it belongs to this one app. Where it goes depends on how you build:

- **Native Android:** put it in your app module, usually `app/`. **React Native and Flutter:** put it in `android/app/`. The [Android](https://kirora.io/docs/sdks/android#send-push-notifications), [React Native](https://kirora.io/docs/sdks/react-native#android) and [Flutter](https://kirora.io/docs/sdks/flutter) SDK guides cover the Gradle plugin it needs.
- **Expo:** put it in your project root and set `android.googleServicesFile` in your app config. See the [Expo guide](https://kirora.io/docs/sdks/expo#2-add-the-plugin-to-your-app-config).

> **Tip:** On EAS Build, you can keep the file out of git. Once your project is linked to EAS (`eas login`, then `eas init`), upload it as a file environment variable with `eas env:set --name GOOGLE_SERVICES_JSON --type file --value ./google-services.json --visibility secret --environment production`, then set `android.googleServicesFile` to `process.env.GOOGLE_SERVICES_JSON ?? "./google-services.json"` in `app.config.js`. Create it in the same environment your build profile uses, such as `preview` for internal builds: EAS doesn't upload git-ignored files, so without the variable the build has no Firebase config.

### 3. Create a service account key

This is the key Kirora uses to send.

1. In the Firebase console, open **Settings** (the gear icon in the sidebar), then **Service accounts**.
2. Choose **Generate new private key**, then **Generate key**. A `.json` file downloads.

*Screenshot: Firebase's Service accounts settings, with Generate new private key at the bottom*

> **Warning:** This file lets anyone send push as your project. Never commit it, put it in your app or send it by email. Upload it only to Kirora, then delete the download or keep it in a password manager.

#### If Firebase says "Key creation is not allowed"

Your Firebase project belongs to a Google Cloud organization, such as your company's Google Workspace, and the organization blocks service account keys. Newer organizations block them by default. An organization admin can allow keys for this one project:

1. In the [Google Cloud console](https://console.cloud.google.com), select your **organization**, open **IAM & Admin › IAM**, and give yourself the **Organization Policy Administrator** role. Organization owners don't have it by default.
2. Select your **Firebase project**, open **IAM & Admin › Organization policies**, and open **Disable service account key creation**. Choose **Manage policy**, then **Override parent's policy**, set **Enforcement** to **Off**, and choose **Set policy**. If a second, managed policy with the same name is listed, turn it off the same way.
3. Wait a minute, then generate the key in Firebase again.

This allows keys in that one project only; the rest of your organization stays as it was. Alternatively, create the Firebase project with a personal Google account, which has no organization.

### 4. Upload it to Kirora

1. Open **Settings › Push apps** and your Android app.
2. Choose **Upload key**, pick the service account file, and choose **Upload key** again.

Kirora checks the key with Google before saving it. The `google-services.json` in your app and the service account you upload must come from the **same Firebase project**. If they don't, pushes never arrive.

## iOS: create an Apple push key

You need a paid Apple Developer Program membership and the **Account Holder** or **Admin** role in it.

### 1. Create the key

1. Sign in to [Apple Developer](https://developer.apple.com/account) and open **Certificates, Identifiers & Profiles**, then **Keys**.
2. Choose the **+** button and give the key a name, such as *Kirora push*.
3. Tick **Apple Push Notifications service (APNs)** and choose **Configure**. Set **Key Restriction** to **Team Scoped (All Topics)**, so the key works for every app in your team, and pick an **Environment**:
   - **Sandbox & Production:** one key for both of your iOS push apps. The simplest choice.
   - **Production**, plus a separate **Sandbox** key only if you run builds from Xcode or `npx expo run:ios`. Apple recommends separate keys, and a leaked key then reaches only one environment.

   You can't change either setting after you save, so choose **Save** only once both are right.

   *Screenshot: Apple's Configure Key page with the environment set to Sandbox & Production and the key restriction to Team Scoped*

4. Choose **Continue**, then **Register**.

5. Choose **Download** to save the `.p8` file.

> **Warning:** Apple lets you download the `.p8` file only once. Keep it in a password manager. If you lose it, revoke the key and create a new one.

Note the **Key ID** shown beside the key. Your **Team ID** is under **Membership details** in your Apple account. A team-scoped key works for every app in your team, so you only need to do this once.

### 2. Turn on push for your app

Your app's identifier needs the **Push Notifications** capability.

- **Expo with EAS Build:** add [Kirora's Expo plugin](https://kirora.io/docs/sdks/expo#2-add-the-plugin-to-your-app-config) first. It adds the push capability and declares Kirora's notification service extension, so the next `eas build` registers both with Apple when you sign in.
- **Xcode:** in your app target, open **Signing & Capabilities**, choose **+ Capability** and add **Push Notifications**. The [iOS](https://kirora.io/docs/sdks/ios#send-push-notifications) and [React Native](https://kirora.io/docs/sdks/react-native#ios) SDK guides cover the notification service extension, which adds images and buttons.

*Screenshot: Xcode's Signing & Capabilities tab with the Push Notifications capability added*

### 3. Upload it to Kirora

1. Open **Settings › Push apps** and your iOS app.
2. Choose **Upload key**, then **Apple (APNs key)**.
3. Enter the **Key ID**, **Team ID** and **Bundle ID**. The bundle ID is your app's, exactly as it's built, not the extension's.
4. Pick the `.p8` file and choose **Upload key**.

Kirora checks the key with Apple before saving it. A **Sandbox & Production** key goes in both iOS push apps. With separate keys, upload the Production key to your Production push app and the Sandbox key to your Sandbox app.

## Sandbox or Production

Apple sends to development builds and released builds through different environments, and a device token only works in its own. Match the Kirora push app to the build:

| Build | Kirora push app |
| --- | --- |
| Run from Xcode, or `npx expo run:ios`, on your own device | **Sandbox** |
| Any EAS build (development, internal or ad hoc), TestFlight, App Store | **Production** |

Android has no sandbox: one Firebase project serves every build.

## Test on a real device

1. Install a build on a real phone. The iOS Simulator isn't a reliable place to test push. For ad hoc or EAS internal builds, register each iPhone first with `eas device:create` (Expo) or in your Apple account. TestFlight needs no registration.
2. Sign in to the app, and allow notifications when asked. Android 13 and later ask too.
3. Send yourself a test from a campaign's **Push notification** step. See [Test a push notification](https://kirora.io/docs/guides/messaging/push/test-push).
4. Check that it arrives, its image shows and tapping it opens the right screen.

Signing in matters: the app links the device to a contact with a user token your server signs. Each SDK guide shows a short token route, for example in [React Native](https://kirora.io/docs/sdks/react-native#2-add-a-token-route-to-your-server).

## If pushes don't arrive

| What you see | What to check |
| --- | --- |
| Firebase says *Key creation is not allowed on this service account* | Your organization blocks keys. See [If Firebase says "Key creation is not allowed"](#if-firebase-says-key-creation-is-not-allowed). |
| An EAS Android build gets no pushes, or Expo warns that `googleServicesFile` is missing | The `GOOGLE_SERVICES_JSON` variable isn't in that build profile's environment. |
| Kirora won't save the Firebase key | It must be the service account file from **Generate new private key**, not `google-services.json`. |
| Android pushes never arrive | `google-services.json` and the service account come from the same Firebase project, and the package name matches your app. |
| Kirora won't save the Apple key | The Key ID, Team ID and `.p8` file all come from the same Apple developer account, and the key's environment matches the push app. |
| iOS pushes work in development but not TestFlight, or the reverse | The device is registered to the wrong push app. See [Sandbox or Production](#sandbox-or-production). |
| iOS pushes never arrive | The **Bundle ID** in Kirora matches your app exactly, and the app has the Push Notifications capability. |
| Images don't show on iOS | Your app needs a notification service extension. See the [iOS SDK](https://kirora.io/docs/sdks/ios#add-the-notification-service-extension). |

For more, see [Troubleshoot push](https://kirora.io/docs/guides/messaging/push/troubleshoot-push).

## Next steps

- [Set up push](https://kirora.io/docs/guides/getting-started/set-up-push) — push apps, projects and what your developer connects
- [SDKs](https://kirora.io/docs/sdks#in-your-app) — add Kirora to your iOS, Android, React Native, Expo or Flutter app
- [Test a push notification](https://kirora.io/docs/guides/messaging/push/test-push) — send yourself a test before you go live