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

1

6

This was working good before iOS 15

let center = UNUserNotificationCenter.current()
let content = UNMutableNotificationContent()
        content.sound = UNNotificationSound.init(named:UNNotificationSoundName(rawValue: sound))
let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger)
center.add(request)

User was getting notification sound, after iOS 15 I have to add

content.body = "Hello iOS 15"

Anyway to send local notification with sound only on iOS 15?

Bookcraft answered 22/9, 2021 at 1:10 Comment(4)
Same issue. Event then, the sound goes away when the banner goes away.Fula
Please find my answer here: linkVaios
My problem is not sound for foreground notification, I am talking about local notification even if the app was closed.Bookcraft
FYI, Apple has fixed this in iOS 16 beta 2. No solution for iOS 15 though.Misnomer
P
-1

Looked deeper on this, we are having the same issue. Best I can tell iOS 15 wont deliver "blank" notifications, not sure if this is a "bug" or intended I couldn't find any documentation around this. We ended up using AudioServicesPlaySystemSound instead for our specific use case. Not sure if that would help you or not.

Pea answered 5/10, 2021 at 20:33 Comment(5)
This just agrees with the question, saying you're seeing the same phenomenon. But "Me too" is not an answer.Materials
The response clearly includes the suggestion of using AudioServicesPlaySystemSound insteadPea
If your app is not running or is backgrounded, how does that produce sound at the required time?Materials
As mentioned, for our use case this is an acceptable trade off, until some other resolution is available via Apple. The goal of the answer being to offer a possible work around to a frustrating change in iOSPea
Well we don't know what your use case is. The question is about the OP's use case, and this doesn't meet it. The question is "send local notification with sound only on iOS 15". I see no evidence that you're doing that or that you're sending a local notification at all.Materials

© 2022 - 2024 — McMap. All rights reserved.