How to Add Push Notifications to Your Lovable App with Firebase

A customer books a repair through your app, closes the browser, and gets on with their day. Two hours later, the repair is ready. You update the dashboard, but the customer has no reason to check it.

This is where push notifications become useful. Instead of waiting for someone to reopen your app, you can let them know that something relevant has changed.

Lovable’s Firebase Cloud Messaging connector gives your app a way to send those updates through your own Firebase project. It supports Android, iOS, and web clients, but connecting the service is only part of the job. Your app also needs to know which device to contact, when a message is appropriate, and what should happen when someone taps it.

Let’s use an illustrative repair-shop app called RepairReady to make the moving parts concrete. Customers book repairs, staff update job statuses, and customers can choose to receive a notification when their item is ready for collection.

A push notification is the last step, not the whole workflow

It is tempting to start with “send a notification when a repair is finished.” Before that can work, three separate pieces need to exist:

  • A destination: the Firebase client SDK obtains a registration token for a device or browser.
  • A stored relationship: your app saves that token and associates it with the right signed-in user.
  • A sending action: trusted server code uses the linked Firebase Cloud Messaging connection to send a message when the relevant event happens.

The connector handles sending. It does not automatically register devices, collect tokens, or decide who owns them. Think of it as the delivery connection, not your customer address book.

For RepairReady, the notification should follow a successful status update. The customer’s repair record remains the source of truth; the push simply tells them there is something worth checking.

Choose the audience before choosing the message

Firebase Cloud Messaging offers three targeting options, and a message must use exactly one of them.

A registration token targets one device. This is the right starting point for a private update such as “Your repair is ready.” If a customer uses several devices, your app needs to manage the relevant tokens rather than assume one account always means one device.

A topic reaches devices that have already subscribed to that topic. A public announcement about holiday opening hours could use a topic such as shop-news. Sending to that topic does not subscribe anyone automatically.

A condition uses an FCM expression to select an audience based on topic subscriptions. It is useful when your targeting needs more than a single topic, but it is not necessary for a first customer-specific notification.

Keep private order or booking information out of broad announcements. A topic is a broadcast mechanism, not a substitute for checking whether someone is allowed to see a particular record.

Prepare Firebase without handing your app a private key

You need a Firebase project and a service account in that project with the Firebase Cloud Messaging API Admin role. You also need permission to create connections in your Lovable workspace.

In the Firebase console, open your project and go to Project settings → Service accounts. Generate a private key for an appropriately authorized service account. Firebase downloads a JSON file.

Treat that file as a password. Upload it only through the Lovable connection form. Do not paste it into a project conversation, add it to your repository, or include it in browser code. If it leaks, rotate the key in Google Cloud and update the connection.

Lovable stores the service account credentials on the connection and uses them to obtain a short-lived Google token for sending. Your generated app does not need to contain the service account JSON.

App + chat connectors are available by default on Free, Pro, and Business plans. In Enterprise workspaces, an administrator may first need to allow connection creation under Connectors → Admin settings → App + chat connectors, because the initial setting is “No one.”

Messages use your Firebase and Google Cloud project. Google handles applicable quotas and any Google Cloud billing, rather than Lovable.

The important setup choice: existing devices or browser opt-in?

Open Connectors in Lovable, choose Firebase Cloud Messaging, and add a connection. Give it a recognizable name, upload your service account JSON, and choose the client setup that matches your app.

Server or native only is the default. Use it when your app already has destination tokens, including tokens from Android or iOS clients. Native clients do not use a web VAPID key.

Include web push is for apps that also register browsers. RepairReady needs this option because customers will opt in through its web app.

For web push, create or select a Firebase web app in the same Firebase project and provide these three public values:

  • Firebase API key: copy apiKey from the web app’s SDK configuration under Project settings → General → Your apps.
  • Firebase App ID: copy appId from the same configuration. Its format is 1:<numbers>:web:<identifier>.
  • Web Push VAPID key: copy the public key from Project settings → Cloud Messaging → Web Push certificates.

Lovable derives the Firebase project ID from the service account, so there is no separate project ID field to fill in. These public web configuration values are different from the private service account key.

Choose sharing deliberately. A connection starts out private; you can give selected workspace members access or invite the workspace. Make sure the project owner has access before linking it.

Finish connecting, then ask Lovable to link the connection to your project. You can keep separate connections for development and production Firebase projects, which helps avoid sending test notifications to real customers.

Build the smallest useful notification first

Do not begin with reminders, broadcasts, and background updates all at once. Start with one opted-in customer receiving one repair-ready message.

A useful starting prompt is:

Link Firebase Cloud Messaging to RepairReady. Add a signed-in “Notify me when my repair is ready” button. Use the Firebase client SDK to register supported browsers and store each token against the authenticated customer through trusted server code. When staff successfully mark that customer’s repair as ready, send a targeted notification through the linked connector. Include the repair page path as string data, check access before showing that page, and display a clear result if registration or sending fails.

This prompt describes both the visible experience and the work behind it. It does not assume the connector will invent token storage or authorization for you.

Sending belongs in server code through Lovable’s connector gateway, not in browser code calling fcm.googleapis.com directly. Keep connector credentials out of the frontend, and validate the user, destination, and event before sending.

A message can contain notification text and a small data payload. Data values must be strings. For example, a path value can identify the repair page the client should open. Your client still needs to handle that value; adding it to a message does not automatically create navigation behavior.

Browser permission is a product moment

A notification permission prompt should follow a deliberate action, not appear simply because someone landed on your homepage. A customer is more likely to understand the request when they have just booked a repair and clicked a button for updates.

There is also a testing trap: the in-editor Lovable preview runs inside an iframe. Browsers block notification permission requests there. Open the preview in its own tab or use the published app when testing opt-in.

Ask Lovable to detect this situation and explain that the app needs its own tab. Also ask for separate messages when the browser is unsupported, permission has been denied, or the connection lacks web push configuration. These are different problems and should not all produce “Something went wrong.”

If you originally chose Server or native only, edit the connection, switch to Include web push, and complete all three web fields. Link the updated connection to the project again if needed.

Expand only after the first message works

Once RepairReady can reach a real opted-in device, the same foundation can support other workflows. A booking app could send appointment reminders; an operations tool could notify on-call staff about incidents; an admin page could publish announcements to an existing topic.

Scheduling remains separate work. FCM sends the message, but a reminder still needs a scheduled process that finds the relevant booking and triggers the send at the correct time.

Data-only messages are another option when a client should react without displaying a banner. The client needs to implement that behavior, and background handling depends on the platform. Do not treat silent push as a guarantee that a closed app will immediately refresh.

When messages fail, check the right layer

If the connection rejects your uploaded file, verify that it is a service account key, not an OAuth client file. It should contain "type": "service_account" and project_id, and the account must have the required FCM role.

If browser registration never reaches the permission prompt, check whether you are inside the preview iframe. If registration reports missing web configuration, check the connection’s client setup and web fields.

If a send returns UNREGISTERED, remove the stale token from your stored destinations rather than repeatedly sending to it. Some INVALID_ARGUMENT responses also indicate an invalid token, but that error can have other causes, so inspect the response before deciding what to delete.

For temporary failures such as rate limits or server errors, use backoff rather than immediate repeated sends. If the service account has been disabled or its key revoked, update the connection with a valid key.

Finally, distinguish “the send request succeeded” from “the person saw the notification.” This connector does not provide delivery analytics, open rates, or per-user reach. Investigate available reporting in Firebase and its BigQuery export if enabled. It also does not receive inbound FCM events.

A focused tool, not a complete Firebase integration

Connecting Cloud Messaging does not connect Firebase Authentication, Realtime Database, Cloud Storage, or Analytics. It also does not sign each app user into their own Firebase account. One connection represents one Firebase project shared by the Lovable projects linked to it.

That focused scope is useful when you need notifications without changing the rest of your app. Keep your existing sign-in and booking workflow, add device registration, and use FCM for the outgoing message.

Unlinking a project removes its access while keeping the connection available elsewhere. Deleting the connection removes it from the workspace and stops dependent features in linked projects until a replacement is added.

The best first notification is a useful one with a clear destination and a tested opt-in flow. Get that right before building a broadcast system.

If you want help adding notifications to an existing app, explore my Lovable development services or explore booking options.

Source: Lovable’s Firebase Cloud Messaging documentation. This article uses original wording and an illustrative repair-shop scenario.

FAQ

Does connecting Firebase Cloud Messaging automatically register devices?

No. The Firebase client SDK obtains registration tokens. Your app must store them and associate them with the appropriate users before server code can send targeted messages.

Why does browser push not prompt inside the Lovable preview?

The editor preview is embedded in an iframe, where browsers block notification permission requests. Open the app in its own tab or test the published version, and request permission after a user clicks an opt-in button.

What do I need for web push?

Select Include web push and supply the Firebase web app API key, Firebase App ID, and public Web Push VAPID key. The web app must belong to the same Firebase project as the service account.

Can I send a message to a topic and a device in the same request?

No. Each message targets exactly one registration token, topic, or condition. Devices must already be subscribed before they can receive a topic broadcast.

Does this connector connect Firebase Authentication too?

No. The integration is for Cloud Messaging only. Firebase Authentication, databases, storage, and analytics require separate setup.

Can I see who opened a notification through the connector?

No. It does not read delivery or opening analytics. Check the reporting available in Firebase and its BigQuery export if enabled.

What should I do with an expired device token?

Remove a token that returns UNREGISTERED. For INVALID_ARGUMENT, inspect the error details to confirm whether the token or another part of the message is invalid before removing anything.