
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@stanfordspezi/spezi-firebase-cloud-messaging
Advanced tools
Firebase Cloud Messaging (FCM) remote notifications package for Spezi
A standalone package for handling Firebase Cloud Messaging (FCM) remote notifications in Spezi applications. This package provides a complete solution for managing device registration, sending multi-language notifications, and handling message delivery across different platforms.
This package is part of the Spezi Firebase project and depends on the spezi-firebase-utils package for core utilities.
npm install @stanfordspezi/spezi-firebase-cloud-messaging
import { initializeApp, cert } from 'firebase-admin/app'
import { getMessaging } from 'firebase-admin/messaging'
import { getFirestore } from 'firebase-admin/firestore'
import {
FirebaseNotificationService,
FirestoreDeviceStorage,
Message,
DevicePlatform,
Device,
LocalizedText,
} from '@stanfordspezi/spezi-firebase-cloud-messaging'
// Initialize Firebase
const app = initializeApp()
const messaging = getMessaging(app)
const firestore = getFirestore(app)
// Initialize device storage
const deviceStorage = new FirestoreDeviceStorage(firestore)
// Initialize notification service
const notificationService = new FirebaseNotificationService(
messaging,
deviceStorage,
)
// Register a device
await notificationService.registerDevice(
'user123',
new Device({
notificationToken: 'fcm-token-123',
platform: DevicePlatform.iOS,
language: 'en',
appVersion: '1.0.0',
}),
)
// Send a notification
await notificationService.sendNotification('user123', {
title: { en: 'Hello', de: 'Hallo' },
body: {
en: 'This is a test notification',
de: 'Dies ist eine Test-Benachrichtigung',
},
data: { action: 'open_home' },
})
// Create and send a message notification
const message = Message.createInformation({
title: { en: 'Information', de: 'Information' },
description: {
en: 'This is important information',
de: 'Dies ist eine wichtige Information',
},
action: 'view_details',
isDismissible: true,
data: { itemId: '123' },
})
// Send a message-based notification
await notificationService.sendMessageNotification('user123', {
id: 'message-123',
path: '/messages/message-123',
lastUpdate: new Date(),
content: message,
})
// Unregister a device
await notificationService.unregisterDevice(
'user123',
'fcm-token-123',
DevicePlatform.iOS,
)
This package includes helpers for creating Firebase Functions:
import { onCall } from 'firebase-functions/v2/https'
import {
createRegisterDeviceHandler,
createUnregisterDeviceHandler,
registerDeviceInputSchema,
unregisterDeviceInputSchema,
} from '@stanfordspezi/spezi-firebase-cloud-messaging'
// Create function handlers
const registerDeviceHandler = createRegisterDeviceHandler(notificationService)
const unregisterDeviceHandler =
createUnregisterDeviceHandler(notificationService)
// Create Firebase Functions
export const registerDevice = onCall(
{
schema: registerDeviceInputSchema,
},
async (request) => {
const userId = request.auth?.uid
if (!userId) throw new Error('Unauthorized')
return registerDeviceHandler(userId, request.data)
},
)
export const unregisterDevice = onCall(
{
schema: unregisterDeviceInputSchema,
},
async (request) => {
const userId = request.auth?.uid
if (!userId) throw new Error('Unauthorized')
return unregisterDeviceHandler(userId, request.data)
},
)
This project is licensed under the MIT License. See Licenses for more information.
This project is developed as part of the Stanford Mussallem Center for Biodesign at Stanford University. See CONTRIBUTORS.md for a full list of all Spezi Firebase contributors.

FAQs
Firebase Cloud Messaging (FCM) remote notifications package for Spezi
The npm package @stanfordspezi/spezi-firebase-cloud-messaging receives a total of 5 weekly downloads. As such, @stanfordspezi/spezi-firebase-cloud-messaging popularity was classified as not popular.
We found that @stanfordspezi/spezi-firebase-cloud-messaging demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.