Skip to content

Instantly share code, notes, and snippets.

@KentarouKanno
Created October 8, 2016 00:32
Show Gist options
  • Save KentarouKanno/c9f589c92c22b527428d0cbf0e9515cb to your computer and use it in GitHub Desktop.
Save KentarouKanno/c9f589c92c22b527428d0cbf0e9515cb to your computer and use it in GitHub Desktop.
NSUserNotification

NSUserNotification

Apple NSUserNotification

☆ 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)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment