没有收到本地通知

时间:2017-07-05 12:54:32

标签: swift3

我在AppDelegate

中完成了这项工作
func sendNotification(inSecond: TimeInterval, completion: @escaping (_ Success: Bool) -> ()){
    let notify = UNMutableNotificationContent()
    notify.title = "Break Oil"
    notify.subtitle = "Please renew your Break Oil"
    notify.sound = UNNotificationSound(named: "carsHrn.mp3")
    let trigger = UNTimeIntervalNotificationTrigger(timeInterval: inSecond, repeats: false)
    let request = UNNotificationRequest(identifier: "myNotification", content: notify, trigger: trigger)
    UNUserNotificationCenter.current().add(request, withCompletionHandler: { error in
        if error != nil{
            print(error!)
            completion(false)
        }
        else    {
            completion(true)
        }
    })

}

在我的ViewController类中,我已经使用此方法调用按钮操作

=(SUM(SUMIFS(D2:D11,A2:A11,"South", C2:C11,"Meat"),SUMIFS(D2:D11,A2:A11,"South", C2:C11,"Beverages")))

1 个答案:

答案 0 :(得分:1)

使用固定 扩展名DignoSViewController:UNUserNotificationCenterDelegate {

func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
    completionHandler([.alert])
}

}

相关问题