2

We have an issue when we tried to fire only the sound in the push notification in iOS 15.

Sound does not play when UNNotificationPresentationOptions is only set as sound. [.sound] (see snippet code attached)

It seems iOS 15 silence this. It was working before in iOS 14 but stopped working for iOS 15.

The following StackOverflow's URLs recommend playing a sound with AudioServicesPlaySystemSound.

iOS 15 - Notification sounds are not playing for foreground notifications

Before iOS 15, I was able to send sound only local notification, Now I have to show banner

Any tips/recommendations on how to resolve this? Does anyone know if Apple does not allow this anymore?

func taskNotificationCenter(_ center: TaskNotificationCenterType,
               willPresent notification: UNNotificationType,
               withCompletionHandler completionHandler:
                @escaping (UNNotificationPresentationOptions) -> Void) {  
  completionHandler([.sound]) // does not work
//completionHandler([.sound, .alert, .badge]) // works
}

******* LAST UPDATE 26/07/22:** This looks to be fixed on iOS 16.

Luciano Perez
  • 101
  • 1
  • 10
  • Is it behaving the same even if you add priority to notification with 'apns-priority' ? – Mr.SwiftOak Nov 23 '21 at 12:44
  • Bcz `.alert` is important for making alert sound – Kudos Nov 23 '21 at 12:50
  • .alert is deprecated in iOS 15. I only want the sound, nothing else. – Luciano Perez Nov 23 '21 at 12:57
  • Please find my answer here: [link](https://stackoverflow.com/a/70436505/8314394) – Starsky Dec 21 '21 at 13:51
  • @Starsky thanks but this is not what I am looking for. You are showing a `List` option for iOS 14 or above and I only need sound. Thanks again. – Luciano Perez Jan 23 '22 at 18:24
  • @LucianoPerez `List` option means the notification will come with sound when the app is active, and this notification will be placed on the Notification Center list. It will not show anything visual inside the app. I guess there is no way to make just the `[.sound]` option on iOS 15. Give it a try and see for yourself. – Starsky Jan 24 '22 at 08:44
  • This does not work either because it plays the sound but at the same time it "listed" the notification and what I need is just to play the sound. This is what ".list" means. The sound option was working before iOS 15 was introduced. I guess the solution for this is to play a sound when the version will be greater or equal to iOS 15. – Luciano Perez Jan 25 '22 at 10:22
  • 1
    FYI, this is now fixed in iOS 16 – return0 Jul 26 '22 at 04:54
  • @return0 yes, it looks like is fixed on iOS 16. – Luciano Perez Jul 26 '22 at 15:52

0 Answers0