didReceive in WKUserNotificationHostingController not called

I was following the SwiftUI tutorial series and finished with the watchOS app (https://developer.apple.com/tutorials/swiftui/creating-a-watchos-app). The problem I see now, is that the custom

NotificationView
provided in the
NotificationController.swift
source is never properly shown with the circle image, as illustrated in the tutorial step "Create a Custom Notification Interface" step 9 (=final step).


It seems, as if the data of the push notification is not used at all and therefore an empty

NotificationView
is instantiated. (=title is "Unknown Landmark", no image displayed).


Therefore I've added console logs to all the functions and have found that

didReceive
is never called.

    override func didReceive(_ notification: UNNotification)


There is an deprecated

didReceive
function which includes a completion handler, which is getting called and delivers notification data...

    override func didReceive(_ notification: UNNotification, withCompletion completionHandler: @escaping (WKUserNotificationInterfaceType) -> Void)


But as soon as I implement this method myself, the other functions which generate the

NotificationView
(body) or provide lifecycle information (
willActivate
,
didDeactivate
) are not called at anymore...


Is there anybody who has successfully implemented a custom watchOS notification view using SwiftUI?

I somehow doubt that the tutorial is properly working anywhere...

Hello, you are not alone, I am experiencing the same issue. I have not found a solution yet.


Overall the rest of tutorial worked for me, sometimes I needed to run the app in Simulator, like, for navigating between list and detail views on the watch app, the Canvas just gave me a white screen.
I found one typo in Step 6 of "Creating a watchOS App".
> Select the WatchLandmarkView.swift
Should be WatchLandmarkDetail.swift

I've got the same issue. It's an issue with the WatchOS 6.1 simulator. Try running your code against the WatchOS 6.0 simulator, didReceive on the NotificationController should run properly. When you run on 6.1, the didReceive function is never fired.

didReceive in WKUserNotificationHostingController not called
 
 
Q