Sibbo custom events
The CMP launches a custom event to detect the following:
The CMP has been closed ('sibbo-close' event)
- @objc func close(_ sender: Any) {
- webView.evaluateJavaScript("SibboCMP.close()", completionHandler: nil)
- }
The closing of the consent tool is handled through a message that is sent from the webpage's
JavaScript. When this message is received, it calls the consentToolHasClosed() function.
- let action = JSON(body)["action"]
- if action == "close" {
- consentToolHasClosed()
- }
Finally, the consentToolHasClosed() function closes the view. This is done by calling the
dismiss(animated:completion:) function on the viewController.
swift
- func consentToolHasClosed() {
- dismiss(animated: true, completion: nil)
- }
In summary, the process of closing the view starts when the CMP is closed. This
triggers a call to a JavaScript function which sends a message through the webView.
When this message is received, it calls a function which closes the view.