Home > Net >  Didomi trying to add events with variables
Didomi trying to add events with variables

Time:02-11

I'm trying to add these values ​​according to what the user does but I can't figure out how to do it:

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

In this function I have a listener where I call the actions that the user does, the problem is that I don't know what function to put if the user has customized it and I don't know if the way I was putting it is right

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

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

And if the user performs another action without accepting:

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

I was following this documentation

CodePudding user response:

I was doing so bad, so there's the solution:

I upgraded the Didomi version too.

First I changed my enum to only String with the params I need

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

Then I added a Struct like this:

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

The next thing I did was declare a constant that is and a variable with the struct of DidomiUserData.

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

Finally only have to do an if-if-else.

  • Related