Matthew Brown
Matthew Brown

Reputation: 1052

Determine if UNNotificationResponse is from watch extension or iOS app

When handling a location notification in the UNUserNotificationCenterDelegate using func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) is it possible to determine if the user interacted with the notification using the watch app or on the iOS device?

Upvotes: 2

Views: 557

Answers (1)

Jawad Ali
Jawad Ali

Reputation: 14397

By default, if a notification arrives for an iOS app with a companion WatchKit app, the system will first decide whether to display the alert on the iPhone or the Apple Watch. In the event that the notification is delivered to the Apple Watch a “short-look” notification scene will first be displayed. This consists of the app icon, the title from the notification and the name of the WatchKit app

check out this tutorial

You have to implement UNUserNotificationCenterDelegate for both iPhone and Watchkit as well and take action accordingly.

Upvotes: 1

Related Questions