Как я могу добавить тип тревоги и звук в быстрой - PullRequest
0 голосов
/ 16 февраля 2020

Я хочу добавить будильник, и я хочу добавить собственный звук и добавить тип будильника к аудио. Я пытался, но не получил ответа. Кто-нибудь может мне помочь, пожалуйста?

func createReminder() {
    let calander = Calendar.current
    let warmane = calander.date(byAdding: .minute, value: 1, to: Date())

    let reminder = EKReminder(eventStore: self.eventStore)
    reminder.title = "Go to the store and buy milk"
    reminder.calendar = eventStore.defaultCalendarForNewReminders()

    let date = warmane
    let alarm = EKAlarm(absoluteDate: date!)

    reminder.addAlarm(alarm)

    do {
        try eventStore.save(reminder,
            commit: true)

    } catch let error {
            print("Reminder failed with error \(error.localizedDescription)")
    }
}

1 Ответ

0 голосов
/ 16 февраля 2020
Try this 
let content = UNMutableNotificationContent()
    content.title = "Notification Tutorial"
    content.subtitle = "from ioscreator.com"
    content.body = " Notification triggered"
    //Default sound
    content.sound = UNNotificationSound.default
    //Play custom sound
    content.sound = UNNotificationSound.init(named:UNNotificationSoundName(rawValue: "123.mp3"))

------
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...