Developer DemoDisplay our demo page in your app to test during development: https://median.dev/firebase-messagingThe demo also links to a standalone Test Sender. Run it in your browser (not inside the app) to send real test pushes to a device or topic using a Firebase service-account key. It supports presets for plain, deep-link, big picture/text, custom channel, badge, and silent notifications, and shows the raw FCM payload it sends.
Why use Firebase Cloud Messaging
- Direct-to-device push, no middleman: Send native push notifications straight from your own Firebase project to iOS and Android devices inside the Median shell, giving you end-to-end control over the messaging pipeline.
- Bridge-first control: Manage permissions, registration tokens, topic subscriptions, notification channels, and badge counts directly from JavaScript without writing native code.
- Topic-based targeting: Subscribe and unsubscribe devices from FCM topics to broadcast messages to segments of users without maintaining a token list yourself.
- Notification channel management (Android): Create, update, and delete notification channels directly from your web app.
- Foreground notification control: Choose whether incoming pushes show a banner while the app is open, or are delivered silently to your JavaScript listeners instead.
- Deep linking: When deep linking is configured, notification taps can open the right screen in-app instead of the device browser.
Prerequisites
- A Median app with the JavaScript Bridge enabled.
- A Firebase project with Cloud Messaging enabled.
google-services.jsonuploaded in your Median app configuration (required for push delivery on Android).GoogleService-Info.plistuploaded in your Median app configuration, plus an APNS authentication key or certificate configured in the Firebase console (required for push delivery on iOS).
Implementation guide
Firebase project setup
Create (or reuse) a Firebase project and register your Android and iOS apps to it. Median handles native SDK initialization once those configuration files and credentials are in place.- In the Firebase console, create a project (or select an existing one) and enable Cloud Messaging.
- Add an Android app to the project using your app’s package name/Application ID, then download the generated
google-services.json. - Add an iOS app to the project using your app’s Bundle ID, then download the generated
GoogleService-Info.plist. - In Project settings → Cloud Messaging → Apple app configuration, upload an APNS authentication key (recommended) or certificate so Firebase can deliver to iOS devices.
App configuration
- Open Median App Studio for your app.
- Navigate to Build & Deploy.
- Upload
google-services.json(Android) andGoogleService-Info.plist(iOS) in Google Services configuration.

App Studio Google Services configuration
- Enable the Firebase Cloud Messaging native plugin.
- Configure plugin settings.
- Rebuild your app to include the Firebase Cloud Messaging SDKs and your settings.

App Studio Firebase Cloud Messaging configuration
Plugin configuration options
Rebuild after configurationPlugin settings take effect only in new builds. After changing credentials or uploading new Firebase configuration files, rebuild your app and test on a real device or simulator before releasing.
Deep linking (optional)
The Firebase Cloud Messaging plugin integrates with Median deep linking. When deep links are configured, users who tap a push notification are routed to the correct screen inside the app rather than to the mobile browser. The Test Sender’s Deep link preset lets you validate this by sending a push with a target URL. To enable this:- Configure URL schemes, Universal Links (iOS), and App Links (Android) in Median App Studio.
- Ensure the target URL sent in your FCM payload matches the routes handled inside your app.
JavaScript Bridge functions
All methods are available on themedian.firebaseMessaging namespace and must be called after the Median JavaScript Bridge is fully initialized.
Push notification permissions
Request permission Triggers the native OS permission prompt. Maps to the demo’s Request Permission button. For best results, defer this call to a point in the user journey where the value of notifications is clear. Contextual prompts have significantly higher opt-in rates. On Android 12 and below, notification permission may be granted automatically depending on device OS version and policy.Token management
Register Registers the device with FCM if no token exists yet.Looking to send pushes to individual users or segments?
Follow the guide below to identify and target individual users or segments.
Topics
Subscribe or unsubscribe a device from FCM topics to target groups of users without maintaining your own list of device tokens. Subscribe to a topicNotification channels (Android)
Android groups notifications into channels that control importance, sound, and visual treatment. Once a channel is created, only its name and description can be changed. The channel ID and importance are fixed for the life of the channel. Create or update a channelNotification badges
Sets the app icon badge count. This is best-effort: it works on launchers that support badges (e.g. Samsung, Xiaomi, and similar), and does nothing on stock Android launchers that don’t support badge counts. Set badgeForeground notifications
Controls whether an incoming push shows a visible banner while the app is in the foreground. Turn banners off if you’d rather handle the incoming event yourself (e.g. show an in-app toast) without the OS notification also appearing.Listeners
Register listeners to respond when notifications are received in the foreground or tapped by the user. Multiple listeners can be registered for the same event. Each listener fires independently until it’s removed.Testing checklist
Use this checklist, together with the demo page and test sender, to confirm Firebase Cloud Messaging is working correctly in your app:- Configuration files present:
google-services.jsonandGoogleService-Info.plistare uploaded in Median App Studio and the app has been rebuilt. - Permission flow:
requestPermission()prompts the OS dialog andcheckPermission()reflects the resulting status. - Token generated:
getToken()returns a non-empty token on a real device. - Test push received: Using the Test Sender with your service account key, send a push to the copied token and confirm it’s received and, if tapped, opens the app.
- Topics: Subscribe to a test topic, send a push to that topic from the Test Sender, and confirm delivery; then unsubscribe and confirm it stops.
- Channels (Android): Create a custom channel, send a push targeting that
channelIdfrom the Test Sender, and confirm it uses the expected importance/behavior. - Badge: Set and clear a badge count and confirm it’s reflected on supported launchers.
- Foreground banners: Toggle banners off and confirm the app still receives the
notificationReceivedevent without showing a native banner while foregrounded. - Deep linking: Send a push using the Deep link preset and confirm the tap opens the correct in-app screen rather than the device browser.
Troubleshooting
App Studio reports missing Google services configuration files
App Studio reports missing Google services configuration files
FCM requires Google Services to be configured for your app. Follow the steps in our Google Services guide to add
google-services.json (Android) and GoogleService-Info.plist (iOS).Test push from the sender isn't arriving
Test push from the sender isn't arriving
Check that everything points to the same Firebase project:
- The project ID in the Test Sender matches the project in your app’s
google-services.json/GoogleService-Info.plist. - The service account key belongs to that same project.
- The destination token or topic is current.
Deep links open in the browser instead of the app
Deep links open in the browser instead of the app
Configure Median deep linking (URL scheme, Universal
Links, and App Links) so the target URL in your FCM payload matches a route
the app handles.
Custom notification sound doesn't play (Android)
Custom notification sound doesn't play (Android)
On Android, a notification’s sound belongs to its notification channel, not the individual message. To play a custom sound, set The first message sent with a new
channel_id alongside sound in the message’s android.notification block:FCM message
channel_id creates that channel with the given sound. Android doesn’t let apps change a channel’s sound after it’s created, so the channel keeps that sound permanently.To use a different sound, send it on a new
channel_id. Messages without a channel_id use the default channel and its sound.Tapping grouped notifications doesn't open the target URL (Android)
Tapping grouped notifications doesn't open the target URL (Android)
When several notifications from your app are showing, Android may bundle them
into a group. Tapping the group summary opens the app without a target URL.
Expand the group and tap an individual notification to open its URL.
Badge count isn't showing (Android)
Badge count isn't showing (Android)
Badge counts are best-effort and depend on launcher support. They work on Samsung, Xiaomi, and similar launchers, but have no effect on stock Android (AOSP/Pixel-style) launchers. This is a platform limitation, not a problem with your integration.