"Could not connect to Notification Center to set hasContent"

Originator:robotspacer
Number:rdar://19685759 Date Originated:02-Feb-2015 01:16 PM
Status:Open Resolved:
Product:OS X SDK Product Version:OS X 10.10.2 (14C109), Xcode 6.1.1 (6A2008a)
Classification:Other Bug Reproducible:Always
 
Summary:
When a Today widget has no content to display, the widget or its parent app should be able to call [[NCWidgetController widgetController] setHasContent:forWidgetWithBundleIdentifier:]. When set to NO, the widget should hide, then when the parent app sets it to YES, the widget should appear again. This works great on iOS and given the limited space in Notification Center, many users appreciate the feature. On OS X I have never been able to get the feature to work. Any time I try to call this method in a sandboxed app, I get the error "Could not connect to Notification Center to set hasContent".

Steps to Reproduce:
1. Build and install the attached sample app.
2. Run the app.
3. Install its Today widget.
4. Quit and relaunch the app to give it one more chance. As soon as the app launches, it attempts to hide the widget with [[NCWidgetController widgetController] setHasContent:YES forWidgetWithBundleIdentifier:@"com.junecloud.HasContent.HasContentToday"];

Expected Results:
The Today widget should hide.

Actual Results:
The app fails to hide the widget. Some errors are logged:
2/2/15 1:07:17.001 PM HasContent[50372]: Could not connect to Notification Center to set hasContent
2/2/15 1:07:17.008 PM sandboxd[333]: ([50372]) HasContent(50372) deny mach-lookup com.apple.notificationcenterui.widgetcontent

The full sandboxd report is attached.

Version:
OS X 10.10.2 (14C109), Xcode 6.1.1 (6A2008a)

Notes:
The only workaround I've been able to find is to disable sandboxing. With an App Store app this is not even an option.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!