Prompt
How do I send transactional push notifications like password resets or order updates?
Latest observation
To send transactional push notifications (like password reset links, order status updates, shipping alerts, OTPs, etc.), you typically use a push notification service plus your app’s device tokens.
Basic flow
- User installs your app and grants notification permission
- Your app gets a device token
- iOS: APNs token
- Android: FCM token
- Your app sends that token to your backend and associates it with the user
- When a transactional event happens in your backend:
- password reset requested
- order shipped
- payment failed
- account verification needed
- Your backend sends a push notification through:
- Firebase Cloud Messaging (FCM) for Android and often as a gateway for iOS too
- or APNs directly for iOS
- or a provider like OneSignal, Braze, AWS SNS, etc.
Important: Push is usually not enough for password resets
For password resets, push notifications should usually be informational only, not the sole delivery method.
Better pattern:
- Send the actual reset link or code via email
- Optionally send a push notification like:
- “A password reset was requested for your account. If this was you, check your email.”
Why:
- Push notifications are not guaranteed to be delivered immediately
- User may not have notifications enabled
- Security-sensitive actions should have a fallback channel
Recommended setup
1. Store device tokens
When the app starts or user logs in:
- get push token
- send it to backend
- store it with:
- user ID
- platform
- app version
- last seen timestamp
2. Create transactional events in backend
Examples:
password_reset_requestedorder_status_changedshipment_deliveredpayment_failed
3. Use a notification service layer
Your backend calls a notification function that:
- chooses recipients
- formats message
- sends via FCM/APNs
- retries on failures
- removes invalid tokens
4. Keep messages short and contextual
Example order update:
- Title:
Your order has shipped - Body:
Order #4821 is on the way. Expected delivery: Friday.
Example password reset alert:
- Title:
Password reset requested - Body:
If this was you, check your email to continue. If not, secure your account.
Example architecture
App → gets token → sends token to Backend
Backend → stores token in DB
Backend event → notification worker
Worker → sends push via FCM/APNs
Provider → delivers to device
Common tools
If you want to build it yourself
- Firebase Cloud Messaging (FCM): easiest for Android, also works with iOS via APNs integration
- APNs: Apple Push Notification service for iOS
- Node.js / Python / Go backend to send pushes
If you want a managed platform
- OneSignal
- Braze
- Airship
- AWS SNS
- Pusher Beams
These help with:
- token management
- segmentation
- retries
- analytics
- templates
Best practices for transactional push
- Send only for user-relevant events
- Keep notifications specific and timely
- Include deep links to the right screen
- Don’t overuse push for spammy updates
- Handle invalid/expired tokens
- Respect user preferences where appropriate
- Use email/SMS as fallback for critical actions
Minimal implementation idea
If you have a backend, the pattern is:
- App registers token:
{
"userId": "123",
"token": "fcm_device_token_here",
"platform": "android"
}
-
Backend stores it.
-
When order changes:
{
"title": "Your order has shipped",
"body": "Order #4821 is on the way.",
"data": {
"type": "order_update",
"orderId": "4821"
}
}
- Send to FCM/APNs.
If you want, I can show you:
- a Node.js example using FCM,
- a Python example, or
- the best architecture for password reset flows.