The Panahashi backend sends push notifications through Firebase Cloud Messaging (FCM) to keep bakers and customers informed as orders move through the system. All notifications are sent server-side using the Firebase Admin SDK — the client only needs to register a valid FCM token.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/AndrewwCO/Panahashi-Backend/llms.txt
Use this file to discover all available pages before exploring further.
How notifications work
When a significant event occurs (a new order, a status change, a loyalty stamp, etc.), the backend fetches the target user’s FCM token from their Firestore document atusers/{uid}.fcmToken, constructs a message, and calls FirebaseMessaging.getInstance().send(message). If the user does not have a token stored, no notification is sent.
Registering a device token
When the app launches (or when the FCM token refreshes), the client must send the new token to the backend so the server always has a valid address to deliver notifications to. Send aPATCH request to /api/v1/users/me with the fcmToken field in the request body:
Call this function on every app launch, not just on the first install. FCM tokens can be refreshed by the device at any time. Use
messaging().onTokenRefresh(token => registerFcmToken(authToken)) to handle mid-session refreshes.Notification events
The table below lists every notification the backend can send, including the Spanish-language strings used in the app (Panahashi serves the Colombian market).| Event | Trigger | Recipient | Title | Body |
|---|---|---|---|---|
| New order (cash) | Customer places a cash-on-pickup order | Baker | ¡Nuevo Pedido! | Tienes un nuevo pedido de {customerName} |
| New order (payment approved) | Payment gateway approves payment | Baker | ¡Nuevo Pedido! | Tienes un nuevo pedido de {customerName} |
| Order confirmed | Baker confirms the order | Customer | Pedido Confirmado | Tu pedido ha sido confirmado y está siendo preparado |
| Order baking | Baker marks order as in progress | Customer | Pedido en Preparación | Tu pedido está siendo preparado |
| Order ready | Baker marks order as ready for pickup | Customer | ¡Pedido Listo! | Tu pedido está listo para recoger |
| Order completed | Baker marks order as completed | Customer | Pedido Completado | Tu pedido ha sido completado. ¡Gracias por tu compra! |
| Order cancelled | Baker or system cancels the order | Customer | Pedido Cancelado | Tu pedido ha sido cancelado |
| Bakery activated | Admin activates a baker’s bakery | Baker | ¡Panadería Activada! | Tu panadería {bakeryName} ha sido activada |
| Estimated ready time | Baker sets an estimated ready time | Customer | Tiempo Estimado Actualizado | Tu pedido estará listo aproximadamente a las {estimatedReadyAt} |
| Loyalty stamp awarded | Order completed; stamp recorded | Customer | ¡Sello de Fidelidad! | Has ganado un sello en {bakeryName}. Tienes {stamps}/{stampsForReward} sellos |
| Payment rejected | Payment gateway rejects payment | Customer | Pago Rechazado | El pago de tu pedido {orderId} fue rechazado |
Order status notification flow
As an order moves through its lifecycle, specific notifications fire at each transition. The diagram below shows the full flow from order placement to completion or cancellation.Client implementation (React Native)
The following example shows how to set up FCM in a React Native app, request permissions, register the token, and handle incoming notifications.Foreground and background handling
- Background / quit state
- Foreground
When the app is in the background or closed, FCM delivers the notification to the device’s notification tray. Tapping the notification launches the app. Use
messaging().getInitialNotification() in your root component to read the notification that opened the app and navigate accordingly.