Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Pass custom APNs sounds through for FCM notifications
apns_config only ever set aps['sound'] when the notification's sound
attribute was exactly 'default', so any custom sound value configured
by the user was silently omitted from the APNs payload sent via FCM.
Pass the sound through when set, and keep omitting the key entirely
when no sound is configured (so notifications stay silent, matching
the existing behavior of android_notification and the plain APNs
client).

Fixes #715
  • Loading branch information
IshanA2007 committed Sep 2, 2026
commit e248b3b6f75d99aa5411b392435c33d254dec1e5
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Fix active record logger dependency for older rails versions that was breaking the build [\#731](https://github.com/rpush/rpush/pull/731) ([SixiS](https://github.com/sixis))
* Specify ostruct dependency ([not bundled with ruby since 3.5](https://github.com/ruby/ruby/blob/4eaa245fccd3dd9a61fe1b5f114a6fb47907640a/lib/bundled_gems.rb#L18)) [\#740](https://github.com/rpush/rpush/pull/740) ([grekko-headacy](https://github.com/grekko-headacy))
* Fix APNs P8 HTTP2 error recovery [\#734](https://github.com/rpush/rpush/pull/734) ([kjvarga](https://github.com/kjvarga)) ([SixiS](https://github.com/SixiS))
* Fix custom APNs sounds being dropped for FCM notifications [\#747](https://github.com/rpush/rpush/pull/747) ([IshanA2007](https://github.com/IshanA2007))

[Full Changelog](https://github.com/rpush/rpush/compare/v9.2.0...HEAD)

Expand Down
2 changes: 1 addition & 1 deletion lib/rpush/client/active_model/fcm/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def apns_config
aps = ActiveSupport::OrderedHash.new
aps['mutable-content'] = 1 if mutable_content
aps['content-available'] = 1 if content_available
aps['sound'] = 'default' if sound == 'default'
aps['sound'] = sound if sound
aps['badge'] = badge if badge

json['payload']['aps'] = aps
Expand Down
10 changes: 10 additions & 0 deletions spec/unit/client/shared/fcm/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@
expect(notification.as_json['message']['apns']['payload']['aps']['badge']).to eq(3)
end

it 'passes through a custom sound to the apns payload' do
notification.sound = 'custom.aiff'
expect(notification.as_json['message']['apns']['payload']['aps']['sound']).to eq('custom.aiff')
end

it 'omits the apns sound when no sound is set' do
notification.sound = nil
expect(notification.as_json['message']['apns']['payload']['aps']).not_to have_key('sound')
end

it 'excludes the notification payload if undefined' do
expect(notification.as_json['message']).not_to have_key 'notification'
end
Expand Down