I want to create a Notification Content Extension to take advantage of the new iOS 10 rich notifications. However, in the main application we do not make use of interface builder. How can I create a content extension that does not utilize a story board?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Create the Notification Content extension target as you normally would.
Remove the storyboard file from the project
Remove the NSExtensionMainStoryboard entry from the extension's Info.plist.
Add a new entry of NSExtensionPrincipalClass to the Info.plist under NSExtension. The value should be the namespace of your extension and the class of the main ViewController. For example, if your extension is called Pretty Notification and the class is PrettyNotificationViewController, you would enter Pretty_Notification.PrettyNotificationViewController.
Note: Your principal class must conform to UNNotificationContentExtension