Fortunately, it is YES. Vist this link : How do I add a file to the main bundle's /Library/Sounds directory?
Here I have copied the system ringtone to Library/Sounds, likewise you have to copy from your data directory by putting the path as source path and destination as given below, by creating a directory with Sounds name.
// get the list of system sounds, there are other sounds in folders beside /New
let soundPath = "/System/Library/Audio/UISounds/New"
var arrayOFSoundNames = [String] ()
// MARK: - scene setup
func doAnyAdditionalSetup()
{
arrayOFSoundNames = getSoundList()
}
// MARK: - File manager methods
func getSoundList() -> [String] {
var result:[String] = []
let fileManager = NSFileManager.defaultManager()
let enumerator:NSDirectoryEnumerator =
fileManager.enumeratorAtPath(soundPath)!
for url in enumerator.allObjects {
let string = url as! String
let newString = string.stringByReplacingOccurrencesOfString(".caf", withString: "", options: NSStringCompareOptions.LiteralSearch, range: nil)
result.append(newString)
}
return result
}
// copy sound file to /Library/Sounds directory, it will be auto detect and played when a push notification arrive
class func copyFileToDirectory(fromPath:String, fileName:String) {
let fileManager = NSFileManager.defaultManager()
do {
let libraryDir = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.LibraryDirectory, NSSearchPathDomainMask.UserDomainMask, true)
let directoryPath = "\(libraryDir.first!)/Sounds"
try fileManager.createDirectoryAtPath(directoryPath, withIntermediateDirectories: true, attributes: nil)
let systemSoundPath = "\(fromPath)/\(fileName)"
let notificationSoundPath = "\(directoryPath)/notification.caf"
let fileExist = fileManager.fileExistsAtPath(notificationSoundPath)
if (fileExist) {
try fileManager.removeItemAtPath(notificationSoundPath)
}
try fileManager.copyItemAtPath(systemSoundPath, toPath: notificationSoundPath)
}
catch let error as NSError {
print("Error: \(error)")
}
}
// MARK: - tableview methods
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return arrayOFSoundNames.count
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
copyFileToDirectory(fromPath:soundPath, fileName:arrayOFSoundNames[indexPath.row])
}
You will get your answer, also check the apple document