在 iOS 15 之前,我只能发送声音本地通知,现在我必须显示横幅

iTa*_*rek 6 notifications ios unnotificationrequest ios15

这在 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)
Run Code Online (Sandbox Code Playgroud)

用户收到通知声音,iOS 15 之后我必须添加

content.body = "Hello iOS 15"
Run Code Online (Sandbox Code Playgroud)

无论如何,只能在 iOS 15 上发送带有声音的本地通知?

cor*_*303 -1

更深入地研究这一点,我们遇到了同样的问题。据我所知,iOS 15 不会发送“空白”通知,不确定这是一个“错误”还是有意为之,我找不到任何相关文档。我们最终使用 AudioServicesPlaySystemSound 来代替我们的特定用例。不确定这是否对您有帮助。