TheHorbach TheHorbach - 1 year ago 83
iOS Question

Can you use 3D Touch on widgets?

I am thinking about creating an iOS app that will have a notifications center extension. However I need my app to use 3D Touch on the extension within the Notification Center, is it possible?

Answer Source

To my knowledge, you cannot. From apple documentation, it appears the feature is only available in app and on the homescreen:

A user can now press your Home screen icon to immediately access functionality provided by your app. Within your app, a user can now press views to see previews of additional content and gain accelerated access to features.

For experimentation sake, try enrolling the view controller with touch ID using

override func viewDidLoad() {
     if( traitCollection.forceTouchCapability == .Available){        
           registerForPreviewingWithDelegate(self, sourceView: view)         

And you will get an error as TodayViewController will not conform to these protocols. That might be something to add in the future, but it does not look currently supported, most likely because "Today Widgets" are to be as simple as possible.

EDIT: As of iOS 10, this is not only possible but preferred functionality in widgets. Standard documentation will tell you how to implement.