我的本地通知不会触发

时间:2018-06-09 12:09:37

标签: ios iphone swift3 unusernotificationcenter

以下代码位于viewDidLoad函数

 let content = UNMutableNotificationContent()

        content.title = "Hello"
        content.body = "What up?"
        content.sound = UNNotificationSound.default()


        let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: 5, repeats: false)
        let request = UNNotificationRequest.init(identifier: "FiveSecond", content: content, trigger: trigger)


        let center = UNUserNotificationCenter.current()
        center.add(request) { (error) in
            print(error)
        }

这是我的AppDelegate函数

UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { (granted, error) in
            print("granted: (\(granted)")
        }    

为什么我的本地通知不会触发?

0 个答案:

没有答案