Interface NCWidgetProviding


  • public interface NCWidgetProviding
    'NCWidgetProviding' is an optional protocol for further customizing aspects of the provided content.
    • Method Detail

      • widgetActiveDisplayModeDidChangeWithMaximumSize

        default void widgetActiveDisplayModeDidChangeWithMaximumSize​(long activeDisplayMode,
                                                                     CGSize maxSize)
        If implemented, called when the active display mode changes. The widget may wish to change its preferredContentSize to better accommodate the new display mode.
      • widgetMarginInsetsForProposedMarginInsets

        default UIEdgeInsets widgetMarginInsetsForProposedMarginInsets​(UIEdgeInsets defaultMarginInsets)
        Widgets wishing to customize the default margin insets can return their preferred values. Widgets that choose not to implement this method will receive the default margin insets.
      • widgetPerformUpdateWithCompletionHandler

        default void widgetPerformUpdateWithCompletionHandler​(NCWidgetProviding.Block_widgetPerformUpdateWithCompletionHandler completionHandler)
        If implemented, the system will call at opportune times for the widget to update its state, both when the Notification Center is visible as well as in the background. An implementation is required to enable background updates. It's expected that the widget will perform the work to update asynchronously and off the main thread as much as possible. Widgets should call the argument block when the work is complete, passing the appropriate 'NCUpdateResult'. Widgets should NOT block returning from 'viewWillAppear:' on the results of this operation. Instead, widgets should load cached state in 'viewWillAppear:' in order to match the state of the view from the last 'viewWillDisappear:', then transition smoothly to the new data when it arrives.