繁体   English   中英

macOS上的UserNotifcation声音

[英]UserNotifcation SOUND on macOS

好的,我知道如何实施通知警报,声音等...

无论如何,在macOS中,我听不到任何自定义通知声音!

所有设置均与iOS相同,并且在iOS中正常运行。 但是在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("\tNotification Sound is set as a \(content.sound)\n\tSound 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!")
}

我不知道对macOS有什么要求吗?

请帮忙...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM