Skip to main content
⚡ Calmops

Push Notifications: FCM, APNs, and Delivery Optimization

Push Notifications: FCM, APNs, and Delivery Optimization

TL;DR: This guide covers push notification implementation. Learn FCM, APNs, notification content, and optimizing delivery for mobile apps.


Introduction

Push notifications have become an essential component of mobile app engagement strategies. These small, targeted messages delivered directly to users’ devices enable apps to maintain ongoing communication with their audience, driving user retention, increasing app usage, and delivering time-sensitive information. Whether it’s a chat message, a shopping promotion, a news alert, or a reminder, push notifications help apps cut through the noise and reach users effectively.

The push notification ecosystem is dominated by two major platforms: Firebase Cloud Messaging (FCM) for Android and cross-platform apps, and Apple Push Notification Service (APNs) for iOS devices. While these services serve similar purposes, they have distinct architectures, capabilities, and implementation requirements. Understanding both is essential for developers building mobile applications that need to reach users across platforms.

This comprehensive guide explores the technical foundations of push notification systems, implementation strategies for both platforms, best practices for notification content and timing, and techniques for optimizing delivery and engagement. Whether you are implementing push notifications for the first time or looking to improve an existing implementation, this guide provides the knowledge and practical examples needed to succeed.

Understanding Push Notification Architecture

How Push Notifications Work

Push notifications operate on a publish-subscribe model that involves multiple components working together. When an app server needs to send a notification to a user, it doesn’t communicate directly with the user’s device. Instead, it sends the message to a push notification service—FCM or APNs—which then handles delivery to the specific device. This architecture provides several important benefits, including battery efficiency, reliable delivery even when apps are closed, and centralized management of notification sending.

The process begins when a user installs and opens an app for the first time. The app registers with the appropriate push notification service and receives a unique token that identifies that specific installation. This token serves as the address for sending notifications to that particular device. The app then sends this token to its backend server, which stores it for later use when sending notifications.

When the server wants to send a notification, it sends an HTTP request to the push notification service containing the device token and the notification payload. The push service then delivers the message to the device, where the operating system displays the notification to the user, even if the app is not currently running. If the user taps the notification, the system launches the app and provides the notification data to the app.

The Role of Device Tokens

Device tokens are fundamental to push notification functionality. Each token is unique to a specific app installation on a specific device. When users reinstall an app or clear app data, a new token is generated. Apps must handle token refresh events and update their server records accordingly to ensure continuous notification delivery.

Tokens are platform-specific—iOS devices receive tokens from APNs, while Android devices use FCM tokens. Apps that support both platforms must maintain both types of tokens for each user and send notifications through the appropriate service based on the user’s device type.

The token format varies between services but typically consists of a long alphanumeric string. Servers must store these tokens securely and associate them with user accounts to enable targeted notification sending. Consider implementing token refresh handling to maintain accurate token records over time.

Push Notification Services

Firebase Cloud Messaging (FCM)

Firebase Cloud Messaging is Google’s solution for sending push notifications to Android devices, iOS devices, and web applications. FCM is the successor to Google Cloud Messaging (GCM) and provides a unified API for cross-platform notification delivery. The service is free to use and offers robust features for notification targeting, scheduling, and analytics.

FCM supports both upstream and downstream messaging. Downstream messaging—the traditional push notification model where servers send messages to devices—is the most common use case. Upstream messaging allows devices to send messages back to servers, useful for scenarios like chat applications where user messages need to reach the server.

The FCM HTTP API enables sending notifications with various payload options. Beyond the standard notification title and body, developers can include custom data fields that apps can access when handling notifications. Rich notification features support images, actions, and formatting. The FCM SDK handles notification display on Android devices automatically, while iOS notifications delivered through FCM still rely on APNs for delivery.

Service Platform Provider Key Features
FCM Android, iOS, Web Firebase/Google Cross-platform, analytics, segmentation
APNs iOS, macOS Apple Rich notifications, Critical Alerts
HMS Push Huawei Huawei China market, HMS ecosystem

Apple Push Notification Service (APNs)

Apple Push Notification Service is Apple’s native push notification infrastructure, required for all push notifications on iOS, iPadOS, and macOS devices. APNs provides reliable, secure delivery of notifications to Apple devices and supports rich notification features including images, videos, and interactive actions.

APNs uses a certificate-based authentication system. Developers must create either a certificate or a token for their app, which is used to authenticate with Apple’s servers. Certificates must be renewed annually, making token-based authentication increasingly popular as it offers longer validity periods.

The APNs service offers different priority levels for notifications. Standard priority notifications are delivered promptly but may be batched during periods of high load. The high-priority option ensures immediate delivery but should be used sparingly to preserve battery life. Critical Alerts—a special category for time-sensitive notifications like health and safety alerts—require specific entitlements and are approved by Apple for limited use cases.

APNs supports notification payloads with various options including mutable-content for notification content modification, sound customization, badge counts, and thread identifiers for grouping related notifications. Rich notifications support attachments and custom user interfaces through Notification Content App Extensions.

Huawei Push Kit

For apps targeting the Chinese market or Huawei devices, HMS Push Kit provides an alternative notification service. Huawei’s mobile services have grown significantly, particularly in China where Google Play Services are not available. Push Kit offers similar functionality to FCM for Huawei devices, enabling notification delivery independent of Google’s infrastructure.

Apps targeting global audiences may need to implement multiple push services to ensure notifications reach all users regardless of their device and region. Implementation strategies include detecting the device type and available services, maintaining tokens for all applicable services, and sending notifications through all relevant channels.

React Native Implementation

Implementing push notifications in React Native requires native module integration and platform-specific code. The @react-native-firebase/messaging library provides cross-platform support, handling the complexities of both FCM and APNs under a unified API.

Initial Setup and Configuration

Setting up push notifications begins with installing the messaging package and configuring native project settings. For iOS, this includes enabling push notification capabilities in Xcode, configuring background modes for remote notifications, and setting up APNs authentication. Android configuration involves adding the Firebase configuration file and ensuring Google Play Services are available.

The implementation requires adding the messaging library to your project and configuring the native platforms accordingly. For React Native projects, the Firebase messaging package provides the core functionality, while additional packages handle local notifications and notification channels.

import messaging from '@react-native-firebase/messaging';

// Request permission
const requestPermission = async () => {
  const authorizationStatus = await messaging().requestPermission();
  return authorizationStatus === messaging.AuthorizationStatus.AUTHORIZED;
};

// Get token
const getToken = async () => {
  const token = await messaging().getToken();
  await api.savePushToken(token);
  return token;
};

// Handle notifications
messaging().onMessage(async remoteMessage => {
  // Foreground notification
  showNotification(remoteMessage.notification);
});

messaging().onNotificationOpenedApp(remoteMessage => {
  // App opened from notification
  handleNotificationTap(remoteMessage.data);
});

Handling Permissions

Requesting notification permissions is a critical first step. iOS requires explicit user permission before an app can receive push notifications. The permission request should be timed appropriately—asking immediately upon app launch can feel aggressive, while asking too late may miss an opportunity when users are engaged.

Best practices suggest requesting permission after users have had a chance to experience the app’s value. Many apps delay the permission request until after the user has completed an onboarding flow or performed a meaningful action. The permission dialog cannot be customized on iOS, making timing even more important.

Android’s permission model is different—users can disable notifications at the system level, but apps can generally send notifications without explicit runtime permission on older Android versions. Android 13 introduced runtime permission for notifications, requiring similar handling to iOS. Your code should check current permission status and handle cases where users have denied permission.

Token Management

Obtaining and managing the device token is essential for notification delivery. The token should be retrieved when the app starts and sent to your server for storage. Additionally, implement token refresh handling to detect when tokens change and update your server records.

// Get initial token on app start
useEffect(() => {
  const initializeNotifications = async () => {
    const hasPermission = await requestPermission();
    if (hasPermission) {
      const token = await messaging().getToken();
      await api.registerToken(token);
    }
  };
  
  initializeNotifications();
  
  // Handle token refresh
  const unsubscribe = messaging().onTokenRefresh(async token => {
    await api.updateToken(token);
  });
  
  return unsubscribe;
}, []);

// Handle notifications when app is in foreground
messaging().onMessage(async remoteMessage => {
  const notification = remoteMessage.notification;
  
  // Display in-app notification or pass to native handler
  displayInAppNotification({
    title: notification.title,
    body: notification.body,
    data: remoteMessage.data
  });
});

Handling Notification Taps

When users tap notifications, apps need to handle the navigation appropriately. The notification may open the app from a closed state or bring a background app to the foreground. Both scenarios require handling to ensure users reach the relevant content.

For apps using React Navigation, you can configure deep linking to handle notification navigation. Store the target screen and any parameters in the notification data, then navigate appropriately when the app opens. Consider edge cases like the app being opened from a notification when already in the foreground.

Notification Content Best Practices

Crafting Effective Messages

The content of your notifications directly impacts engagement rates. Effective notifications are clear, concise, and valuable to the user. The title should immediately communicate what the notification is about, while the body provides additional context or a call to action.

Personalization significantly improves notification effectiveness. Using the user’s name in notifications creates a sense of direct communication. Beyond simple personalization, tailor notification content based on user behavior, preferences, and context. A notification about a sale is more relevant to users who have shown shopping interest; a reminder about an abandoned cart is relevant only to users who left items behind.

Actionable notifications encourage user engagement. Include clear calls to action in your notification text—Shop now, View details, Reply—giving users a specific next step. Avoid vague messages like “You have a new message” without indicating who it’s from or what it’s about.

Timing and Frequency

Notification timing affects both immediate engagement and long-term user retention. Sending notifications at inappropriate times—such as late at night—creates negative associations with your app. Respect users’ time zones and typical usage patterns when scheduling notifications.

Frequency matters equally. Too many notifications lead to user frustration and app uninstalls; too few may cause users to forget about your app. Monitor notification engagement metrics and adjust frequency based on user response. Allow users to control notification preferences, letting them choose what types of notifications they want to receive.

Consider batching related notifications rather than sending multiple separate notifications. If a user receives multiple messages in a short period, combining them into a single notification reduces interruption while ensuring all information reaches the user.

Rich Notifications and Actions

Modern push notifications support rich content beyond simple text. Including images in notifications increases engagement significantly—visual content catches attention and communicates information more effectively than text alone. Both FCM and APNs support image attachments in notifications.

Notification actions enable users to take immediate action without fully opening the app. Quick reply options in messaging apps, call-to-action buttons in retail apps, and acknowledgment buttons in productivity apps all leverage notification actions. Keep actions simple and limited—typically two to three actions maximum.

Interactive notifications allow more complex interactions. Users can respond to messages, mark tasks complete, or interact with content directly from the notification. Implementing these features requires additional development but can significantly improve user experience.

Opt-Out and Preference Management

Respecting user preferences builds trust and improves long-term engagement. Provide clear settings that let users control which notifications they receive. Allow granular control over different notification categories—users may want urgent alerts but not promotional messages.

Make it easy to unsubscribe from notifications. Include an unsubscribe link in commercial notifications, and honor opt-out requests promptly. Users who feel their choices are respected are more likely to remain engaged with your app.

Monitor permission denial rates and opt-out rates as key metrics. High denial rates may indicate poor timing or unclear value propositions during the permission request. High opt-out rates may suggest sending too many notifications or content that users don’t find valuable.

Server-Side Implementation

Sending Notifications

Your server needs to communicate with FCM and APNs to send notifications. Both services provide HTTP APIs that accept notification payloads and deliver them to devices. The basic payload includes the device token, notification title and body, and optional data fields.

For production systems, implement proper error handling and retry logic. Both FCM and APNs may return errors for invalid tokens, rate limiting, or service interruptions. Invalid tokens should be removed from your database to prevent repeated failed delivery attempts.

Consider using notification management platforms that abstract the complexity of multiple push services. Services like OneSignal, Airship, and Firebase Admin SDK simplify notification sending while providing additional features like segmentation, scheduling, and analytics.

// Example FCM sending with Firebase Admin
const admin = require('firebase-admin');
admin.initializeApp();

async function sendPushNotification(token, title, body, data) {
  const message = {
    notification: {
      title: title,
      body: body
    },
    data: data || {},
    token: token,
    android: {
      notification: {
        channel_id: 'default',
        priority: 'high'
      }
    },
    apns: {
      payload: {
        aps: {
          sound: 'default',
          badge: 1
        }
      }
    }
  };
  
  try {
    const response = await admin.messaging().send(message);
    console.log('Successfully sent message:', response);
    return { success: true, response };
  } catch (error) {
    console.error('Error sending message:', error);
    return { success: false, error };
  }
}

Notification Targeting

Sending notifications to specific users or groups requires proper audience management. Segment your user base based on demographics, behavior, preferences, or custom attributes. Most push services support server-side audience definition that targets specific user segments.

Topic-based messaging allows sending to users who have subscribed to specific topics. This approach works well for content categories—users subscribe to topics like “sports,” “news,” or “deals” and receive notifications about those topics. Topics are easy to implement and scale well.

Device group messaging targets notifications to specific groups of devices belonging to a single user. This is useful for scenarios where users have multiple devices and want notifications delivered to all of them—or to the most recently active device only.

Optimization and Analytics

Delivery Optimization

Notification delivery optimization involves ensuring messages reach users quickly and reliably. Both FCM and APNs provide delivery timestamps that help identify delays. Monitor these metrics and investigate patterns that suggest delivery problems.

Device conditions affect notification delivery. Devices that are offline, in airplane mode, or have restrictive battery settings may experience delayed or failed delivery. While you can’t control device settings, understanding these limitations helps set appropriate expectations and may inform user education efforts.

Consider using high-priority notifications sparingly. While they ensure immediate delivery, excessive use may impact device battery life and user experience. Reserve high priority for genuinely time-sensitive notifications like security alerts or urgent communications.

Engagement Analytics

Tracking notification engagement provides insights that drive optimization. Key metrics include delivery rate (notifications successfully delivered), open rate (users who tapped the notification), and conversion rate (users who completed a desired action).

A/B testing notification content helps identify what resonates with users. Test different titles, body text, images, and calls to action. Most push notification services support A/B testing functionality that makes experiments easy to implement and analyze.

Analyze engagement patterns over time to identify optimal send times and frequencies. Users in different time zones or with different usage patterns may respond to notifications at different times. Segment analysis reveals these patterns and enables more targeted sending.

Performance Monitoring

Implement comprehensive monitoring for your notification system. Track metrics including notification delivery success rates, error rates by error type, token invalidation rates, and notification engagement. Set up alerts for anomalous patterns that might indicate problems.

Monitor the impact of notifications on app performance. Processing incoming notifications can consume resources, particularly when handling rich content or notification actions. Ensure your app handles notification processing efficiently without degrading user experience.

Conclusion

Push notifications remain a powerful tool for mobile app engagement when implemented thoughtfully. Success requires understanding both the technical architecture—FCM, APNs, and device tokens—and the user experience considerations that drive engagement.

Key implementation requirements include proper service setup with FCM and APNs configuration, thoughtful permission handling that respects user experience, compelling notification content that provides value, and delivery optimization through timing and segmentation.

As mobile ecosystems evolve, push notification capabilities continue to expand. Stay current with platform updates, particularly regarding permission models and new notification features. The fundamentals—clear content, appropriate timing, user control—remain constant even as technical implementations evolve.

With careful implementation and ongoing optimization, push notifications can drive significant engagement and retention improvements. Use the strategies and examples in this guide to build notification systems that users appreciate receiving.

Comments