Appodeal
This commit is contained in:
@@ -0,0 +1,450 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace ConsentManager.Platforms.iOS
|
||||
{
|
||||
#if UNITY_IPHONE
|
||||
internal delegate void ConsentInfoUpdatedCallback(IntPtr consent);
|
||||
internal delegate void ConsentInfoUpdatedFailedCallback(IntPtr error);
|
||||
|
||||
internal delegate void ConsentFormCallback();
|
||||
|
||||
internal delegate void ConsentFormCallbackError(IntPtr error);
|
||||
|
||||
internal delegate void ConsentFormCallbackClosed(IntPtr consent);
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBeMadeStatic.Global")]
|
||||
internal class ConsentManagerObjCBridge
|
||||
{
|
||||
private readonly IntPtr consentManager;
|
||||
|
||||
public ConsentManagerObjCBridge()
|
||||
{
|
||||
consentManager = GetConsentManager();
|
||||
}
|
||||
|
||||
public ConsentManagerObjCBridge(IntPtr intPtr)
|
||||
{
|
||||
consentManager = intPtr;
|
||||
}
|
||||
|
||||
public IntPtr getConsentManager()
|
||||
{
|
||||
return consentManager;
|
||||
}
|
||||
|
||||
public static void requestConsentInfoUpdate(string appodealAppKey,
|
||||
ConsentInfoUpdatedCallback onConsentInfoUpdated,
|
||||
ConsentInfoUpdatedFailedCallback onFailedToUpdateConsentInfo)
|
||||
{
|
||||
RequestConsentInfoUpdate(appodealAppKey, onConsentInfoUpdated, onFailedToUpdateConsentInfo);
|
||||
}
|
||||
|
||||
public static void disableAppTrackingTransparencyRequest()
|
||||
{
|
||||
DisableAppTrackingTransparencyRequest();
|
||||
}
|
||||
|
||||
public void setCustomVendor(IntPtr customVendor)
|
||||
{
|
||||
SetCustomVendor(customVendor);
|
||||
}
|
||||
|
||||
public IntPtr getCustomVendor(string bundle)
|
||||
{
|
||||
return GetCustomVendor(bundle);
|
||||
}
|
||||
|
||||
public string getStorage()
|
||||
{
|
||||
return GetStorage();
|
||||
}
|
||||
|
||||
public void setStorage(string storage)
|
||||
{
|
||||
SetStorage(storage);
|
||||
}
|
||||
|
||||
public string getIabConsentString()
|
||||
{
|
||||
return GetIabConsentString();
|
||||
}
|
||||
|
||||
public string shouldShowConsentDialog()
|
||||
{
|
||||
return ShouldShowConsentDialog();
|
||||
}
|
||||
|
||||
public string getConsentZone()
|
||||
{
|
||||
return GetConsentZone();
|
||||
}
|
||||
|
||||
public string getConsentStatus()
|
||||
{
|
||||
return GetConsentStatus();
|
||||
}
|
||||
|
||||
public IntPtr getConsent()
|
||||
{
|
||||
return GetConsent();
|
||||
}
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void RequestConsentInfoUpdate(string appodealAppKey,
|
||||
ConsentInfoUpdatedCallback onConsentInfoUpdated,
|
||||
ConsentInfoUpdatedFailedCallback onFailedToUpdateConsentInfo);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void DisableAppTrackingTransparencyRequest();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern IntPtr GetConsentManager();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void SetCustomVendor(IntPtr customVendor);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern IntPtr GetCustomVendor(string bundle);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern string GetStorage();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void SetStorage(string storage);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern string GetIabConsentString();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern string ShouldShowConsentDialog();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern string GetConsentZone();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern string GetConsentStatus();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern IntPtr GetConsent();
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
internal class VendorBuilderObjCBridge
|
||||
{
|
||||
private readonly IntPtr nativeObject;
|
||||
|
||||
public VendorBuilderObjCBridge(string name, string bundle, string url)
|
||||
{
|
||||
nativeObject = GetVendor(name, bundle, url);
|
||||
}
|
||||
|
||||
public IntPtr getNativeObject()
|
||||
{
|
||||
return nativeObject;
|
||||
}
|
||||
|
||||
public static void setPurposeIds(IEnumerable<int> purposeIds)
|
||||
{
|
||||
SetPurposeIds(CommaSeparatedStringFromList(purposeIds));
|
||||
}
|
||||
|
||||
public static void setFeatureIds(IEnumerable<int> featureIds)
|
||||
{
|
||||
SetFeatureIds(CommaSeparatedStringFromList(featureIds));
|
||||
}
|
||||
|
||||
public static void setLegitimateInterestPurposeIds(IEnumerable<int> legitimateInterestPurposeIds)
|
||||
{
|
||||
SetLegitimateInterestPurposeIds(CommaSeparatedStringFromList(legitimateInterestPurposeIds));
|
||||
}
|
||||
|
||||
private static string CommaSeparatedStringFromList(IEnumerable<int> list)
|
||||
{
|
||||
return string.Join(",", list.Select(n => n.ToString()).ToArray());
|
||||
}
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern IntPtr GetVendor(string name, string bundle, string url);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void SetPurposeIds(string purposeIds);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void SetFeatureIds(string featureIds);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void SetLegitimateInterestPurposeIds(string purposeIds);
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
internal class VendorObjBridge
|
||||
{
|
||||
private readonly IntPtr vendor;
|
||||
|
||||
public VendorObjBridge()
|
||||
{
|
||||
vendor = GetVendor();
|
||||
}
|
||||
|
||||
public VendorObjBridge(IntPtr vendorIntPtr)
|
||||
{
|
||||
vendor = vendorIntPtr;
|
||||
}
|
||||
|
||||
public IntPtr getVendor()
|
||||
{
|
||||
return vendor;
|
||||
}
|
||||
|
||||
public static string getName()
|
||||
{
|
||||
return VendorGetName();
|
||||
}
|
||||
|
||||
public static string getBundle()
|
||||
{
|
||||
return VendorGetBundle();
|
||||
}
|
||||
|
||||
public static string getPolicyUrl()
|
||||
{
|
||||
return VendorGetPolicyUrl();
|
||||
}
|
||||
|
||||
public static List<int> getPurposeIds()
|
||||
{
|
||||
return getList( VendorGetPurposeIds());
|
||||
}
|
||||
|
||||
public static List<int> getFeatureIds()
|
||||
{
|
||||
return getList( VendorGetFeatureIds());
|
||||
}
|
||||
|
||||
public static List<int> getLegitimateInterestPurposeIds()
|
||||
{
|
||||
return getList(VendorGetLegitimateInterestPurposeIds());
|
||||
}
|
||||
|
||||
private static List<int> getList(string raw)
|
||||
{
|
||||
return raw.Split(new[] { "," },
|
||||
StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(item => Convert.ToInt32(item)).ToList();
|
||||
}
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern IntPtr GetVendor();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern string VendorGetName();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern string VendorGetBundle();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern string VendorGetPolicyUrl();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern string VendorGetPurposeIds();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern string VendorGetFeatureIds();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern string VendorGetLegitimateInterestPurposeIds();
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
internal class ConsentObjBridge
|
||||
{
|
||||
private readonly IntPtr consent;
|
||||
|
||||
public ConsentObjBridge(IntPtr intPtr)
|
||||
{
|
||||
consent = intPtr;
|
||||
}
|
||||
|
||||
public IntPtr getConsent()
|
||||
{
|
||||
return consent;
|
||||
}
|
||||
|
||||
public static string getZone()
|
||||
{
|
||||
return GetZone();
|
||||
}
|
||||
|
||||
public static string getStatus()
|
||||
{
|
||||
return GetStatus();
|
||||
}
|
||||
|
||||
public static string getAuthorizationStatus()
|
||||
{
|
||||
return GetAuthorizationStatus();
|
||||
}
|
||||
|
||||
public static string getIabConsentString()
|
||||
{
|
||||
return GetIabString();
|
||||
}
|
||||
|
||||
public string hasConsentForVendor(string bundle)
|
||||
{
|
||||
return HasConsentForVendor(bundle);
|
||||
}
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern string GetZone();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern string GetStatus();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern string GetAuthorizationStatus();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern string GetIabString();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern string HasConsentForVendor(string bundle);
|
||||
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
internal class ConsentFormObjCBridge
|
||||
{
|
||||
private readonly IntPtr consentForm;
|
||||
|
||||
public ConsentFormObjCBridge()
|
||||
{
|
||||
consentForm = GetConsentForm();
|
||||
}
|
||||
|
||||
public ConsentFormObjCBridge(IntPtr intPtr)
|
||||
{
|
||||
consentForm = intPtr;
|
||||
}
|
||||
|
||||
public static void load()
|
||||
{
|
||||
Load();
|
||||
}
|
||||
|
||||
public static void show()
|
||||
{
|
||||
Show();
|
||||
}
|
||||
|
||||
public static bool isLoaded()
|
||||
{
|
||||
return IsLoaded();
|
||||
}
|
||||
|
||||
public static bool isShowing()
|
||||
{
|
||||
return IsShowing();
|
||||
}
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern IntPtr GetConsentForm();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void Load();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void Show();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern bool IsLoaded();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern bool IsShowing();
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
internal class ConsentFormBuilderObjCBridge
|
||||
{
|
||||
private readonly IntPtr consentFormBuilder;
|
||||
|
||||
public ConsentFormBuilderObjCBridge()
|
||||
{
|
||||
consentFormBuilder = GetConsentForm();
|
||||
}
|
||||
|
||||
public ConsentFormBuilderObjCBridge(IntPtr intPtr)
|
||||
{
|
||||
consentFormBuilder = intPtr;
|
||||
}
|
||||
|
||||
public IntPtr getConsentFormBuilder()
|
||||
{
|
||||
return consentFormBuilder;
|
||||
}
|
||||
|
||||
public static void withListener(ConsentFormCallback onConsentFormLoaded,
|
||||
ConsentFormCallbackError onConsentFormError,
|
||||
ConsentFormCallback onConsentFormOpened,
|
||||
ConsentFormCallbackClosed onConsentFormClosed)
|
||||
{
|
||||
WithListener(onConsentFormLoaded, onConsentFormError, onConsentFormOpened, onConsentFormClosed);
|
||||
}
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern IntPtr GetConsentForm();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void WithListener(
|
||||
ConsentFormCallback onConsentFormLoaded,
|
||||
ConsentFormCallbackError onConsentFormError,
|
||||
ConsentFormCallback onConsentFormOpened,
|
||||
ConsentFormCallbackClosed onConsentFormClosed);
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
internal class ConsentManagerExceptionObjCBridge
|
||||
{
|
||||
private readonly IntPtr consentManagerException;
|
||||
|
||||
public ConsentManagerExceptionObjCBridge(IntPtr intPtr)
|
||||
{
|
||||
consentManagerException = intPtr;
|
||||
}
|
||||
|
||||
public ConsentManagerExceptionObjCBridge()
|
||||
{
|
||||
consentManagerException = GetConsentManagerException();
|
||||
}
|
||||
|
||||
public IntPtr getConsentManagerException()
|
||||
{
|
||||
return consentManagerException;
|
||||
}
|
||||
|
||||
public string getReason()
|
||||
{
|
||||
return GetReason();
|
||||
}
|
||||
|
||||
public static int getCode()
|
||||
{
|
||||
return GetCode();
|
||||
}
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern IntPtr GetConsentManagerException();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern string GetReason();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern int GetCode();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6f03f604726e450b86569ea8320b5f2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,495 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using AOT;
|
||||
using UnityEngine;
|
||||
using ConsentManager.Common;
|
||||
|
||||
namespace ConsentManager.Platforms.iOS
|
||||
{
|
||||
#if UNITY_IPHONE
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "CollectionNeverUpdated.Local")]
|
||||
[SuppressMessage("ReSharper", "UnusedType.Global")]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
public class iOSConsentManager : IConsentManager
|
||||
{
|
||||
private readonly ConsentManagerObjCBridge consentManagerObjCBridge;
|
||||
private static IConsentInfoUpdateListener consentInfoUpdateListener;
|
||||
|
||||
public iOSConsentManager()
|
||||
{
|
||||
consentManagerObjCBridge = new ConsentManagerObjCBridge();
|
||||
}
|
||||
|
||||
public iOSConsentManager(IntPtr intPtr)
|
||||
{
|
||||
consentManagerObjCBridge = new ConsentManagerObjCBridge(intPtr);
|
||||
}
|
||||
|
||||
public void requestConsentInfoUpdate(string appodealAppKey, IConsentInfoUpdateListener listener)
|
||||
{
|
||||
consentInfoUpdateListener = listener;
|
||||
ConsentManagerObjCBridge.requestConsentInfoUpdate(appodealAppKey, onConsentInfoUpdated,
|
||||
onFailedToUpdateConsentInfo);
|
||||
}
|
||||
|
||||
public void disableAppTrackingTransparencyRequest()
|
||||
{
|
||||
ConsentManagerObjCBridge.disableAppTrackingTransparencyRequest();
|
||||
}
|
||||
|
||||
public void setCustomVendor(Vendor customVendor)
|
||||
{
|
||||
var vendor = (iOSVendor) customVendor.getNativeVendor();
|
||||
consentManagerObjCBridge.setCustomVendor(vendor.getIntPtr());
|
||||
}
|
||||
|
||||
public Vendor getCustomVendor(string bundle)
|
||||
{
|
||||
return new Vendor(new iOSVendor(consentManagerObjCBridge.getCustomVendor(bundle)));
|
||||
}
|
||||
|
||||
public ConsentManager.Storage getStorage()
|
||||
{
|
||||
var storage = ConsentManager.Storage.NONE;
|
||||
switch (consentManagerObjCBridge.getStorage())
|
||||
{
|
||||
case "NONE":
|
||||
storage = ConsentManager.Storage.NONE;
|
||||
break;
|
||||
case "SHARED_PREFERENCE":
|
||||
storage = ConsentManager.Storage.SHARED_PREFERENCE;
|
||||
break;
|
||||
}
|
||||
|
||||
return storage;
|
||||
}
|
||||
|
||||
public void setStorage(ConsentManager.Storage iabStorage)
|
||||
{
|
||||
consentManagerObjCBridge.setStorage(iabStorage.ToString());
|
||||
}
|
||||
|
||||
public string getIabConsentString()
|
||||
{
|
||||
return consentManagerObjCBridge.getIabConsentString();
|
||||
}
|
||||
|
||||
public Consent.ShouldShow shouldShowConsentDialog()
|
||||
{
|
||||
var shouldShow = Consent.ShouldShow.UNKNOWN;
|
||||
|
||||
switch (consentManagerObjCBridge.shouldShowConsentDialog())
|
||||
{
|
||||
case "UNKNOWN":
|
||||
shouldShow = Consent.ShouldShow.UNKNOWN;
|
||||
break;
|
||||
case "TRUE":
|
||||
shouldShow = Consent.ShouldShow.TRUE;
|
||||
break;
|
||||
case "FALSE":
|
||||
shouldShow = Consent.ShouldShow.FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
return shouldShow;
|
||||
}
|
||||
|
||||
public Consent.Zone getConsentZone()
|
||||
{
|
||||
var zone = Consent.Zone.UNKNOWN;
|
||||
|
||||
switch (consentManagerObjCBridge.getConsentZone())
|
||||
{
|
||||
case "UNKNOWN":
|
||||
zone = Consent.Zone.UNKNOWN;
|
||||
break;
|
||||
case "CCPA":
|
||||
zone = Consent.Zone.CCPA;
|
||||
break;
|
||||
case "GDPR":
|
||||
zone = Consent.Zone.GDPR;
|
||||
break;
|
||||
case "NONE":
|
||||
zone = Consent.Zone.NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
return zone;
|
||||
}
|
||||
|
||||
public Consent.Status getConsentStatus()
|
||||
{
|
||||
var status = Consent.Status.UNKNOWN;
|
||||
|
||||
switch (consentManagerObjCBridge.getConsentStatus())
|
||||
{
|
||||
case "UNKNOWN":
|
||||
status = Consent.Status.UNKNOWN;
|
||||
break;
|
||||
case "PERSONALIZED":
|
||||
status = Consent.Status.PERSONALIZED;
|
||||
break;
|
||||
case "NON_PERSONALIZED":
|
||||
status = Consent.Status.NON_PERSONALIZED;
|
||||
break;
|
||||
case "PARTLY_PERSONALIZED":
|
||||
status = Consent.Status.PARTLY_PERSONALIZED;
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
public Consent getConsent()
|
||||
{
|
||||
return new Consent(new iOSConsent(consentManagerObjCBridge.getConsent()));
|
||||
}
|
||||
|
||||
#region ConsentInfoUpdate delegate
|
||||
|
||||
[MonoPInvokeCallback(typeof(ConsentInfoUpdatedCallback))]
|
||||
private static void onConsentInfoUpdated(IntPtr consent)
|
||||
{
|
||||
Debug.Log("onConsentInfoUpdated");
|
||||
|
||||
consentInfoUpdateListener?.onConsentInfoUpdated(new Consent(new iOSConsent(consent)));
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback(typeof(ConsentInfoUpdatedFailedCallback))]
|
||||
private static void onFailedToUpdateConsentInfo(IntPtr error)
|
||||
{
|
||||
consentInfoUpdateListener?.onFailedToUpdateConsentInfo(
|
||||
new ConsentManagerException(new iOSConsentManagerException(error)));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public class iOSVendor : IVendor
|
||||
{
|
||||
private readonly VendorObjBridge vendorObjBridge;
|
||||
|
||||
public iOSVendor(IntPtr vendor)
|
||||
{
|
||||
vendorObjBridge = new VendorObjBridge(vendor);
|
||||
}
|
||||
|
||||
public IntPtr getIntPtr()
|
||||
{
|
||||
return vendorObjBridge.getVendor();
|
||||
}
|
||||
|
||||
public string getName()
|
||||
{
|
||||
return VendorObjBridge.getName();
|
||||
}
|
||||
|
||||
public string getBundle()
|
||||
{
|
||||
return VendorObjBridge.getBundle();
|
||||
}
|
||||
|
||||
public string getPolicyUrl()
|
||||
{
|
||||
return VendorObjBridge.getPolicyUrl();
|
||||
}
|
||||
|
||||
public List<int> getPurposeIds()
|
||||
{
|
||||
return VendorObjBridge.getPurposeIds();
|
||||
}
|
||||
|
||||
public List<int> getFeatureIds()
|
||||
{
|
||||
return VendorObjBridge.getFeatureIds();
|
||||
}
|
||||
|
||||
public List<int> getLegitimateInterestPurposeIds()
|
||||
{
|
||||
return VendorObjBridge.getLegitimateInterestPurposeIds();
|
||||
}
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "UnusedType.Global")]
|
||||
public class iOSVendorBuilder : IVendorBuilder
|
||||
{
|
||||
private readonly VendorBuilderObjCBridge vendorBuilderObjCBridge;
|
||||
|
||||
public iOSVendorBuilder(string name, string bundle, string url)
|
||||
{
|
||||
vendorBuilderObjCBridge = new VendorBuilderObjCBridge(name, bundle, url);
|
||||
}
|
||||
|
||||
private IntPtr GetIntPtr()
|
||||
{
|
||||
return vendorBuilderObjCBridge.getNativeObject();
|
||||
}
|
||||
|
||||
public IVendor build()
|
||||
{
|
||||
return new iOSVendor(GetIntPtr());
|
||||
}
|
||||
|
||||
public void setPurposeIds(IEnumerable<int> purposeIds)
|
||||
{
|
||||
VendorBuilderObjCBridge.setPurposeIds(Helper.getEnumerable(purposeIds));
|
||||
}
|
||||
|
||||
public void setFeatureIds(IEnumerable<int> featureIds)
|
||||
{
|
||||
VendorBuilderObjCBridge.setFeatureIds(Helper.getEnumerable(featureIds));
|
||||
}
|
||||
|
||||
public void setLegitimateInterestPurposeIds(IEnumerable<int> legitimateInterestPurposeIds)
|
||||
{
|
||||
VendorBuilderObjCBridge.setLegitimateInterestPurposeIds(Helper.getEnumerable(legitimateInterestPurposeIds));
|
||||
}
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "ObjectCreationAsStatement")]
|
||||
public class iOSConsentForm : IConsentForm
|
||||
{
|
||||
public iOSConsentForm(IntPtr intPtr)
|
||||
{
|
||||
new ConsentFormObjCBridge(intPtr);
|
||||
}
|
||||
|
||||
public void load()
|
||||
{
|
||||
ConsentFormObjCBridge.load();
|
||||
}
|
||||
|
||||
public void show()
|
||||
{
|
||||
ConsentFormObjCBridge.show();
|
||||
}
|
||||
|
||||
public bool isLoaded()
|
||||
{
|
||||
return ConsentFormObjCBridge.isLoaded();
|
||||
}
|
||||
|
||||
public bool isShowing()
|
||||
{
|
||||
return ConsentFormObjCBridge.isShowing();
|
||||
}
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "UnassignedField.Global")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
||||
[SuppressMessage("ReSharper", "UnusedType.Global")]
|
||||
public class iOSConsentFormBuilder
|
||||
{
|
||||
private readonly ConsentFormBuilderObjCBridge consentFormBuilderObjCBridge;
|
||||
public static IConsentFormListener consentFormListeners;
|
||||
|
||||
public iOSConsentFormBuilder()
|
||||
{
|
||||
consentFormBuilderObjCBridge = new ConsentFormBuilderObjCBridge();
|
||||
}
|
||||
|
||||
public iOSConsentFormBuilder(IntPtr intPtr)
|
||||
{
|
||||
consentFormBuilderObjCBridge = new ConsentFormBuilderObjCBridge(intPtr);
|
||||
}
|
||||
|
||||
private IntPtr GetIntPtr()
|
||||
{
|
||||
return consentFormBuilderObjCBridge.getConsentFormBuilder();
|
||||
}
|
||||
|
||||
public IConsentForm build()
|
||||
{
|
||||
return new iOSConsentForm(GetIntPtr());
|
||||
}
|
||||
|
||||
public void withListener(IConsentFormListener listener)
|
||||
{
|
||||
consentFormListeners = listener;
|
||||
ConsentFormBuilderObjCBridge.withListener(onConsentFormLoaded, onConsentFormError, onConsentFormOpened,
|
||||
onConsentFormClosed);
|
||||
}
|
||||
|
||||
#region ConsentForm Callbacks
|
||||
|
||||
[MonoPInvokeCallback(typeof(ConsentFormCallback))]
|
||||
private static void onConsentFormLoaded()
|
||||
{
|
||||
consentFormListeners?.onConsentFormLoaded();
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback(typeof(ConsentFormCallbackError))]
|
||||
private static void onConsentFormError(IntPtr exception)
|
||||
{
|
||||
consentFormListeners?.onConsentFormError(new ConsentManagerException(new iOSConsentManagerException(exception)));
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback(typeof(ConsentFormCallback))]
|
||||
private static void onConsentFormOpened()
|
||||
{
|
||||
consentFormListeners?.onConsentFormOpened();
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback(typeof(ConsentFormCallbackClosed))]
|
||||
private static void onConsentFormClosed(IntPtr consent)
|
||||
{
|
||||
consentFormListeners?.onConsentFormClosed(new Consent(new iOSConsent(consent)));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
public class iOSConsentManagerException : IConsentManagerException
|
||||
{
|
||||
private readonly ConsentManagerExceptionObjCBridge consentManagerExceptionObjCBridge;
|
||||
|
||||
public iOSConsentManagerException()
|
||||
{
|
||||
consentManagerExceptionObjCBridge = new ConsentManagerExceptionObjCBridge();
|
||||
}
|
||||
|
||||
public iOSConsentManagerException(IntPtr intPtr)
|
||||
{
|
||||
consentManagerExceptionObjCBridge = new ConsentManagerExceptionObjCBridge(intPtr);
|
||||
}
|
||||
|
||||
public string getReason()
|
||||
{
|
||||
return consentManagerExceptionObjCBridge.getReason();
|
||||
}
|
||||
|
||||
public int getCode()
|
||||
{
|
||||
return ConsentManagerExceptionObjCBridge.getCode();
|
||||
}
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
public class iOSConsent : IConsent
|
||||
{
|
||||
private readonly ConsentObjBridge consentObjBridge;
|
||||
|
||||
public iOSConsent(IntPtr intPtr)
|
||||
{
|
||||
consentObjBridge = new ConsentObjBridge(intPtr);
|
||||
}
|
||||
|
||||
public IntPtr GetIntPtr()
|
||||
{
|
||||
return consentObjBridge.getConsent();
|
||||
}
|
||||
|
||||
public Consent.Zone getZone()
|
||||
{
|
||||
var zone = Consent.Zone.UNKNOWN;
|
||||
|
||||
switch (ConsentObjBridge.getZone())
|
||||
{
|
||||
case "UNKNOWN":
|
||||
zone = Consent.Zone.UNKNOWN;
|
||||
break;
|
||||
case "NONE":
|
||||
zone = Consent.Zone.NONE;
|
||||
break;
|
||||
case "CCPA":
|
||||
zone = Consent.Zone.CCPA;
|
||||
break;
|
||||
case "GDPR":
|
||||
zone = Consent.Zone.GDPR;
|
||||
break;
|
||||
}
|
||||
|
||||
return zone;
|
||||
}
|
||||
|
||||
public Consent.Status getStatus()
|
||||
{
|
||||
var status = Consent.Status.UNKNOWN;
|
||||
switch (ConsentObjBridge.getStatus())
|
||||
{
|
||||
case "UNKNOWN":
|
||||
status = Consent.Status.UNKNOWN;
|
||||
break;
|
||||
case "PERSONALIZED":
|
||||
status = Consent.Status.PERSONALIZED;
|
||||
break;
|
||||
case "NON_PERSONALIZED":
|
||||
status = Consent.Status.NON_PERSONALIZED;
|
||||
break;
|
||||
case "PARTLY_PERSONALIZED":
|
||||
status = Consent.Status.PARTLY_PERSONALIZED;
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
public Consent.AuthorizationStatus getAuthorizationStatus()
|
||||
{
|
||||
var authorizationStatus = Consent.AuthorizationStatus.NOT_DETERMINED;
|
||||
switch (ConsentObjBridge.getAuthorizationStatus())
|
||||
{
|
||||
case "NOT_DETERMINED":
|
||||
authorizationStatus = Consent.AuthorizationStatus.NOT_DETERMINED;
|
||||
break;
|
||||
case "DENIED":
|
||||
authorizationStatus = Consent.AuthorizationStatus.DENIED;
|
||||
break;
|
||||
case "RESTRICTED":
|
||||
authorizationStatus = Consent.AuthorizationStatus.RESTRICTED;
|
||||
break;
|
||||
case "AUTHORIZED":
|
||||
authorizationStatus = Consent.AuthorizationStatus.AUTHORIZED;
|
||||
break;
|
||||
}
|
||||
|
||||
return authorizationStatus;
|
||||
}
|
||||
|
||||
public Consent.HasConsent hasConsentForVendor(string bundle)
|
||||
{
|
||||
var hasConsent = Consent.HasConsent.UNKNOWN;
|
||||
|
||||
switch (ConsentObjBridge.getStatus())
|
||||
{
|
||||
case "UNKNOWN":
|
||||
hasConsent = Consent.HasConsent.UNKNOWN;
|
||||
break;
|
||||
case "TRUE":
|
||||
hasConsent = Consent.HasConsent.TRUE;
|
||||
break;
|
||||
case "FALSE":
|
||||
hasConsent = Consent.HasConsent.FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
return hasConsent;
|
||||
}
|
||||
|
||||
public string getIabConsentString()
|
||||
{
|
||||
return ConsentObjBridge.getIabConsentString();
|
||||
}
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public static class Helper
|
||||
{
|
||||
public static IEnumerable<int> getEnumerable(IEnumerable<int> enumerable)
|
||||
{
|
||||
return enumerable as int[] ?? enumerable.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6bfcfaed0fe6243d68b12148624744d0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user