About this widget
TheQueryRuleCustomData widget displays custom data from rules.
You may want to use this widget to display banners or recommendations returned by Rules, and that match search parameters.
Explore example code
Browse the QueryRuleCustomData example code on GitHub.
Examples
Instantiate aQueryRuleCustomDataConnector and launch an initial search on its Searcher triggering a Rule that returns custom data.
Swift
Parameters
The logic applied to the custom model.
The Controller interfacing with a concrete custom data view.
The Presenter defining how a model appears in the controller.
Low-level API
If you want to fully control theQueryRuleCustomData components and connect them manually, you can use the following components:
Searcher. TheSearcherthat handles your searches.QueryRuleCustomDataInteractor. The logic applied to the custom model.ItemController. The Controller interfacing with a concrete custom data view.
Swift
Customizing your view
If you want to use a third-party input view, or you want to introduce some custom behavior to the already provided UIKit component, you can create your own controller conforming to theItemController protocol.
Protocol
func setItem(_ item: String?):
Function called when new metadata are received.
Example
Suppose your custom JSON data contains a banner URL that can be decoded to the following structure:Swift
BannerViewController presenting the banner image as follows:
Swift
SwiftUI
To create a rule custom data view with SwiftUI start with implementation of theItemController containing your custom model as a published property.
Swift
QueryRuleCustomDataConnector or QueryRuleCustomDataInteractor and build a SwiftUI view presenting the fetched custom model.
Swift