Skip to content

Add iOS FCM support via APNS payload#107

Open
jmscarpa wants to merge 2 commits intorails:mainfrom
jmscarpa:add-ios-fcm-support
Open

Add iOS FCM support via APNS payload#107
jmscarpa wants to merge 2 commits intorails:mainfrom
jmscarpa:add-ios-fcm-support

Conversation

@jmscarpa
Copy link
Copy Markdown

@jmscarpa jmscarpa commented Mar 17, 2026

Add iOS FCM Support via APNS Payload

Problem

The current FCM implementation only sends notifications through Android-specific payload structures, making iOS devices unable to receive push notifications when using Firebase Cloud Messaging. iOS devices require APNS (Apple Push Notification Service) configuration within the FCM message payload to properly receive and display notifications.

Solution

This PR restructures the FCM payload to support both Android and iOS platforms simultaneously by:

  1. Extracting notification fields to top-level: The title and body are now in the top-level notification object, which FCM uses for cross-platform compatibility.

  2. Organizing platform-specific fields:

    • Android-specific notification settings (badge, sound) remain in the android.notification section
    • New APNS (iOS) configuration with iOS-specific alert and sound handling
  3. Adding iOS support: The apns section includes:

    • Alert configuration with title and body
    • Sound settings with "default" as fallback
    • mutable-content: 1 flag to enable rich notifications on iOS

Changes

  • Modified payload_from method in lib/action_push_native/service/fcm.rb
  • Changed from inline payload building to base payload + deep merge pattern for better clarity
  • Maintained all existing Android functionality and backward compatibility

Benefits

✅ iOS devices can now receive push notifications via FCM
✅ Backward compatible with existing Android implementation
✅ Cleaner payload structure with platform-specific sections
✅ Supports rich notifications on iOS through mutable-content

Testing

  • Verify Android notifications continue to work as expected
  • Test iOS notifications on physical devices
  • Verify sound settings work on both platforms
  • Test with and without custom google_data payloads
  • Validate badge/notification count on Android
  • Check that mutable-content enables rich notification handling on iOS

Breaking Changes

None. This is backward compatible.


Checklist:

  • Code follows project style guidelines
  • Tests pass locally
  • Documentation updated (if needed)
  • No new dependencies added

- Extract notification title and body to top-level notification field for iOS compatibility
- Move Android-specific notification fields into android section
- Add APNS configuration with iOS-specific alert and sound settings
- Enable mutable-content for rich notifications on iOS
- Maintain backward compatibility with existing Android functionality
@jmscarpa jmscarpa force-pushed the add-ios-fcm-support branch from db777a7 to 0a4258a Compare March 17, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant