Mobile App Push Notification Systems: APNs, FCM & Delivery Reliability
Unreliable push notification delivery damages user retention. Managing token invalidations and silent background data pushes requires clean queueing.
Why This Matters
Reliable real-time re-engagement across millions of iOS and Android devices.
Core Concepts & Architecture
Expired device push tokens must be deactivated immediately upon receiving Unregistered responses from Apple/Google.
Implementation Details
HTTP/2 token-based APNs authentication, FCM v1 REST API migration, and Expo Push Notification service.
Practical Code Example
The following code illustrates this pattern in a production-ready implementation:
import admin from 'firebase-admin';
export async function sendPushMessage(token: string, title: string, body: string, data?: any) {
try {
await admin.messaging().send({
token,
notification: { title, body },
data: data || {},
});
} catch (err: any) {
if (err.code === 'messaging/registration-token-not-registered') {
// Deactivate obsolete device token
await DeviceToken.updateOne({ token }, { active: false });
}
}
}
Production Considerations
When deploying this in production environments:
- Enforce strict typing and runtime schema validation on all public ingestion vectors.
- Implement defensive rate limiting, connection pooling, and graceful process shutdown.
- Monitor execution latencies using structured telemetry, APM traces, and health check endpoints.
Performance, Security & Scalability
- Security & Authorization: Validate inputs, sanitize database queries, and maintain strict access boundaries.
- Scalability: Design for stateless horizontal scaling and leverage connection pooling and edge caching.
- Telemetry: Track P95 and P99 latency percentiles to detect regressions early in staging.
Common Mistakes & Best Practices
Common Mistakes
- Neglecting Edge Case Validation: Failing to handle network partitions or invalid payloads gracefully.
- Hardcoding Configuration: Always inject environment variables and avoid magic constants in domain code.
Best Practices
- Idempotency: Guarantee safe retries on state-mutating operations.
- Automated CI/CD: Run regression test suites in isolated branches before cutting over production traffic.
Conclusion
Building a reliable notification delivery worker: Token rotation, retry queues, and payload size constraints.
Building a modern mobile or web product? Discuss your upcoming project with our software engineering team at DevMinds Technologies.
Sources & References
- Firebase Cloud Messaging v1 Migration Guide (Official Documentation)