☆ 5秒後にローカル通知を鳴らす
let content = UNMutableNotificationContent()
content.sound = UNNotificationSound(named: "sample.m4a")
content.badge = 10
content.title = "Introduction to Notifications"
content.body = "Let's talk about notifications!"
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false)
let requestIdentifier = "sampleRequest"
let request = UNNotificationRequest(identifier: requestIdentifier,
content: content,
trigger: trigger)
UNUserNotificationCenter.current().add(request) {
(error) in
// ...
print(error)
}