What is the right way to play a tone associated with notification in iOS 15 without displaying banner or list?
When handling notifications in foreground, both local and push, notification sounds are not playing if UNNotificationPresentationOptions
is only sound
. If additional options like banner
or list
is added along with sound
then notification tone plays.
When app is in background, all options of notification presentation are working properly.
I know alert
option is depreciated from iOS 15. Is using sound
as the only presentation option, no longer valid?
Below is the snippet
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification, withCompletionHandler
completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler(.sound) //not working
//completionHandler([.banner, .sound]) //works
//completionHandler([.list, .sound]) //works
}
Update: Apple confirmed that this was a bug and it is now fixed in iOS 16 beta 2. No solution for iOS 15 though.