Prompt
push notifications backend for mobile app
Latest observation
Nov 4, 2026
OpenAI APIWeb search: off
A push notifications backend for a mobile app usually needs to do 5 things:
- Store device tokens
- Create notification requests
- Queue and deliver messages
- Talk to APNs (iOS) / FCM (Android)
- Track delivery, retries, and failures
Typical architecture
1) Mobile app
- Registers for push notifications
- Gets a device token from:
- APNs for iOS
- FCM for Android
- Sends the token to your backend with user/session info
2) Backend API
Endpoints like:
POST /devices/registerPOST /notifications/sendGET /notificationsDELETE /devices/{token}
Responsibilities:
- Save tokens
- Associate tokens with users/devices
- Validate notification payloads
- Enqueue jobs for sending
3) Notification service / worker
Background workers:
- Pull jobs from a queue
- Send to APNs/FCM
- Retry transient failures
- Mark invalid tokens as disabled
4) Database
Tables/entities typically include:
- users
- devices
iduser_idplatform(ios,android)push_tokenapp_versionlast_seen_atenabled
- notifications
idtitlebodydataJSONtarget_audiencestatus
- delivery_logs
notification_iddevice_idprovider_responsesent_atsuccess/failure
Core flow
Register device
- App gets push token
- App calls backend
- Backend stores/updates token
- Backend uses token later for delivery
Send notification
- Admin/user action creates notification
- Backend saves notification
- Job is queued
- Worker sends via APNs/FCM
- Worker stores result
- Invalid tokens are removed or disabled
Important design considerations
Scalability
- Use a queue like:
- RabbitMQ
- SQS
- Kafka
- Redis queue
- Workers can scale horizontally
Reliability
- Retry on network errors
- Use exponential backoff
- Deduplicate notifications if needed
Token lifecycle
- Tokens change often
- Re-register tokens on app launch/login
- Remove invalid tokens when APNs/FCM says they’re bad
Personalization / targeting
Support sending to:
- One device
- One user
- A segment
- All users
- A topic/tag
Security
- Authenticate device registration
- Restrict who can send notifications
- Sign or authorize internal notification requests
Recommended tech stack example
Simple stack
- Backend: Node.js / NestJS, Django, FastAPI, Spring Boot, Go
- DB: PostgreSQL
- Queue: Redis + BullMQ / Celery / Sidekiq
- Push providers: FCM + APNs
- Monitoring: Sentry + Prometheus + Grafana
Minimal API design
Register device
POST /devices/register
{
"user_id": "123",
"platform": "ios",
"push_token": "abcdef...",
"device_id": "phone-uuid"
}
Send notification
POST /notifications/send
{
"target_type": "user",
"target_id": "123",
"title": "Hello",
"body": "You have a new message",
"data": {
"chat_id": "789"
}
}
Best practice
If you want something production-ready, build it as:
- API service for registration and admin actions
- Queue-based worker for sending
- Provider adapters for APNs and FCM
- Logging/metrics for delivery observability
If you want, I can also give you:
- a full database schema
- a microservice design
- a Node.js / Python implementation example
- an AWS/GCP architecture for this backend