Integrate real-time push notifications into your React Native app using Firebase Cloud Messaging (FCM) for Android and Apple Push Notification service (APNs) for iOS, ensuring users stay connected across both platforms.
React Native’s cross-platform nature allows unified push notification handling, but platform-specific configuration and certificates are still required.

Prerequisites

Before implementing push notifications, ensure you have:

Firebase Project

Active Firebase project with FCM enabled for both platforms

Platform Certificates

Android FCM service account JSON and iOS APNs .p12 certificate

social.plus SDK

social.plus TypeScript SDK properly integrated

Development Setup

React Native development environment configured for both platforms

Step 1: Install Dependencies

Core Firebase Dependencies

# Install React Native Firebase
npm install @react-native-firebase/app @react-native-firebase/messaging

# Optional: For enhanced notification handling
npm install @react-native-async-storage/async-storage
npm install react-native-permissions

# For iOS, install pods
cd ios && pod install && cd ..
Always use the latest stable versions. Check the React Native Firebase documentation for current compatibility.

Additional Utility Libraries

# For better permission handling
npm install react-native-permissions

# For local storage
npm install @react-native-async-storage/async-storage

# For device info (optional)
npm install react-native-device-info

Step 2: Platform Configuration

Android Configuration

  1. Add google-services.json to android/app/
  2. Update build.gradle files:
// android/build.gradle
buildscript {
  dependencies {
    classpath 'com.google.gms:google-services:4.3.15'
  }
}

// android/app/build.gradle
apply plugin: 'com.google.gms.google-services'

android {
  compileSdkVersion 34
  
  defaultConfig {
    minSdkVersion 21
    targetSdkVersion 34
  }
}
  1. Add permissions to AndroidManifest.xml:
<!-- android/app/src/main/AndroidManifest.xml -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    
    <!-- Push notification permissions -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
    
    <application>
        <!-- Firebase messaging service -->
        <service
            android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
        
        <!-- Your activities -->
    </application>
</manifest>

iOS Configuration

  1. Add GoogleService-Info.plist to iOS project in Xcode
  2. Enable Push Notifications capability in Xcode:
    • Select your target → Signing & Capabilities → + Capability → Push Notifications
  3. Update AppDelegate for Firebase:
// ios/YourApp/AppDelegate.mm
#import <Firebase.h>
#import <UserNotifications/UserNotifications.h>

@interface AppDelegate () <UNUserNotificationCenterDelegate>
@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  // Configure Firebase
  [FIRApp configure];
  
  // Set notification delegate
  [UNUserNotificationCenter currentNotificationCenter].delegate = self;
  
  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

// Handle notification when app is in foreground
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
       willPresentNotification:(UNNotification *)notification
         withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
  completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound);
}

@end
  1. Update Info.plist for background modes:
<!-- ios/YourApp/Info.plist -->
<dict>
    <!-- Existing keys -->
    
    <key>UIBackgroundModes</key>
    <array>
        <string>background-fetch</string>
        <string>remote-notification</string>
    </array>
    
    <key>FirebaseAppDelegateProxyEnabled</key>
    <false/>
</dict>

Step 3: Upload Certificates to social.plus Console

Android - FCM Service Account

  1. Generate FCM service account JSON:
    • Go to Firebase Console → Project Settings → Service Accounts
    • Click “Generate new private key”
    • Download the JSON file
  2. Upload to social.plus Console:
    • Navigate to Settings → Push Notifications
    • Upload the FCM service account JSON file

iOS - APNs Certificate

  1. Generate .p12 certificate following the iOS setup guide
  2. Upload to social.plus Console:
    • Navigate to Settings → Push Notifications
    • Upload the .p12 file with password
Refer to the iOS Push Notification Certificate Setup Guide for detailed certificate generation instructions.

Best Practices

Testing Strategies

Firebase Console Testing

  1. Use Firebase Console to send test messages:
    • Go to Firebase Console → Cloud Messaging → Send Test Message
    • Use the FCM token from your debug component
    • Test different message types and data payloads
  2. Test Both Platforms:
    • iOS: Test with TestFlight builds (debug builds don’t receive push notifications)
    • Android: Test with both debug and release builds

Troubleshooting

Testing Requirements: iOS push notifications require TestFlight or App Store builds. Android notifications work in both debug and release builds, but release builds are recommended for production testing.