Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DIA-4058 refactor ios interface #63

Conversation

Nevazhnovu
Copy link
Collaborator

No description provided.

@Nevazhnovu Nevazhnovu requested a review from andresilveirah July 3, 2024 13:26
switch CAMPAIGN_TYPE(rawValue: campaignType) {
case .GDPR: consentManager!.loadGDPRPrivacyManager(withId: pmId, tab: tab)
case .CCPA: consentManager!.loadCCPAPrivacyManager(withId: pmId, tab: tab)
case .USNAT: consentManager!.loadUSNatPrivacyManager(withId: pmId, tab: tab)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

were you can use:

guard let consentManager = consentManager else {
  self.callbacks.RunCallback(callbackType: .OnErrorCallback, arg: "Library was not initialized correctly!")
  return
}
// from here on we don't need to force unwrap consentManager(!) since the guard let took care of it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, could we think about a way of making consentManager not optional? This way we don't have to keep checking if it's nil on every method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andresilveirah having guard is a good idea, thanks!
As for making consentManager not optional – for now I cannot imagine how to do it, because to make it not optional we have to initialize it with values, and we cannot declare and initialize them in one place since we wait for the initialization-related data to come from Unity side of a bridge.
I have to think a little bit about it.

callback: @escaping Callbacks.СallbackCharMessage = printChar,
callbackType: Callbacks.CallbackType = .NotSet) {
self.callback = callback
self.callbackType = callbackType
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like what you did with the Callbacks class 👏 .

// foreach (var kvp in TCData)
// sb.AppendLine($" {kvp.Key}: {kvp.Value}");
foreach (var kvp in TCData)
sb.AppendLine($" {kvp.Key}: {kvp.Value.ToString()}");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to call Value.ToString()? Some values inside TCData may not be a string (sometimes they have booleans like 0 or 1).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andresilveirah .ToString() in c# can handle value types just right.
For example, it will convert a boolean value to string True or False and a 1 integer will become "1" string.
We can decide not to specify .ToString() here but it will be done anyway under the hood.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TCData.Value has an object type, which means it can be any value-type value that secures the usage of .ToString()

@Nevazhnovu Nevazhnovu merged commit aefd883 into DIA-4057-refactor-cmp-class-abstract Jul 4, 2024
@Nevazhnovu Nevazhnovu deleted the DIA-4058-refactor-ios-interface branch July 4, 2024 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants