swift - 无法在 Swift (UIKIT) 中生成本地通知
解决方案
UNUserNotificationCenter.current().delegate = self
使用 UNUserNotificationCenter 分配委托并添加以下方法。
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler (.banner)
}
此 UNNotificationPresentationOptions “横幅”在应用程序处于前台时显示通知。
推荐阅读
- javascript - JSON 未定义字段 p5.js
- jquery - 表单注释中表格数据的jQuery选择工作
- python - 正则表达式在谷歌学者更多的结果定位器
- javascript - Javascript数组没有以某种方式变异
- javascript - VIDEOJS:错误:TypeError:this.ytPlayer.getDuration 不是函数 && this.ytPlayer.getPlaybackRate
- sql - Spark SQL Group by 未按预期工作
- python - python 3.7 tkinter 的空列表框返回值
- excel - 在数组中传递工作表函数参数
- apache-spark - Spark Union 与使用 lit in spark 添加列
- ruby-on-rails - FactoryBot #build 对象与传入的关联对象未正确创建对象