How to only make a notification sound without notification banner

When I call the completion handler from the following User Notification Center delegate function and pass UNNotificationPresentationOptions.sound I still get the notification banner:

override func userNotificationCenter(
		_ 						center: 			UNUserNotificationCenter,
		willPresent 			notification: 		UNNotification,
		withCompletionHandler 	completionHandler: 	@escaping (UNNotificationPresentationOptions) -> Void
	) {
		completionHandler(.sound)
	}

All I want is a way to just make a notification sound without showing the notification while the app is in the foreground.

Any ideas?

This is how I am requesting authorization:

[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions: (UNAuthorizationOptionBadge | UNAuthorizationOptionSound)
									  completionHandler: ^ (BOOL granted, NSError * _Nullable error) {
		}];

This is the notification request:

var notification 	= UNMutableNotificationContent()

if (notification != nil) {
notification.categoryIdentifier = "id"
notification.sound 				= .default
notification.title = "title"
notification.body = "body"

request = UNNotificationRequest(
  identifier: NSUUID().uuidString,
  content: 	notification,
  trigger: 	nil
)

UNUserNotificationCenter.current().add(request) { (error) in

}

"Displaying" sound only notifications is no longer possible. If your app is in the foreground, the solution to what you want would be to play a sound yourself.

An easy way to play an alert sound is using AudioServicesPlayAlertSound(_ inSystemSoundID: SystemSoundID) Described here: https://developer.apple.com/documentation/audiotoolbox/1405202-audioservicesplayalertsound

Hi [@Gualtier Malde](https://developer.apple.com/forums/profile/Gualtier Malde), there is one scenario why I want to use notification play sound only: user enable a focus mode, we should not play the sounds. But in macOS, we can't get the focus status when user don't allow share focus status. UNUserNotificationCenter can know current focus status and decide to play sound or not.

Any suggestion about this case?

How to only make a notification sound without notification banner
 
 
Q