-2

I am developing an app that wakes you up after a certain amount of time, and when it is time to wake up I would like to have the local notification play the Marimba ringtone, how would I do this in Swift code? (I don't want to have to download the actual sound file for the ringtone)

// create a new alarm/notification
    let notification: UILocalNotification = UILocalNotification()
    notification.category = "wakeUpAlarms"
    notification.alertAction = "turn off the alarm"
    notification.alertBody = "Time to wake up!"
    notification.fireDate = NSDate(timeIntervalSinceNow: 10)

// instead of UILocalNotificationDefaultSoundName, I want the sound name to 
// be one of the iPhone ringtones that are located in the "Sounds" page of 
// such as Marimba the settings app
    notification.soundName = UILocalNotificationDefaultSoundName

    UIApplication.sharedApplication().scheduleLocalNotification(notification)

1 Answers1

0

You can only use sounds that are a part of the main bundle, which means you have to keep the sound files in the build of the app when submitted to the app store.

  1. UILocalNotification Class Reference: https://developer.apple.com/library/ios/documentation/iPhone/Reference/UILocalNotification_Class/index.html
  2. Local and Push Notification Programming Guide https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/IPhoneOSClientImp.html#//apple_ref/doc/uid/TP40008194-CH103
Siba Prasad Hota
  • 4,779
  • 1
  • 20
  • 40