> ## Documentation Index
> Fetch the complete documentation index at: https://docs.clix.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Setup Firebase

> Firebase acts as the backend for sending push notifications. Setting up Firebase properly ensures your notifications reach your users reliably.

## Create Firebase Project

Follow the instructions to create a new Firebase project.

<Note>
  If Firebase is already set up, skip to

  **Setup Firebase Project > Step 6: Download FCM Service Account Key (JSON).**
</Note>

### Things to Prepare

(iOS Only) You'll need your APNs Key (a `.p8` file provided by Apple) to enable push notifications for iOS devices. Save it securely on your local machine.

<Accordion title="How to Generate APNs Auth Token (.p8 file):" description="(skip if you already setup firebase)" defaultOpen icon="file-code" iconType="regular">
  1. Log in to [Apple Developer Center](https://developer.apple.com/account/).

  2. Go to **Certificates, Identifiers & Profiles**.

       <img src="https://mintcdn.com/greybox/iRqzegAp1WAUYjM_/images/firebase-setting/firebase-setting_1.png?fit=max&auto=format&n=iRqzegAp1WAUYjM_&q=85&s=48149553944bff1c8b8c24f4fa7af1fe" alt="firebase-setting_1.png" width="2880" height="1800" data-path="images/firebase-setting/firebase-setting_1.png" />

  3. Select **Keys** from the sidebar, then click the **+ (plus)** button to create a new key.

  4. Enter a key name (e.g., "Push Notifications") and check the **Apple Push Notifications service (APNs)** option.

  <img src="https://mintcdn.com/greybox/iRqzegAp1WAUYjM_/images/firebase-setting/firebase-setting_2.png?fit=max&auto=format&n=iRqzegAp1WAUYjM_&q=85&s=5d1880181ff668efcd707d5d075bdd36" alt="firebase-setting_2.png" width="2880" height="1800" data-path="images/firebase-setting/firebase-setting_2.png" />

  5. Click **Continue**, then review and confirm your choices.
  6. Click **Register** and download your `.p8` file immediately. Store this file securely, as you will need it in Firebase setup.
</Accordion>

### Setup Firebase Project

<AccordionGroup>
  <Accordion title="1. Sign up to Firebase" defaultOpen>
    Sign up or log into your [Firebase
    Console](https://console.firebase.google.com/)
  </Accordion>

  <Accordion title="2. Create a Firebase Project" defaultOpen>
    Click **Add project** and follow the on-screen instructions. Your project
    organizes your app's notification capabilities.

    <img src="https://mintcdn.com/greybox/iRqzegAp1WAUYjM_/images/firebase-setting/firebase-setting_3.png?fit=max&auto=format&n=iRqzegAp1WAUYjM_&q=85&s=3f34f2114d15de72ebcd42974de1d41a" alt="firebase-setting_3.png" width="2880" height="1800" data-path="images/firebase-setting/firebase-setting_3.png" />
  </Accordion>

  <Accordion title="3. Add App to the Project" defaultOpen>
    1. Navigate to your Project Overview and select **Add app**.
    2. Register your app using your iOS Bundle ID or Android Package Name.

           <img src="https://mintcdn.com/greybox/iRqzegAp1WAUYjM_/images/firebase-setting/firebase-setting_4.png?fit=max&auto=format&n=iRqzegAp1WAUYjM_&q=85&s=4ab419b8ec118e10ef3a6ee014e70736" alt="firebase-setting_4.png" width="2880" height="1800" data-path="images/firebase-setting/firebase-setting_4.png" />
  </Accordion>

  <Accordion title="4. Upload APNs .p8 file (for iOS)" defaultOpen>
    1. Uploading this file authorizes Firebase to send notifications via Apple servers.
    2. Go to **Project settings > Cloud Messaging** and upload your `.p8` file.

           <img src="https://mintcdn.com/greybox/iRqzegAp1WAUYjM_/images/firebase-setting/firebase-setting_5.png?fit=max&auto=format&n=iRqzegAp1WAUYjM_&q=85&s=212f0bc4ebc1c06a06ef8458a27ea22d" alt="firebase-setting_5.png" width="2880" height="1800" data-path="images/firebase-setting/firebase-setting_5.png" />
  </Accordion>

  <Accordion title="5. Download FCM Service Account Key (JSON)" defaultOpen>
    1. In the Project Setting, navigate to **Service Accounts**.
    2. Locate the Firebase Admin SDK service account.
    3. Click **Generate new private key**, then click **Create**.
    4. This will download a `.json` private key file. Keep it secure, and upload it to the Clix console in the next step.
  </Accordion>

  <Accordion title="6. Upload Firebase JSON to Clix Console" defaultOpen>
    Upload the downloaded Firebase service account JSON file to the **Clix
    console > Settings > General > Push Notification Sender Config**.
  </Accordion>

  <Accordion title="7-1. Add GoogleService-Info.plist to Xcode Project (for iOS)" defaultOpen>
    1. In the Project Setting > General, select the registered app on the 'Your apps' list.
    2. Download this file from Firebase Console. 3. Add it to your project's root directory in Xcode.
  </Accordion>

  <Accordion title="7-2. Add google-services.json to Android Project (for Android)" defaultOpen>
    1. In the Project Setting > General, select the registered app on the 'Your apps' list.
    2. Download this file from Firebase Console.
    3. Add it to your project's root directory in Android project.
  </Accordion>
</AccordionGroup>
