小编ABD*_*RLY的帖子

如何实现多个本地通知而不是swift 3的单个通知

我使用单一通知,这是我的代码:这是用于注册本地通知>>>

    func registerLocal() {
    let center = UNUserNotificationCenter.current()

    center.requestAuthorization(options: [.alert, .badge, .sound]) { (granted, error) in
        if granted {
            print("Yay!")
        } else {
            print("D'oh")
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这个函数来安排本地通知>>>

func scheduleLocal() {
    registerCategories()

    let center = UNUserNotificationCenter.current()

    // not required, but useful for testing!
    center.removeAllPendingNotificationRequests()

    let content = UNMutableNotificationContent()
    content.title = "good morning"
    content.body = "ttt123"
    content.categoryIdentifier = "alarm"
    content.userInfo = ["customData": "fizzbuzz"]
    content.sound = UNNotificationSound.default()

    var dateComponents = DateComponents()
    dateComponents.hour = 23
    dateComponents.minute = 18
    let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, …
Run Code Online (Sandbox Code Playgroud)

notifications localnotification swift3 ios10

7
推荐指数
2
解决办法
5120
查看次数

标签 统计

ios10 ×1

localnotification ×1

notifications ×1

swift3 ×1