Apple Watch notification issue: WatchKit error - u

2019-01-20 18:48发布

问题:

I am getting the following error when I am trying to push my notification controller dynamically.

2015-03-30 13:18:53.324 MyApp WatchKit Extension[79826:1951724] Took too long to show custom notification. Falling back to static. 2015-03-30 13:26:13.831 MyApp WatchKit Extension[79826:1957863] WatchKit error - unable to find interface controller class '_TtC26MyApp_WatchKit_Extension19InterfaceController' to instantiate

I heard there might be a glitch, but as far as I am concern it is only occurring on the Xcode beta and not Xcode 6.2. I change the module regarding the notification storyboard to watch kit extension.

Any help or suggestions is appreciated.

Edit : I am using the auto generated payload that apple provide when dealing with notifications for iWatch.

回答1:

Two things to recheck,

  • When you have created a new subclass of WKUserNotificationInterfaceController, Have you selected Watchkit extension as a target instead of iOS app target? You can verify this by Select Project > Select Watchkit Extension Target > Build Phases > Compile Sources. Here you should see NotificationInterface.m file created earlier. If you can't see then you have selected wrong target when creating a file. Then solution is you can create a new class with correct target selected.
  • In Storyboard, make sure custom class name is correctly added. Also in Payload file, category name should match with category set to storyboard scene just to avoid future errors.