2016-05-03 13 views
-1

ダウンロードしたオーディオにローカル通知音を設定しようとしています。 しかし、通知トリガがサウンドが再生されないとき。私はどこが間違っているのか分かりません。コードを見て、私の間違いを知らせてください。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) 
    } 
} 
+0

デバイスがサイレントモードまたはDNDモードでないことを確認します。 –

+0

デバイスがサイレントモードではありません。私のアプリにあらかじめ追加しておいたサウンドでうまく動作します。 –

答えて

0

音は、あなたのアプリケーションのバンドルに実際にある正しい形式であることを確認します(リニアPCMまたはIMA4、ほとんどどこでもiOSのは、それを行う方法を教えてくれるために音を変換する方法について説明している)、および30秒未満です。

参考リンク:

Choose custom sound for local notifications

を更新あなたのコメントによると:

ダウンロードしたファイルは、あなたのバンドルではありません。それはその音を演奏しません!!!!

+0

私は通知とその正常にmp3ファイルを再生しています。しかし、私がダウンロードしたものを設定しようとすると、サウンドが再生されません。アップル通知のサウンドプロパティを確認したところ、 "public var soundName:String?//再生するアプリケーションのバンドル内のリソース名またはUILocalNotificationDefaultSoundName" –

関連する問題