Didomi 尝试添加带有变量的事件

Didomi trying to add events with variables

我正在尝试根据用户的操作添加这些值,但我不知道该怎么做:

enum DidomiStatusType: String, Codable {
case custom = "custom"
case disableAll = "all-denied"
case enabledAll = "all-accepted"
case none = "no-gdpr" }

在这个函数中,我有一个侦听器,我在其中调用用户执行的操作,问题是如果用户自定义了它,我不知道要放置什么函数,我不知道方法是否正确我说得对

//If the user agreed all
let didomiEventListener = EventListener()

            didomiEventListener.onNoticeClickAgree = { _ in
            if self.type == .fakeSplash {
                DispatchQueue.main.async {
                    self.statusType = .enabledAll
                    self.delegate?.continueNavigation()
                }
            }
        }

并且如果用户在没有接受的情况下执行另一个操作:

didomiEventListener.onHideNotice = { _ in
            if self.type == .fakeSplash {
                DispatchQueue.main.async {
                    self.statusType = .none
                    self.statusType = .custom
                    self.statusType = .disableAll
                    self.delegate?.continueNavigation()
                }
            }
        }

我在关注这个documentation

我做得很糟糕,所以有解决方案:

我也升级了Didomi版本

首先,我将我的枚举更改为仅包含我需要的参数的字符串

enum DidomiUserType: String {
case custom = "custom"
case disableAll = "all-denied"
case enabledAll = "all-accepted"
case none = "no-gdpr" }

然后我添加了一个这样的结构:

struct DidomiUserData {
var vendorEnabled: Int
var vendorDisabled: Int
var purposeEnabled: Int
var purposeDisabled: Int
var isUserConsentStatusPartial: Bool
var type: DidomiUserType = .none }

接下来我做的是声明一个常量和一个具有 DidomiUserData 结构的变量。

let didomiUserStatusData = Didomi.shared.getUserStatus()
var didomiUserData = DidomiUserData(and the struct)

终于只需要做一个if-if-else.