[英]Local Notifications not working on independent WatchOS App
我不知道如何在獨立的 WatchOS APP 中安排本地通知
在我的擴展委托中,我嘗試設置它
let center = UNUserNotificationCenter.current()
func applicationDidFinishLaunching() {
center.delegate = self
let options: UNAuthorizationOptions = [.alert, .badge, .sound]
center.requestAuthorization(options: options) { (granted, error) in
if granted {
WKExtension.shared().registerForRemoteNotifications()
}
}
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
completionHandler()
}
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.alert, .sound,.badge])
}
這是時間表代碼:
let content = UNMutableNotificationContent()
content.title = "Meniny Oslavuje"
content.body = nameEntry.name
var dateComponents = DateComponents()
dateComponents.month = dateNameEntry.month
dateComponents.day = dateNameEntry.day
dateComponents.hour = self.reminderTimeHour
dateComponents.minute = self.reminderTimeMinute
let trigger = UNCalendarNotificationTrigger(dateMatching:dateComponents , repeats: true)
let request = UNNotificationRequest(identifier: uuid.uuidString, content: content, trigger: trigger)
center.removeAllPendingNotificationRequests()
center.add(request) { (err) in
print(err)
}
來源: https://forums.developer.apple.com/message/414391#414391
所以,問題在於我可以發送的通知數量。
我正在構建基於事件的應用程序,我知道每天都會發生什么事件。
因此,當我嘗試為每天安排事件(365 天 = 365 個通知)時,我已經達到了 64 個通知的限制。
由於我們現在是四月,我的通知無法觸發……因為它遠遠落后於 64 天……
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.