How do I create a UNNotificationContentExtension without a Storyboard?

Adding content extension to my app's notification handling. I have it working, but I want to do it without a storyboard directly specified. The reason is that I want the ability to pass this on to a 3rd party framework (that I'm developing) to handle presenting the notification and managing the user response.


I tried removing the NSExtensionMainStoryboard entry and adding an NSExtensionPrincipalClass entry so I can load the view in code. However, my class isn't being instantiated. Here's the class definition:


class NotificationViewController: NSObject, UNNotificationContentExtension {
  override init() {
      super.init()
      print("extension instantiated")
  }

  func didReceive(_ notification: UNNotification) {
      print("notification received")
  }
}


Here's my NSExtension entry:


<dict>
  <key>NSExtensionAttributes</key>
  <dict>
    <key>UNNotificationExtensionDefaultContentHidden</key>
    <true/>
    <key>UNNotificationExtensionCategory</key>
    <string>Messaging</string>
    <key>UNNotificationExtensionInitialContentSizeRatio</key>
    <real>1</real>
  </dict>
  <key>NSExtensionPrincipalClass</key>
  <string>NotificationViewController</string>
  <key>NSExtensionPointIdentifier</key>
  <string>com.apple.usernotifications.content-extension</string>
</dict>


Has anyone done this for content extensions?

How do I create a UNNotificationContentExtension without a Storyboard?
 
 
Q