我試圖將本地通知聲音設置爲我下載的音頻。 但是,當通知觸發沒有聲音播放。我不知道我要去哪裏錯。請查看代碼並讓我知道我的錯誤。NS通知不播放下載的聲音
func setNotificationWithDate(date: NSDate, onWeekdaysForNotify: [Int], snooze: Bool, soundName: String, title: String, vibrate: Bool) {
let AlarmNotification: UILocalNotification = UILocalNotification()
AlarmNotification.alertBody = title
AlarmNotification.alertAction = "Open App"
AlarmNotification.category = "AlarmCategory"
AlarmNotification.timeZone = NSTimeZone.defaultTimeZone()
let datesForNotification = correctDate(date, onWeekdaysForNotify:onWeekdaysForNotify)
for d in datesForNotification
{
AlarmNotification.fireDate = d
let tracksDic = appDelegate().alarmTrackArray.objectAtIndex(d.dayOfWeek()!)
let sound = tracksDic.valueForKey("t_id") as? String
AlarmNotification.soundName = sound! + ".mp3"
print(AlarmNotification.soundName)
let userInfo = ["date":date,"soundDetail":tracksDic,"title":title ,"vibrate":vibrate]
AlarmNotification.userInfo = userInfo
print(AlarmNotification.soundName)
UIApplication.sharedApplication().scheduleLocalNotification(AlarmNotification)
}
}
確保設備不是靜音或DND模式。 –
我的設備未處於靜音模式。其工作正常,我已經添加到我的應用程序的聲音。 –