internal AndroidJavaObject ConstructTargetingParam(string key, string value) { AndroidJavaObject targetingParam = new AndroidJavaObject("com.sourcepoint.cmplibrary.model.exposed.TargetingParam", key, value); CmpDebugUtil.Log("TargetingParam is OK"); return(targetingParam); }
void transferCustomConsentToUnity(string spConsentsJson) { CmpDebugUtil.Log("transferCustomConsentToUnitySide c#-side custom consent ->" + spConsentsJson.ToString()); SpCustomConsentAndroid parsed = null; try { parsed = JsonUnwrapper.UnwrapSpCustomConsentAndroid(spConsentsJson); } catch (Exception ex) { Debug.LogError("Something went wrong while parsing the json data; null will be returned. \n Exception message: " + ex.Message); } finally { if (parsed == null) { callback?.Invoke(null); } else { var spGdpr = JsonUnwrapper.UnwrapSpGdprConsentAndroid(parsed.gdpr); customGdprConsent = spGdpr.consents; callback?.Invoke(customGdprConsent); } } }
internal AndroidJavaObject ConsrtuctLib(AndroidJavaObject spConfig, AndroidJavaObject activity, SpClientProxy spClient) { AndroidJavaObject lib = pluginFactoryClass.CallStatic <AndroidJavaObject>("makeConsentLib", spConfig, activity, spClient); CmpDebugUtil.Log("consentLib is OK"); return(lib); }
void OnConsentAction(string message) { CmpDebugUtil.Log("OnConsentAction IOS_CALLBACK_RECEIVED: " + message); CONSENT_ACTION_TYPE actionType = (CONSENT_ACTION_TYPE)Convert.ToInt32(message); ConsentMessenger.Broadcast <IOnConsentAction>(actionType); }
internal AndroidJavaObject ConstructCampaign(AndroidJavaObject campaignType, AndroidJavaObject targetingParams, CAMPAIGN_TYPE campaignTypeForLog) { AndroidJavaObject campaign = new AndroidJavaObject("com.sourcepoint.cmplibrary.model.exposed.SpCampaign", campaignType, targetingParams); CmpDebugUtil.Log($"Campaign {campaignTypeForLog} is OK"); return(campaign); }
internal AndroidJavaObject ConstructSpConfig(int accountId, string propertyName, long messageTimeout, AndroidJavaObject language, CAMPAIGN_ENV campaignsEnvironment, AndroidJavaObject[] spCampaigns) { AndroidJavaObject spConfig; using (AndroidJavaObject SpConfigDataBuilderClass = new AndroidJavaObject("com.sourcepoint.cmplibrary.creation.SpConfigDataBuilder")) { SpConfigDataBuilderClass.Call <AndroidJavaObject>("addAccountId", accountId); CmpDebugUtil.Log("addAccountId is OK"); SpConfigDataBuilderClass.Call <AndroidJavaObject>("addPropertyName", propertyName); CmpDebugUtil.Log("addPropertyName is OK"); SpConfigDataBuilderClass.Call <AndroidJavaObject>("addMessageLanguage", language); CmpDebugUtil.Log("addMessageLanguage is OK"); SpConfigDataBuilderClass.Call <AndroidJavaObject>("addMessageTimeout", messageTimeout); CmpDebugUtil.Log("addMessageTimeout is OK"); AndroidJavaObject env = ConstructCampaignEnv(campaignsEnvironment); SpConfigDataBuilderClass.Call <AndroidJavaObject>("addCampaignsEnv", env); CmpDebugUtil.Log("addCampaignsEnv is OK"); foreach (AndroidJavaObject camp in spCampaigns) { SpConfigDataBuilderClass.Call <AndroidJavaObject>("addCampaign", camp); CmpDebugUtil.Log("addCampaign is OK"); } spConfig = SpConfigDataBuilderClass.Call <AndroidJavaObject>("build"); CmpDebugUtil.Log("build() is OK"); } CmpDebugUtil.Log("SpConfig is OK"); return(spConfig); }
void OnCustomConsentGDPRCallback(string jsonSPGDPRConsent) { CmpDebugUtil.Log("OnCustomConsentGDPRCallback IOS_CALLBACK_RECEIVED: " + jsonSPGDPRConsent); GdprConsent unwrapped = null; try { unwrapped = JsonUnwrapper.UnwrapGdprConsent(jsonSPGDPRConsent); } catch (Exception ex) { Debug.LogError( "Something went wrong while parsing the json data; null will be returned. \n Exception message: " + ex.Message); } finally { if (unwrapped == null) { onCustomConsentsGDPRSuccessAction?.Invoke(null); } else { customGdprConsent = unwrapped; onCustomConsentsGDPRSuccessAction?.Invoke(unwrapped); } } }
void onAction(AndroidJavaObject view, AndroidJavaObject actionType) { CONSENT_ACTION_TYPE unwrappedType = (CONSENT_ACTION_TYPE)actionType.Call <int>("getCode"); CmpDebugUtil.Log("I've reached the C# onAction: " + unwrappedType); ConsentMessenger.Broadcast <IOnConsentAction>(unwrappedType); }
void OnErrorCallback(string jsonError) { CmpDebugUtil.LogError("OnErrorCallback IOS_CALLBACK_RECEIVED: " + jsonError); Exception ex = new Exception(jsonError); ConsentMessenger.Broadcast <IOnConsentError>(ex); }
internal AndroidJavaObject ConstructPrivacyManagerTab(PRIVACY_MANAGER_TAB tab) { AndroidJavaObject privacyManagerTabK = new AndroidJavaObject("com.sourcepoint.cmplibrary.model.PMTab", CSharp2JavaStringEnumMapper.GetPrivacyManagerTabKey(tab), (int)tab); privacyManagerTabK.Set("key", CSharp2JavaStringEnumMapper.GetPrivacyManagerTabKey(tab)); CmpDebugUtil.Log("PMTab is OK"); return(privacyManagerTabK); }
internal AndroidJavaObject ConstructMessageLanguage(MESSAGE_LANGUAGE lang) { AndroidJavaObject msgLang = new AndroidJavaObject("com.sourcepoint.cmplibrary.model.MessageLanguage", CSharp2JavaStringEnumMapper.GetMessageLanguageKey(lang), (int)lang); msgLang.Set("value", CSharp2JavaStringEnumMapper.GetMessageLanguageKey(lang)); CmpDebugUtil.Log("MessageLanguage is OK"); return(msgLang); }
void onConsentReady(string spConsents) { CmpDebugUtil.Log("I've reached the C# onConsentReady with json string: " + spConsents); SpConsents consents = JsonUnwrapper.UnwrapSpConsentsAndroid(spConsents); _spConsents = consents; ConsentMessenger.Broadcast <IOnConsentReady>(consents); }
void onError(AndroidJavaObject rawThrowableObject) { CmpDebugUtil.Log("I've reached the C# onError : " + rawThrowableObject.ToString()); Exception exception = CmpJavaToUnityUtils.ConvertThrowableToError(rawThrowableObject); CmpDebugUtil.Log("Exception converted successfully : " + exception.ToString()); ConsentMessenger.Broadcast <IOnConsentError>(exception); }
private AndroidJavaObject ConstructCampaignEnv(CAMPAIGN_ENV environment) { AndroidJavaObject campaignEnv = new AndroidJavaObject("com.sourcepoint.cmplibrary.data.network.util.CampaignsEnv", CSharp2JavaStringEnumMapper.GetCampaignEnvKey(environment), (int)environment); campaignEnv.Set("env", CSharp2JavaStringEnumMapper.GetCampaignEnvKey(environment)); CmpDebugUtil.Log("campaignEnv is OK"); return(campaignEnv); }
private void Awake() { gameObject.name = "CMPiOSListenerHelper"; #if UNITY_IOS && !UNITY_EDITOR_OSX CmpDebugUtil.Log("Constructing CMPiOSListenerHelper game object..."); DontDestroyOnLoad(this.gameObject); _setUnityCallback(gameObject.name); #endif }
internal static AndroidJavaObject ConvertArrayToList(AndroidJavaObject[] array) { using (AndroidJavaClass UnityUtils = new AndroidJavaClass(UnityUtilsPackageName)) { CmpDebugUtil.Log("C# : passing Array to List conversion to Android's UnityUtils..."); AndroidJavaObject list = UnityUtils.CallStatic <AndroidJavaObject>("arrayToList", new AndroidJavaObject[][] { array }); return(list); } }
internal void Dispose() { if (consentLib != null) { constructor.Dispose(); CmpDebugUtil.Log("Disposing consentLib..."); consentLib.Call("dispose"); CmpDebugUtil.Log("Disposing consentLib successfully done"); } }
public AndroidJavaConstruct() { #if UNITY_ANDROID if (Application.platform == RuntimePlatform.Android) { this.pluginFactoryClass = new AndroidJavaClass(androidPluginName); CmpDebugUtil.Log("plugin class is OK"); } #endif }
private void InvokeLoadMessageWithAuthID(string authID) { CmpDebugUtil.Log("loadMessage(authId: String) STARTING..."); try { consentLib.Call("loadMessage", authID); } catch (Exception ex) { CmpDebugUtil.LogError(ex.Message); } finally { CmpDebugUtil.Log("loadMessage(authId: String) DONE"); } }
public static void UnregisterBroadcastReceiver <T>(GameObject go) where T : IConsentEventHandler { if (BroadcastsReceivers.ContainsKey(typeof(T)) && BroadcastsReceivers[typeof(T)].Contains(go)) { BroadcastsReceivers[typeof(T)].Remove(go); } else { CmpDebugUtil.LogWarning($"{go.name} is not subscribed to handle {typeof(T)}"); } }
private void InvokeLoadMessage() { CmpDebugUtil.Log("InvokeLoadMessage() STARTING..."); try { consentLib.Call("loadMessage"); CmpDebugUtil.Log($"loadMessage() is OK..."); } catch (Exception ex) { CmpDebugUtil.LogError(ex.Message); } finally { CmpDebugUtil.Log($"InvokeLoadMessage() DONE"); } }
private void InvokeLoadPrivacyManager(string pmId, AndroidJavaObject tab, AndroidJavaObject campaignType, CAMPAIGN_TYPE campaignTypeForLog) { CmpDebugUtil.Log("InvokeLoadPrivacyManager() STARTING..."); try { consentLib.Call("loadPrivacyManager", pmId, tab, campaignType); CmpDebugUtil.Log($"loadPrivacyManager() with {campaignTypeForLog} is OK..."); } catch (Exception ex) { CmpDebugUtil.LogError(ex.Message); } finally { CmpDebugUtil.Log($"InvokeLoadPrivacyManager() with {campaignTypeForLog} DONE"); } }
ConsentWrapperAndroid() { #if UNITY_ANDROID if (Application.platform == RuntimePlatform.Android) { activity = AndroidJavaConstruct.GetActivity(); CmpDebugUtil.Log("Activity is OK"); spClient = new SpClientProxy(); CmpDebugUtil.Log("spClient is OK"); this.constructor = new AndroidJavaConstruct(); CmpDebugUtil.Log("AndroidJavaConstruct obj is OK"); } #endif }
public static void Execute <T>(BaseEventData eventData, ExecuteEvents.EventFunction <T> functor) where T : IConsentEventHandler { var handlers = BroadcastReceivers.GetHandlersForEvent <T>(); if (handlers == null) { return; } CmpDebugUtil.Log($"{typeof(T).Name} has {handlers.Count} invokable instances"); foreach (var handler in handlers) { actions.Enqueue(delegate { ExecuteEvents.Execute <T>(handler, eventData, functor); }); } }
internal static Exception ConvertThrowableToError(AndroidJavaObject rawErr) { using (AndroidJavaClass UnityUtils = new AndroidJavaClass(UnityUtilsPackageName)) { try { CmpDebugUtil.Log("C# : passing Throwable to Exception conversion to Android's UnityUtils..."); UnityUtils.CallStatic("throwableToException", rawErr); } catch (AndroidJavaException exception) { return(exception); } return(new NotImplementedException()); } }
public void LoadPrivacyManager(CAMPAIGN_TYPE campaignType, string pmId, PRIVACY_MANAGER_TAB tab) { #if UNITY_ANDROID if (Application.platform == RuntimePlatform.Android) { try { AndroidJavaObject type = constructor.ConstructCampaignType(campaignType); AndroidJavaObject privacyManagerTab = constructor.ConstructPrivacyManagerTab(tab); RunOnUiThread(delegate { InvokeLoadPrivacyManager(pmId, privacyManagerTab, type, campaignType); }); } catch (Exception e) { CmpDebugUtil.LogError(e.Message); } } #endif }
void OnConsentReady(string message) { CmpDebugUtil.Log("OnConsentReady IOS_CALLBACK_RECEIVED: " + message); SpConsents spConsents = null; try { spConsents = JsonUnwrapper.UnwrapSpConsents(message); } catch (Exception ex) { Debug.LogError( "Something went wrong while parsing the json data; null will be returned. \n Exception message: " + ex.Message); } finally { _spConsents = spConsents; ConsentMessenger.Broadcast <IOnConsentReady>(spConsents); } }
internal AndroidJavaObject ConstructCampaignType(CAMPAIGN_TYPE campaignType) { AndroidJavaObject type = null; switch (campaignType) { case CAMPAIGN_TYPE.GDPR: type = new AndroidJavaObject("com.sourcepoint.cmplibrary.exception.CampaignType", CAMPAIGN_TYPE_STRING_KEY.GDPR, (int)CAMPAIGN_TYPE_ANDROID.GDPR); //GDPR has ordinal 0 in Java enum! break; case CAMPAIGN_TYPE.CCPA: type = new AndroidJavaObject("com.sourcepoint.cmplibrary.exception.CampaignType", CAMPAIGN_TYPE_STRING_KEY.CCPA, (int)CAMPAIGN_TYPE_ANDROID.CCPA); //CCPA has ordinal 1 in Java enum! break; default: CmpDebugUtil.LogError("CampaignType is NULL. How did you get there?"); break; } CmpDebugUtil.Log($"CampaignType {campaignType} is OK"); return(type); }
public void InitializeLib(List <SpCampaign> spCampaigns, int accountId, string propertyName, MESSAGE_LANGUAGE language, CAMPAIGN_ENV campaignsEnvironment, long messageTimeoutMilliSeconds = 3000) { #if UNITY_ANDROID if (Application.platform == RuntimePlatform.Android) { try { AndroidJavaObject msgLang = constructor.ConstructMessageLanguage(language); AndroidJavaObject[] campaigns = new AndroidJavaObject[spCampaigns.Count]; foreach (SpCampaign sp in spCampaigns) { AndroidJavaObject typeAJO = constructor.ConstructCampaignType(sp.CampaignType); AndroidJavaObject[] paramsArray = new AndroidJavaObject[sp.TargetingParams.Count]; foreach (TargetingParam tp in sp.TargetingParams) { AndroidJavaObject param = constructor.ConstructTargetingParam(tp.Key, tp.Value); paramsArray[sp.TargetingParams.IndexOf(tp)] = param; } AndroidJavaObject paramsList = CmpJavaToUnityUtils.ConvertArrayToList(paramsArray); AndroidJavaObject campaign = constructor.ConstructCampaign(typeAJO, paramsList, sp.CampaignType); campaigns[spCampaigns.IndexOf(sp)] = campaign; } AndroidJavaObject spConfig = constructor.ConstructSpConfig(accountId: accountId, propertyName: propertyName, messageTimeout: messageTimeoutMilliSeconds, language: msgLang, campaignsEnvironment: campaignsEnvironment, spCampaigns: campaigns); consentLib = constructor.ConsrtuctLib(spConfig: spConfig, activity: this.activity, spClient: this.spClient); } catch (Exception e) { CmpDebugUtil.LogError(e.Message); } } #endif }
public void LoadMessage(string authId = null) { #if UNITY_ANDROID if (Application.platform == RuntimePlatform.Android) { try { if (string.IsNullOrEmpty(authId)) { RunOnUiThread(delegate { InvokeLoadMessage(); }); } else { RunOnUiThread(delegate { InvokeLoadMessageWithAuthID(authId); }); } } catch (Exception e) { CmpDebugUtil.LogError(e.Message); } } #endif }