iosswiftwatchkitwatchoswatchos-4

Swift: cancel local notification (scheduled on handset) from watch


I'm working on a project in which I schedule local notifications from the handset. The bulk of the app is on the watch so I'm trying to make it possible for the user to remove pending notifications from the watch. It seems that local notifications scheduled from the handset can't be cancelled from the watch. Am I missing something? Thanks


Solution

  • The documentation is not entirely clear on this matter, but it can't hurt to try calling removePendingNotificationRequests on the watch to see if a phone-scheduled local notification gets removed. Failing that, you could always use WCSession to send a message to the phone, passing the notification identifier, that calls on the phone to wake up and remove the scheduled notification.