0

My scenario:

I have an app that sends push notifications about articles on a daily basis. The iOS app has three UNNotificationActions attached to the notification -- one to read the article, one to share the article, and one to save the article for later. The read/share article actions are foreground actions, while the save article action happens in the background.

I also have a watchOS version of the app that displays a few top stories, with an option to save for later in the iOS app.

My issue is this: I only want the watch to display the save article background action. The other two UNNotificationActions don't apply to the watchOS app (and wouldn't make sense). Is there a way to hide those two action on the watch? I figured it would be easy, but I don't see any easy way to do this, so I feel like I must be missing something obvious...

For example, the News app has three notification actions on iOS, two foreground actions. On watchOS, only one background action shows up.

user1941966
  • 449
  • 5
  • 18

2 Answers2

0

Don't know if you've managed to solve this on your own, but since watchOS 5.0 you have access to WKUserNotificationInterfaceController's

// notificationActions can only be changed once didReceiveNotification: has been called @available(watchOS 5.0, *) open var notificationActions: [UNNotificationAction]

As the comment states you can remove your iOS specific actions inside your func didReceive(_ notification: UNNotification implementation.

jahsiotr
  • 141
  • 1
  • 11
-1

My solution next:

- (void)didReceiveNotification:(UNNotification *)notification {
  [super didReceiveNotification:notification];
  self.notificationActions = nil;
}