Skip to content

Commit

Permalink
Merge pull request #51 from SourcePointUSA/develop
Browse files Browse the repository at this point in the history
Release 2.3.0
  • Loading branch information
Nevazhnovu authored Mar 25, 2024
2 parents 4051f1d + 72e077b commit e067d7a
Show file tree
Hide file tree
Showing 42 changed files with 1,087 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import UIKit
config = Config(
gdprPmId: nil,
ccpaPmId: nil,
usnatPmId: nil,
transitionCCPAAuth: nil,
supportLegacyUSPString: nil,
vendors: [],
categories: [],
legIntCategories: []
Expand All @@ -22,6 +25,7 @@ import UIKit
case GDPR = 0
case IOS14 = 1
case CCPA = 2
case USNAT = 3
}

enum VendorStatus: String {
Expand All @@ -41,7 +45,8 @@ import UIKit
}

struct Config {
var gdprPmId, ccpaPmId: String?
var gdprPmId, ccpaPmId, usnatPmId: String?
var transitionCCPAAuth, supportLegacyUSPString: Bool?
var vendors: [String] = []
var categories: [String] = []
var legIntCategories: [String] = []
Expand All @@ -52,6 +57,7 @@ import UIKit
var config: Config
lazy var gdprTargetingParams: SPTargetingParams = [:]
lazy var ccpaTargetingParams: SPTargetingParams = [:]
lazy var usnatTargetingParams: SPTargetingParams = [:]

var consentManager: SPSDK?
let logger: OSLogger = OSLogger.standard
Expand All @@ -76,23 +82,38 @@ import UIKit
case .IOS14: break

case .CCPA: ccpaTargetingParams[key]=value

case .USNAT: usnatTargetingParams[key]=value

case .none:
print("Incorrect campaignType on addTargetingParam")
}
}

@objc public func setTransitionCCPAAuth(value: Bool){
print("transitionCCPAAuth set to "+String(value))
config.transitionCCPAAuth = value
}

@objc public func setSupportLegacyUSPString(value: Bool){
print("supportLegacyUSPString set to "+String(value))
config.supportLegacyUSPString = value
}

@objc public func configLib(
accountId: Int,
propertyId: Int,
propertyName: String,
gdpr: Bool,
ccpa: Bool,
usnat: Bool,
language: SPMessageLanguage,
gdprPmId: String,
ccpaPmId: String) {
ccpaPmId: String,
usnatPmId: String) {
self.config.gdprPmId = gdprPmId
self.config.ccpaPmId = ccpaPmId
self.config.usnatPmId = usnatPmId
guard let propName = try? SPPropertyName(propertyName) else {
self.runCallback(callback: self.callbackOnErrorCallback, arg: "`propertyName` invalid!")
return
Expand All @@ -102,8 +123,9 @@ import UIKit
propertyId: propertyId,
propertyName: propName,
campaigns: SPCampaigns(
gdpr: gdpr ? SPCampaign(targetingParams: gdprTargetingParams, groupPmId: gdprPmId) : nil,
ccpa: ccpa ? SPCampaign(targetingParams: ccpaTargetingParams, groupPmId: ccpaPmId) : nil,
gdpr: gdpr ? SPCampaign(targetingParams: gdprTargetingParams) : nil,
ccpa: ccpa ? SPCampaign(targetingParams: ccpaTargetingParams) : nil,
usnat: usnat ? SPCampaign(targetingParams: usnatTargetingParams, transitionCCPAAuth: config.transitionCCPAAuth, supportLegacyUSPString: config.supportLegacyUSPString) : nil,
ios14: SPCampaign()
),
language: language,
Expand Down Expand Up @@ -173,6 +195,16 @@ import UIKit
self.runCallback(callback: self.callbackOnErrorCallback, arg: "Tried to load CCPA pm without ccpa pm id")
}
}

@objc public func onUSNATPrivacyManagerTap() {
if config.usnatPmId != nil {
(consentManager != nil) ?
consentManager?.loadUSNatPrivacyManager(withId: config.usnatPmId!) :
self.runCallback(callback: self.callbackOnErrorCallback, arg: "Library was not initialized correctly!")
} else {
self.runCallback(callback: self.callbackOnErrorCallback, arg: "Tried to load USNAT pm without usnat pm id")
}
}

@objc public func customConsentToGDPR() {
if let consentManager = consentManager {
Expand Down
20 changes: 18 additions & 2 deletions Assets/ConsentManagementProvider/Plugins/iOS/Source/Unity.mm
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,19 @@ void _addTargetingParamForCampaignType(int campaignType, char* key, char* value)
[swiftBridge addTargetingParamWithCampaignType:campaignType key:[NSString stringWithFormat:@"%s", key] value:[NSString stringWithFormat:@"%s", value]];
}

void _configLib(int accountId, int propertyId, char* propertyName, bool gdpr, bool ccpa, SPMessageLanguage language, char* gdprPmId, char* ccpaPmId)
void _setTransitionCCPAAuth(bool value)
{
[swiftBridge configLibWithAccountId:accountId propertyId:propertyId propertyName:[NSString stringWithFormat:@"%s", propertyName] gdpr:gdpr ccpa:ccpa language:language gdprPmId:[NSString stringWithFormat:@"%s", gdprPmId] ccpaPmId:[NSString stringWithFormat:@"%s", ccpaPmId]];
[swiftBridge setTransitionCCPAAuthWithValue:value];
}

void _setSupportLegacyUSPString(bool value)
{
[swiftBridge setSupportLegacyUSPStringWithValue:value];
}

void _configLib(int accountId, int propertyId, char* propertyName, bool gdpr, bool ccpa, bool usnat, SPMessageLanguage language, char* gdprPmId, char* ccpaPmId, char* usnatPmId)
{
[swiftBridge configLibWithAccountId:accountId propertyId:propertyId propertyName:[NSString stringWithFormat:@"%s", propertyName] gdpr:gdpr ccpa:ccpa usnat:usnat language:language gdprPmId:[NSString stringWithFormat:@"%s", gdprPmId] ccpaPmId:[NSString stringWithFormat:@"%s", ccpaPmId] usnatPmId:[NSString stringWithFormat:@"%s", usnatPmId]];
}

void _loadMessage(char * authId)
Expand All @@ -91,6 +101,12 @@ void _loadCCPAPrivacyManager()
[swiftBridge onCCPAPrivacyManagerTap];
}

void _loadUSNATPrivacyManager()
{
[swiftBridge onUSNATPrivacyManagerTap];
}


void _cleanConsent()
{
[swiftBridge onClearConsentTap];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace ConsentMessagePlugin.Android
{
internal static class CONFIG_OPTION_FULL_KEY
{
internal const string
TRANSITION_CCPA_AUTH = "TRANSITION_CCPA_AUTH",
SUPPORT_LEGACY_USPSTRING = "SUPPORT_LEGACY_USPSTRING";
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public enum CAMPAIGN_TYPE
GDPR = 0,
IOS14 = 1, //exist ios only
CCPA = 2,
// UNKNOWN = 3 //exist ios only
USNAT = 3
}
}
37 changes: 27 additions & 10 deletions Assets/ConsentManagementProvider/Scripts/facade/CMP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,36 @@ public static class CMP

public static bool useGDPR = false;
public static bool useCCPA = false;
public static bool useUSNAT = false;

public static void Initialize(
List<SpCampaign> spCampaigns,
int accountId,
int propertyId,
string propertyName,
bool gdpr,
bool ccpa,
string propertyName,
MESSAGE_LANGUAGE language,
string gdprPmId,
string ccpaPmId,
string usnatPmId,
CAMPAIGN_ENV campaignsEnvironment,
long messageTimeoutInSeconds = 3)
long messageTimeoutInSeconds = 3,
bool? transitionCCPAAuth = null,
bool? supportLegacyUSPString = null)
{
if(!IsSpCampaignsValid(spCampaigns))
{
return;
}
useGDPR = gdpr;
useCCPA = ccpa;

foreach (SpCampaign sp in spCampaigns)
{
switch (sp.CampaignType)
{
case CAMPAIGN_TYPE.GDPR: useGDPR = true; break;
case CAMPAIGN_TYPE.CCPA: useCCPA = true; break;
case CAMPAIGN_TYPE.USNAT: useUSNAT = true; break;
}
}
#if UNITY_ANDROID
CreateBroadcastExecutorGO();
//excluding ios14 campaign if any
Expand All @@ -52,22 +62,28 @@ public static void Initialize(
propertyName: propertyName,
language: language,
campaignsEnvironment: campaignsEnvironment,
messageTimeoutMilliSeconds: messageTimeoutInSeconds * 1000);
messageTimeoutMilliSeconds: messageTimeoutInSeconds * 1000,
transitionCCPAAuth: transitionCCPAAuth,
supportLegacyUSPString: supportLegacyUSPString);

#elif UNITY_IOS && !UNITY_EDITOR_OSX
CreateBroadcastExecutorGO();
ConsentWrapperIOS.Instance.InitializeLib(
accountId,
propertyId,
propertyName,
gdpr,
ccpa,
useGDPR,
useCCPA,
useUSNAT,
language,
gdprPmId,
ccpaPmId,
usnatPmId,
spCampaigns,
campaignsEnvironment,
messageTimeoutInSeconds);
messageTimeoutInSeconds,
transitionCCPAAuth,
supportLegacyUSPString);
#endif
}

Expand Down Expand Up @@ -121,6 +137,7 @@ public static void LoadPrivacyManager(CAMPAIGN_TYPE campaignType, string pmId, P
switch (campaignType){
case CAMPAIGN_TYPE.GDPR: ConsentWrapperIOS.Instance.LoadGDPRPrivacyManager(); break;
case CAMPAIGN_TYPE.CCPA: ConsentWrapperIOS.Instance.LoadCCPAPrivacyManager(); break;
case CAMPAIGN_TYPE.USNAT: ConsentWrapperIOS.Instance.LoadUSNATPrivacyManager(); break;
}
#endif
}
Expand Down
Loading

0 comments on commit e067d7a

Please sign in to comment.