Skip to content

Pass custom APNs sounds through for FCM notifications - #747

Open
IshanA2007 wants to merge 1 commit into
rpush:masterfrom
IshanA2007:fix/issue-715
Open

IshanA2007 wants to merge 1 commit into
rpush:masterfrom
IshanA2007:fix/issue-715

Conversation

@IshanA2007

Copy link
Copy Markdown

Fixes #715

Since the move to the FCM v1 API, apns_config in Rpush::Client::ActiveModel::Fcm::Notification only set aps.sound when the notification's sound was exactly 'default':

aps['sound'] = 'default' if sound == 'default'

Any custom sound (e.g. 'alert.caf') was silently dropped from the APNs payload, so iOS devices receiving FCM notifications fell back to no sound. The Android payload built a few lines above already passes the value through (json['sound'] = sound if sound), as does the APNs client.

This makes the APNs branch do the same: pass sound through whenever it is set, and keep omitting the key when it is nil so notifications without a sound stay silent, matching the existing behaviour and the APNs client's own specs.

Added regression specs to the shared FCM notification examples for both the custom-sound and the nil cases.

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 rpush#715
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.

custom sounds for APN stopped working after moving to FCM v2

1 participant