【问题标题】:Before iOS 15, I was able to send sound only local notification, Now I have to show banner在 iOS 15 之前,我只能发送声音本地通知,现在我必须显示横幅
【发布时间】:2021-11-15 11:58:36
【问题描述】:

这在 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)

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

content.body = "Hello iOS 15"

是否仅在 iOS 15 上发送带有声音的本地通知?

【问题讨论】:

  • 同样的问题。事件然后,当横幅消失时声音消失。
  • 请在这里找到我的答案:link

标签: ios notifications ios15 unnotificationrequest


【解决方案1】:

对此进行深入研究,我们遇到了同样的问题。最好我可以告诉 iOS 15 不会提供“空白”通知,不确定这是一个“错误”还是有意我找不到任何有关此的文档。我们最终使用 AudioServicesPlaySystemSound 代替了我们的特定用例。不确定这是否对您有帮助。

【讨论】:

  • 这与问题一致,说你看到了同样的现象。但“我也是”不是答案。
  • 响应中明确包含使用 AudioServicesPlaySystemSound 的建议
  • 如果您的应用未运行或处于后台运行状态,如何在要求的时间发出声音?
  • 如前所述,对于我们的用例,这是可以接受的折衷方案,直到通过 Apple 提供其他解决方案。答案的目标是为 iOS 中令人沮丧的变化提供一种可能的解决方法
  • 好吧,我们不知道您的用例是什么。问题是关于 OP 的用例,这不符合它。问题是“仅在 iOS 15 上发送带有声音的本地通知”。我没有看到任何证据表明您正在这样做,或者您根本没有发送本地通知。
猜你喜欢
  • 1970-01-01
  • 2016-08-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-07
相关资源
最近更新 更多