🔥Firebase - Push Notifications (Advanced)
Send push notifications to your users through Firebase Cloud Messaging.
What are Firebase Push Notifications?
Natively provides built-in support for Firebase Cloud Messaging (FCM) to handle push notification delivery for your app. Firebase manages device tokens and topic-based targeting through its own console, and you send notifications either directly from the Firebase console or via the Firebase Cloud Messaging API.
If you don't have a specific reason to manage Firebase yourself, consider OneSignal - Push Notifications instead, which offers a simpler dashboard-driven setup and a much easier API for sending notifications.
Prerequisites
This feature requires the Unlimited or Lifetime plan. See all plans
A Firebase account.
iOS:
An Apple Developer account.
Your iOS app is already published in the Natively Dashboard.
Android:
Your Android app is already published in the Natively Dashboard.
Pre-Firebase Configuration (iOS only)
To send push notifications to iOS devices, Firebase requires the Push Notifications App Capability enabled on your Bundle ID and an APNs authentication key from your Apple Developer account.
App Capabilities Configuration
Open your Apple Developer account and navigate to Certificates, IDs & Profiles > Identifiers.
Select your app's Bundle ID.
Scroll down the Capabilities list and enable Push Notifications.
Click Save and confirm.
Set up APNs Authentication Key
Open your Apple Developer account and navigate to Certificates, IDs & Profiles > Keys.
Click + to register a new key.
Enter Key Name.
Select the Apple Push Notifications service (APNs) checkbox and click Configure.
In the Environment dropdown menu, select Sandbox & Production and click Save.
Click Continue, then Register.
Download the generated
.p8key.
You can only download this file once, so save it securely. If you lose it, you'll need to revoke the key and generate a new one.
Gather your credentials
Collect:
Key ID - located in the row of the key you just created. Make sure it matches the downloaded
.p8file.Team ID - located in your Apple Developer account under Membership details.
You'll need these for Firebase iOS Platform configuration.
Firebase Configuration
To send push notifications through Firebase, you'll need a Firebase project and Platforms configured for your app.
Create or open your Firebase Project
Go to the Firebase console.
If you don’t have a project yet, click Create a project and complete the setup.
If you already have a project, select it.
Confirm Firebase Cloud Messaging API v1 is enabled
While on the Project Overview page, select Settings > General from the left sidebar, then go to the Cloud Messaging tab.
Firebase Cloud Messaging API (V1) is enabled by default for most projects.
If it shows as disabled:
Click on the 3-dots menu.
Click Manage the API in Google Cloud Console.
Click Enable in the Google Cloud Console. Wait a few minutes for the change to reflect in Firebase.
Configure your platform
While on the Project Overview page, click the + Add app button under your project name.
Select Android.
In the Register app section:
Enter the Android package name (Bundle ID) of the app configured in your Natively Dashboard.
(Optional) Enter an App nickname; it will be used only in the Firebase Console to represent this app.
Click Register app.
In the Download and then add config file section, click Download google-services.json and save the
google-services.jsonfile in a secure location.Skip the SDK setup steps that follow, since Natively handles SDK integration for you, and click Continue to console at the end.
Configure iOS app
While on the Project Overview page, click the + Add app button under your project name.
Select iOS(Apple).
In the Register app section:
Enter the Apple Bundle ID of the app configured in your Natively Dashboard.
(Optional) Enter an App nickname; it will be used only in the Firebase Console to represent this app.
(Optional) Enter an App Store ID (App Store App ID) of the app configured in your Natively Dashboard.
Click Register app.
In the Download and then add config file section, click Download google-services.json and save the
GoogleService-Info.plistfile in a secure location.Skip the SDK setup steps that follow, since Natively handles SDK integration for you, and click Continue to console at the end.
Upload your APNs Authentication Key
While on the Project Overview page, select Settings > General from the left sidebar, then go to the Cloud Messaging tab.
Scroll down to Apple app configuration and select your iOS app.
Under APNs Authentication Key in both development and production fields, provide the following and click Upload:
APNs Auth key -
.p8file you downloaded in the Set up APNs Authentication Key step above.Key ID and Team ID - gathered in the Gather your credentials step above.
Natively Dashboard Setup
Before proceeding, make sure you have completed the Firebase Configuration steps above.
Open your Natively app dashboard and navigate to Features > Notifications > Firebase.
Toggle the feature to Enabled.
Upload the Android Config file (
google-services.json) or/and the iOS Config file (GoogleService-Info.plist).Enter the Permission Description.
(Optional) Adjust the Automatically request push permission on app launch checkbox.
Click Save.
Rebuild your app(s).
You must rebuild your app for these changes to take effect.
Implementation
Choose your integration method below: Bubble.io Plugin (No-Code), JavaScript SDK (Code), or AI Agents (for AI-powered editors like Lovable, Base44, and Replit).
Initialization
Check Plugin
Before starting, verify if the Natively plugin is already installed in your Bubble project.
Open your Bubble editor and navigate to the Plugins tab in the left sidebar.
Check Installed Plugins: Look through your list of installed plugins for "Natively iOS & Android app builder".
If it IS installed: Check the version number. If an update is available (e.g., you see a button saying "Update"), click it to ensure you have the latest features and bug fixes.

If it is NOT installed: Click the + Add plugins button, search for "Natively", and click Install.

Check SDK
Before writing any logic, ensure the Natively SDK is correctly installed and up-to-date in your codebase.
Open your project's main HTML file (or header settings) and look for the Natively script tag inside the
<head>section.Install/Update: If missing or outdated, add the following code. You can specify the SDK version in the URL (e.g.,
@2.26.0).
Initialize the SDK
AI-powered editors like Lovable, Base44, and Replit use the JavaScript SDK to implement Natively features. Before implementing any feature, the Natively SDK must be initialized in your project.
Copy the line below and paste it into your AI agent to check and set up the Natively SDK in your project.
Setup logic
[Element] Natively - Push Notifications (Firebase)
This element must be set to Visible on page load to initialize correctly. It should be placed directly on the page root and not inside hidden containers, such as Popups, Floating Groups, Group Focus elements, or Repeating Groups. To hide the element from your UI, you may set its dimensions to 0x0 px.
Events:
Firebase FMC Token Updated - fires when the FCM token is updated.
Firebase APNS Token Updated - fires when the APNs token is updated.
Notification permissions authorized - fires when the user taps Allow on the permission alert.
Notification permissions denied - fires when the user taps Decline on the permission alert.
Notification permissions status updated - fires when permission status changes due to a user action.
Topic subscription status - fires when a subscribe/unsubscribe action's status updates.
States:
Permission Status - Yes/No.
Firebase FCM Token - the FCM token value.
Firebase APNS Token - the APNs token value.
Topic subscription status -
SUCCESSif the subscribe action succeeded.Topic unsubscribe status -
SUCCESSif the unsubscribe action succeeded.
Actions:
Request the user's push notification permission - displays the system permission popup using your configured Permission Description.
Get the user's Firebase APNS Token - reloads the user's Firebase APNS token.
Get the user's Firebase FCM Token - reloads the user's Firebase FCM token.
Get the user's push notification permission status
Subscribe to topic - subscribes to an FCM topic:
Topic ID - the FCM topic name.
Unsubscribe from topic - unsubscribes from an FCM topic:
Topic ID - the FCM topic name.
AI-powered editors like Lovable, Base44, and Replit use the JavaScript SDK to implement Natively features.
Copy the line below and paste it into your AI agent.
Replace the placeholder at the beginning with a description of what you want to build - for example: "Request push notification permission and save the FCM token to the user's profile on login".
How to use
Save both tokens on login - you'll need them to send notifications later
Store the FCM token (e.g. an fcm_token field on your user record) to send notifications on any platform. For iOS specifically, also store the APNs token (e.g. an apns_token field) if you send notifications directly via APNs rather than through FCM. Since tokens can change over time - after reinstalls or token refresh - retrieve and update them on every login rather than assuming a value saved once stays valid.
Check resp.status before treating permission as granted
firebase_request_permission only returns true when the user grants full authorization - any other state (denied, provisional, or not yet decided) returns false. Don't assume a non-true response means the request failed; it may simply mean the user hasn't fully authorized notifications.
Only call firebase_get_apns_token on iOS
This method always fails on Android with resp.message: "APNS token is only available on iOS". Check the platform first with Browser Info, and act upon the result.
Always provide a topic name
firebase_subscribe_to_topic and firebase_unsubscribe_from_topic fail with "Exception: Topic is required" if the topic is missing - validate the topic string before calling either method.
Use topics for broadcast-style targeting
Topics are best suited for sending the same notification to many users at once based on a shared interest or category (e.g. news_updates, weekly_digest) - subscribe users to relevant topics, then send a single notification to the topic instead of targeting each device individually.
Sending Notifications
Once a device's FCM token (and APNs token, for iOS) is saved, you can send notifications directly through the Firebase Console or the Cloud Messaging REST API.
Firebase Console - the simplest way to send a test or one-off notification to either an individual device or a topic. See Firebase Console Docs.
Cloud Messaging REST API - send notifications programmatically from your backend to either an individual device or a topic. See Cloud Messaging REST API Docs.
To a topic's subscribers:
To a single user:
Troubleshooting
Last updated