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);
        }
Example #2
0
        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
        }