Local Notifications not working on independent WatchOS App

444 views Asked by At

I cannot figure out, how I can schedule local notification in independent WatchOS APP

In my extension delegate I try to setup it

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])  
    }  

And this is schedule code:

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)  
                            }  

Source: https://forums.developer.apple.com/message/414391#414391

1

There are 1 answers

0
Tomas Radvansky On

So, issue is with number of notification I can send.

I am building event based app, where I know what event happens every day.

Therefore When I tried to schedule event for each day (365days = 365 notitifications) I've reached 64notification limit.

And as we are now in april, my notification could not be trigger...as its far behind 64 days...