Group Group Group Group Group Group Group Group Group

08-user-notifications custom sound

#1

Have any of you used custom sound in local notifications ?

iv tried UNNotificationSound(named: “soundname.extension”) and converting the audio file like apple says https://developer.apple.com/reference/usernotifications/unnotificationsound but my notification always go´s bace to default

let newString = titleField.text!

   
let content = UNMutableNotificationContent()
content.title = "!Dont Forget!"
//content.subtitle = "Glad to help..."
content.body = newString
content.sound = UNNotificationSound(named:"push.m4a")

 // content.attachments = [attachment]
content.categoryIdentifier = newCuddlePixCategoryName

let calendar = Calendar(identifier: .gregorian)
let components = calendar.dateComponents(in: .current, from: date)
let newComponents = DateComponents(calendar: calendar, timeZone: .current, month: components.month, day: components.day, hour: components.hour, minute: components.minute)

let trigger = UNCalendarNotificationTrigger(dateMatching: newComponents, repeats: false)

let request = UNNotificationRequest(
  identifier: randomImageName, content: content, trigger: trigger)

UNUserNotificationCenter.current().add(request, withCompletionHandler:
  { (error) in
    if let error = error {
      print(error)
      completion(false)
    } else {
      completion(true)
    }