# Firebase Android integration

## Registered Android application

- Firebase project ID: `flutter-ai-playground-410ea`
- Firebase project number: `475854312836`
- Android package: `com.colorjetbd.managementsuite`
- Firebase Android App ID: `1:475854312836:android:c68d85ee194443660c39d1`

The uploaded `google-services.json` is stored at:

```text
mobile-engineer/google-services.json
```

The Expo app config points to that file through `android.googleServicesFile`.

## EAS project linking

Firebase App ID and EAS Project ID are different identifiers. Before producing the signed build, authenticate with the correct Expo account and run:

```bash
cd mobile-engineer
npx eas-cli@latest init
```

This writes the real EAS project UUID into the Expo configuration. Do not substitute the Firebase App ID for the EAS UUID.

## Push registration flow

1. App requests notification permission.
2. App obtains an Expo push token using the EAS project UUID.
3. App registers the token at `POST /api/notifications/devices`.
4. Backend stores the token in `device_push_tokens`.
5. Ticket assignments create an in-app notification and send a push notification.
6. Opening a ticket notification routes the engineer to `/ticket/{ticketId}`.

## Database migration

Apply:

```bash
psql "$DATABASE_URL" -f database/0004_push_notification_devices.sql
```

## Production safety

- Never add a Firebase service-account private key to the mobile project.
- Do not publish backend JWT secrets or database credentials in `EXPO_PUBLIC_*` variables.
- Notification payloads should not include customer phone numbers, due balances, NID, bank data or private service notes.
