Example #1
0
 public InitializationListenerProxy(
     CASMediationManager manager,
     InitCompleteAction initCompleteAction)
     : base(CASJavaProxy.OnInitializationListenerClassName)
 {
     this.manager            = manager;
     this.initCompleteAction = initCompleteAction;
 }
 public static IMediationManager Initialize(
     string managerID,
     AdFlags enableAd = AdFlags.Everything,
     bool testAdMode  = false,
     InitCompleteAction initCompleteAction = null)
 {
     return(BuildManager()
            .WithManagerId(managerID)
            .WithEnabledAdTypes(enableAd)
            .WithTestAdMode(testAdMode)
            .WithInitListener(initCompleteAction)
            .Initialize());
 }
        public static IMediationManager InitializeFromResources(
            int managerIndex = 0,
            AdFlags enableAd = AdFlags.Everything,
            InitCompleteAction initCompleteAction = null)
        {
            var builder = BuildManager()
                          .WithInitListener(initCompleteAction);

            builder.WithEnabledAdTypes(enableAd & builder.allowedAdFlags);
            if (managerIndex > 0)
            {
                builder.WithManagerIdAtIndex(managerIndex);
            }
            return(builder.Initialize());
        }
Example #4
0
 public void onInitialization(bool success, string error)
 {
     if (CASFactory.isDebug)
     {
         Debug.Log("[CleverAdsSolutions] onInitialization " + success);
     }
     manager.initializationListener = null;
     if (initCompleteAction != null)
     {
         CASFactory.ExecuteEvent(() =>
         {
             initCompleteAction(success, error);
             initCompleteAction = null;
         });
     }
 }
        public void CreateManager(CASInitSettings initData)
        {
            _initCompleteAction = initData.initListener;

            CASExterns.CASUSetUnityVersion(Application.unityVersion);

            _managerClient = ( IntPtr )GCHandle.Alloc(this);

            if (initData.extras != null && initData.extras.Count != 0)
            {
                var extrasKeys   = new string[initData.extras.Count];
                var extrasValues = new string[initData.extras.Count];
                int extraI       = 0;
                foreach (var extra in initData.extras)
                {
                    extrasKeys[extraI]   = extra.Key;
                    extrasValues[extraI] = extra.Value;
                    extraI++;
                }
                _managerRef = CASExterns.CASUCreateManagerWithExtras(
                    _managerClient,
                    InitializationCompleteCallback,
                    managerID,
                    ( int )initData.allowedAdFlags,
                    isTestAdMode,
                    extrasKeys,
                    extrasValues,
                    initData.extras.Count
                    );
            }
            else
            {
                _managerRef = CASExterns.CASUCreateManager(
                    _managerClient,
                    InitializationCompleteCallback,
                    managerID,
                    ( int )initData.allowedAdFlags,
                    isTestAdMode
                    );
            }

            CASExterns.CASUSetInterstitialDelegate(_managerRef,
                                                   InterstitialLoadedAdCallback,
                                                   InterstitialFailedAdCallback,
                                                   InterstitialOpeningWithMetaCallback,
                                                   InterstitialDidShowAdFailedWithErrorCallback,
                                                   InterstitialDidClickedAdCallback,
                                                   InterstitialDidClosedAdCallback);

            CASExterns.CASUSetRewardedDelegate(_managerRef,
                                               RewardedLoadedAdCallback,
                                               RewardedFailedAdCallback,
                                               RewardedOpeningWithAdCallbackAndMeta,
                                               RewardedDidShowAdFailedWithErrorCallback,
                                               RewardedDidClickedAdCallback,
                                               RewardedDidCompletedAdCallback,
                                               RewardedDidClosedAdCallback);

            CASExterns.CASUSetAppReturnDelegate(_managerRef,
                                                ReturnAdOpeningWithAdCallback,
                                                ReturnAdDidShowAdFailedWithErrorCallback,
                                                ReturnAdDidClickedAdCallback,
                                                ReturnAdDidClosedAdCallback);
        }
 /// <summary>
 /// Set listener to initialization complete result callback.
 /// </summary>
 public CASInitSettings WithInitListener(InitCompleteAction listener)
 {
     initListener = listener;
     return(this);
 }