Adding Push Notifications to a Lovable App
Short answer: A Lovable app can send push notifications in two ways: web push through a service worker, which works in browsers and installed PWAs with platform limits, or native push through Apple Push Notification service and Firebase Cloud Messaging once the app is wrapped as an iOS and Android app. For reliable delivery on iPhones and a stronger App Store case, native push via a wrapper such as WebViewGold is usually the better choice.
On this page
Web push or native push: the decision comes first
Lovable generates a web app, so the first question is where your users will receive notifications. Web push uses the Push API and a service worker. It works in desktop browsers and on Android, and on iOS only for web apps that users have added to their home screen, on supported iOS versions. Many users never take that step, which limits reach on iPhone.
Native push uses Apple Push Notification service (APNs) on iOS and Firebase Cloud Messaging (FCM) on Android. It requires a native app, but delivery is reliable, permission prompts are familiar, and notifications support badges, sounds, images and deep links. If you plan to be in the app stores anyway, native push is the stronger option and it also helps answer Apple's Minimum Functionality question.
Architecture: who sends what to whom
Regardless of channel, the moving parts are the same. Keeping them separate makes the system easier to debug.
- Device token: a unique address for one app installation, issued by APNs or FCM, or a push subscription object for web push.
- Token store: a Supabase table linking tokens to user IDs, platform and last-seen date, protected by Row Level Security.
- Trigger: the event that should cause a notification, such as a new message, a status change or a scheduled reminder.
- Sender: a Supabase edge function or provider such as OneSignal that holds the credentials and calls APNs or FCM.
- Handler: the code in your app that reacts when a user taps the notification and routes them to the right screen.
Setting up native push with a wrapper
With WebViewGold, push notifications are a built-in feature with Firebase and OneSignal options, so most of the native work is configuration. A typical setup looks like this.
- Create a Firebase project, add the Android app with your package name and download google-services.json.
- In the Apple Developer portal, enable the Push Notifications capability for your App ID and create an APNs authentication key; upload it to Firebase or your push provider.
- Enable push in the WebViewGold configuration for both platforms and add the Firebase files to the projects.
- Pass the device token from the native layer to your Lovable web app through the native bridge, then save it to your Supabase token table together with the logged-in user ID.
- Write an edge function that receives an event, looks up the user's tokens and calls FCM with the title, body and a deep link path.
- Handle the tap: read the deep link in the web app and navigate to the matching route.
- Test on physical devices in foreground, background and terminated states, since behavior differs between them.
Need a hand? WebViewGold helps with exactly this. Book a call for free and get a clear plan in 15 to 30 minutes.
Triggering notifications from Supabase
Two patterns cover most products. For event-driven notifications, a database webhook or trigger fires on an insert or update, for example a new row in a messages table, and calls your edge function. For scheduled notifications, such as daily summaries or expiring trials, a cron job in Supabase calls the function at a fixed time and queries which users qualify.
Keep the function idempotent and log every send attempt with its result. Remove tokens that FCM reports as invalid, otherwise your token table fills with dead installs. Never put the Firebase service account or APNs key into the front end; they belong in edge function secrets.
Permission prompts and notification design
On iOS you get one chance at the system permission prompt. If the user declines, they must go to Settings to change it. Do not ask on first launch. Ask right after the user does something that makes notifications obviously useful, such as following a project or placing an order, and show a short in-app explanation first.
Respect frequency. Give users notification categories they can switch on and off in your app's settings, store preferences in Supabase, and check them in the sender before every push. Transactional notifications (your order shipped) are welcome; marketing notifications need clear consent and should be rare. Both Apple and Google prohibit using push for unsolicited advertising without opt-in.
Common problems and how to fix them
Notifications that arrive on Android but not iOS usually point to a missing APNs key in Firebase, a missing capability in Xcode, or testing on the simulator in setups where it does not receive remote push. Tokens that are saved without a user ID typically come from saving before login completes; save again after authentication. Taps that open the app but not the right screen mean the deep link is not passed to the web layer or the route needs the user to be logged in first.
WebViewGold documents each of these cases, and it handles the native token lifecycle so your Lovable code only deals with saving tokens and sending messages. If you would rather have the whole flow implemented and tested on real devices, a free call is a good starting point.
Frequently asked questions
Can I add push notifications to a Lovable app without publishing it to the app stores?
Yes, through web push with a service worker. It works well on desktop browsers and Android. On iPhone, web push only reaches users who added the web app to their home screen on a supported iOS version, which limits reach. For broad mobile coverage, a native app with APNs and FCM is more dependable.
Should I use OneSignal or Firebase directly?
Firebase Cloud Messaging directly gives you full control and no extra vendor, but you build segmentation and scheduling yourself in Supabase. OneSignal adds a dashboard, segments, scheduling and analytics with less code. Small teams often start with a provider and move to direct FCM only if cost or data control requires it.
Do push notifications help with App Store approval?
They can. Apple's Guideline 4.2 rejects apps that are little more than a website. Meaningful native push notifications tied to real user events are one of several features that show native value. They should be genuinely useful, though; notifications added only for review purposes will not carry a weak app.
