I have an AppleWatch app that receives remote notifications. I want the user to be able to open the watch app from a custom notification action and view the item the notification is about. But debugging my Notification scene in my watch app never actually delivers the notification content to my root WKInterfaceController
, and just keeps spitting out errors like this in the console:
[default] -[SPRemoteInterface _interfaceControllerID:]:2402: ComF: interfaceControllerID for controller:(null) not found (clientIdentifier=(null))
[default] -[SPRemoteInterface _interfaceControllerClientIDForControllerID:]:2414: ComF: clientIdentifier for interfaceControllerID:(null) not found
[default] -[SPRemoteInterface didFinishHandlingActivity:]:2292: ComF:<-Plugin controller ID (null) (object:(null)) has no client identifier
Whether I use a custom notification UI or not (WKUserNotificationInterfaceTypeCustom
vs Default
), tapping a button or the notification itself doesn't pass any information through to my root interface controller.
I've implemented handleActionWithIdentifier:forNotification:
in my root WKInterfaceController
, but it never gets called. My extension delegate does not implement handleActionWithIdentifier:forNotification:withResponseInfo:
.
I've tried setting my WKExtensionDelegate
implementation to the delegate of the UNUserNotificationCenter
and implementing userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:
, and that gets called, but I can't seem to get to my root interface controller to have it handle the content. I get the errors above.
Notably, things seem to work once in a while when I make code changes and build and run. But if I rerun the same code it never works - I always get the error messages above.
How is this supposed to work? It must be possible - every messenger app in the world with a watch app does this. But I can't find a tutorial or code example anywhere about how to get notification payload reliably into a WKInterfaceController
subclass.
Update: Interestingly, if I set up my extension delegate as the UNUserNotificationCenter
's delegate and handle userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:
, it works sometimes, but other times I get the error messages listed above, and when I try to get [WKExtension sharedExtension].rootInterfaceController
, it's nil
.