how to play custom notification sound in ios push notification using FCM
thanks for your answers and comments
It is working fine now after adding notification file in build phases (Xcode).
For Ref: Playing a custom sound on receiving a remote push notification on iOS 12 from FCM
FCM custom sound not working on iOS when in background mode
After several additional rounds communication with Firebase, here is the current status update and their response:
I would like to let you know that this issue was just recently
identified as a bug with our Legacy API that’s not properly handling
the custom sound for iOS. Our FCM gurus have identified the fix for
this issue, and the fix is about to be released on our production, but
we can’t share any exact details or timeline for the release. The fix
should let you send notifications properly based on your custom sounds
configuration and there should be no code changes needed on your end.
Also, it should still properly handle the notification sounds if the
app is closed or in background state for your iOS application.
We are furthermore told that for the moment, migration from FCM HTTP to HTTP v1 is the only work around. Will post here again once we hear confirmation on the fix to the Legacy API (which most people reading this as using). Stay tuned...
Enable Default Sound on FCM Push Notification for iOS
insane, but for me, some reason in appdelegate the window variable was deleted and that resulted into this issue..
adding it back, sound works correctly now...
Push notification ios from Firebase is received but no sound or in notification center
If your app is open, the operating system will not present the banner or play a sound on its own. Instead, you get notified about the notification in your AppDelegate.
If you target iOS 10 or above, you can use UNUserNotificationCenter
and it lets you present the notification even if your app is open. Below is an example:
In your NUserNotificationCenterDelegate
object, pass .alert
, .badge
or .sound
to the completion block of willPresent notification
method:
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)
{
completionHandler([.alert, .badge, .sound])
}
Although be very cautious about this approach. Users can easily forbid your app from presenting any notifications. If so, the above method will result in nothing being shown to the user.
It may be a better approach to present all notifications yourself if your app is open.
Related Topics
Is the Function 'Dlopen()' Private API
Coreanimation - Opacity Fade in and Out Animation Not Working
Lock iOS App in Single App Mode Programmatically
iOS 7 Device Token Is Different for Same Device
Change the Alpha Value of the Navigation Bar
Will Appstore Reviewers Allow Us to Use Dynamic Library in iOS8
How to Receive Push Notifications of an Other App
Collectionview with the Horizontal Scroll with Mulitple Section
Xcode 11.4. Navigation's Title Color Gone Black from Storyboard
How to Animate a Uiview with Constraints in Swift
It Gives Errors When Using Swift Static Library with Objective-C Project
How to Do Something Before Unwind Segue Action
Nsuserdefaultsdidchangenotification and Today Extensions
Pass Different Parameters to an Ibaction
Link Errors with Parse.Framework iOS
Add Inverted Circle Overlay to Map View