iOS: Events

iOS: Events

Sibbo custom events

The CMP launches a custom event to detect the following:
  1. The CMP has been closed ('sibbo-close' event)

swift

  1. @objc func close(_ sender: Any) {
  2.     webView.evaluateJavaScript("SibboCMP.close()", completionHandler: nil)
  3. }

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.


swift

  1. let action = JSON(body)["action"]

  2. if action == "close" {
  3.     consentToolHasClosed()
  4. }

Finally, the consentToolHasClosed() function closes the view. This is done by calling the dismiss(animated:completion:) function on the viewController.

swift
  1. func consentToolHasClosed() {
  2.     dismiss(animated: true, completion: nil)
  3. }

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.