Я настроил уведомление с пользовательским звуком, например:
var soundNames = ["Default", "Alert1", "Alert2", "Alert3", "Alert4", "Alert5", "Alert6", "Alert7", "Alert8", "Alert9", "Alert10"]
func addNotification(title: String, timeInt: TimeInterval, image: Data?, soundName: String?) {
let content = UNMutableNotificationContent()
content.title = title
content.sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: "\(soundName!).caf"))
var trigger: UNTimeIntervalNotificationTrigger
trigger = UNTimeIntervalNotificationTrigger(timeInterval: timeInt, repeats: true)
// choose a random identifier
let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger)
// add our notification request
UNUserNotificationCenter.current().add(request)
saveConceptCard(id: request.identifier, title: title, image: image)
}
Теперь я хочу получить имя пользовательского звука, который я использовал, когда я извлекаю конкретный запрос уведомления из его идентификатора.
var notification: UNNotificationRequest
Я пытаюсь получить имя звука так:
let sound = notification.content.sound!.debugDescription
Но это возвращает:
<UNNotificationSound: 0x2822419d0>
Есть ли способ получить имя файла из этого кода?
userInfo
. - person vadian   schedule 28.10.2020