Avinash Mulewa Avinash Mulewa - 4 months ago 26x
iOS Question

UILocalNotification always give default sound

I want to add custom sound in interactive localnotification. I have write this code in appdelegate

func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) {
func scheduleNotification() {

// Schedule the notification ********************************************
if UIApplication.sharedApplication().scheduledLocalNotifications!.count == 0 {

let notification = UILocalNotification()
notification.alertBody = "Hey! Update your counters ;)"
// let URLToMyFile = documentsURL.URLByAppendingPathComponent("notes_of_the_optimistic.caf")

let ring: String = NSBundle.mainBundle().pathForResource("notes_of_the_optimistic", ofType: "caf")!
notification.soundName = ring
notification.fireDate = NSDate()
notification.category = categoryID
notification.repeatInterval = NSCalendarUnit.Minute


I have added notes_of_the_optimistic.caf file in my project but my nitification always give the default sound. The length of the sound file is 29sec. Can any budy tell me what I am missing.


You don't need get a full path of your custom sound, you need only sound name with file format like notification.soundName = "notes_of_the_optimistic.caf"