问题描述
我能够成功显示通知,但遇到了两个问题:
- 我想播放铃声而不是播放通知声音。
- 如果用户在 30 秒内没有执行任何操作,我还想隐藏通知
let content = UNMutableNotificationContent()
content.title = "Incoming Call"
content.subtitle = "Call from a user XYZ"
content.sound = UNNotificationSound.default
// show this notification five seconds from now
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5,repeats: false)
// choose a random identifier
let request = UNNotificationRequest(identifier: UUID().uuidString,content: content,trigger: trigger)
// add our notification request
UNUserNotificationCenter.current().add(request)
我尝试了 stackoverflow 中的一些解决方案,但像 notif.soundName = UILocalNotificationDefaultSoundName;
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)