OK, I know how to implement notification alert, sound or etc...
(好的,我知道如何实施通知警报,声音等...)
Anyway in macOS, I can't hear any custom notification sound!
(无论如何,在macOS中,我听不到任何自定义通知声音!)
all of settings are same as iOS and in iOS, it works properly.
(所有设置均与iOS相同,并且在iOS中正常运行。)
but in macOS, it doesn't :( (但是在macOS中,它不是:()
func setNotificationWhenTimerStart() {
let content = UNMutableNotificationContent()
content.title = "T!mer done"
content.body = "Your T!mer is done!"
content.categoryIdentifier = "finishNotificationCategory"
switch self.userSettings.soundIndex {
case 0:
content.sound = UNNotificationSound.default
case 1:
content.sound = UNNotificationSound(named: self.bicycleNotificationSound)
case 2:
content.sound = UNNotificationSound(named: self.bellStoreDoorNotificationSound)
case 3:
content.sound = UNNotificationSound(named: self.cookooNotificationSound)
case 4:
content.sound = UNNotificationSound(named: self.towerBellNotificationSound)
default:
print("------------Error occured in fixing UNNotificationSound.")
}
print("Notification Sound is set as a (content.sound)
Sound Index is (self.userSettings.soundIndex)")
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: self.userSettings.initialNotificationTime, repeats: false)
let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger)
center.add(request) { (error) in
print("UNNotificationCenter add error: (String(describing: error.debugDescription))")
}
print("UserNotifications is setting done!")
}
is there any requirement for macOS that I don't know?
(我不知道对macOS有什么要求吗?)
please help...
(请帮忙...)
ask by Kreimben translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…