renderWidget
Use the renderWidget API to handle the display of widgets and data collection.
Method signature
The following code shows the method signature of the renderWidget API:
func renderWidget(_ input: SpacePullInfo, containerView: UIView, actionDelegate: WidgetActionDelegate, completion: ((Result
<SpaceContent?, ASAPBusinessWidgetError>) -> Void)? = nil)Request parameters
Name | Type | Description |
input | A | |
containerView | UIView | A pre-allocated |
actionDelegate | WidgetActionDelegate |
|
completion | (Result<SpaceContent, ASAPBusinessWidgetError>) -> Void | A closure that takes a The |
Response parameters
N/A
Exception
Error code | Error message |
1200 | A network error has occurred. |
1201 | A backend error has occurred. |
1202 | The user ID is empty. |
1203 | A response payload is unavailable. |
1400 | A widget render error has occurred. |
1500 |
|
Sample
Swift
var spacePullInfo = SpacePullInfo(spaceCode: "SPACE_CODE_001")
spacePullInfo.pullOffsetInfo = PullOffsetInfo(overallOffset: 0, pullSize: 10)
spacePullInfo.conditions = ["longitude": "23.1234", "latitude": "100.4567"]
// Create a UIView in advance and place it in a specified location on the page to reserve a space. Once the widget is created, the ASAPWidget component will render it onto the containerView as soon as possible
let containerView = UIView()
view.addSubview(containerView)
ComponentManager.ASAP.businessComponent.renderWidget(input:spacePullInfo containerView:containerView, actionDelegate: self, completion: { result in
switch result {
case .success(let success):
print(success)
case .failure(let failure):
print(failure)
}
})