How to find out if background action for a local notification was answered on iPhone or Apple Watch

93 Views Asked by At

Is there a way to find out if a local notification with background actions was responded to on the iPhone vs. on the Apple Watch. In both cases they are handled by the iPhone App userNotificationCenter(_:didReceive:withCompletionHandler:). Is this information somehwere accesible, maybe in the UNNotificationResponse?

1

There are 1 best solutions below

1
On

AFAIK the UserNotification framework doesn't have such method at the moment.

However, you could check whether the notification handling code is run in your main app or on your Watch Extension and use that information to take appropriate actions.

See this question on how to determine where your code is running.