如何将系统声音用作UILocalNotification的声音?

时间:2016-03-03 22:49:36

标签: ios swift uilocalnotification

我正在编写一个警报应用程序,我想使用Tweet等系统声音作为警报声。我知道alarm.soundName是字符串类型,但我不知道如何将此声音应用于警报。

let alarm: UILocalNotification = UILocalNotification()
alarm.category = "wakeUpAlarms"
alarm.alertAction = "turn off the alarm"
alarm.alertBody = "Time to wake up!"
alarm.fireDate = NSDate(timeIntervalSinceNow: Double(secondsUntilFire))
// get the system sound (tweet in this case)
let systemSoundID: SystemSoundID = 1016
// apply that sound to the alarm
alarm.soundName = systemSoundID     // doesn't work
alarm.userInfo = ["Length": userInfoLength]
UIApplication.sharedApplication().scheduleLocalNotification(alarm)

0 个答案:

没有答案