Пример #1
0
 public static void Init(AdsConfiguration config, Action <string> onComplete = null)
 {
     if (inst == null)
     {
         DebugLog("AdsRequestHelper.Init()");
         try
         {
             DebugLog("MoPub.InitializeSdk()");
             if (onComplete != null)
             {
                 MoPubManager.OnSdkInitializedEvent += onComplete;
             }
             MoPubBase.SdkConfiguration sdkConfiguration = new MoPubBase.SdkConfiguration {
                 AdUnitId = config.mopubRewarded,
                 LogLevel = MoPubBase.LogLevel.MPLogLevelDebug
             };
             sdkConfiguration.MediatedNetworks = new MoPubBase.MediatedNetwork[] { new MoPubBase.SupportedNetwork.AdMob(), new MoPubBase.SupportedNetwork.AppLovin(), new MoPubBase.SupportedNetwork.Facebook(), new MoPubBase.SupportedNetwork.IronSource(), new MoPubBase.SupportedNetwork.Unity() };
             MoPubAndroid.InitializeSdk(sdkConfiguration);
             DebugLog("MoPub.LoadRewardedVideoPluginsForAdUnits()");
             string[] rewardedVideoAdUnitIds = new string[] { config.mopubRewarded };
             MoPubAndroid.LoadRewardedVideoPluginsForAdUnits(rewardedVideoAdUnitIds);
             Type[]     components = new Type[] { typeof(AdsRequestHelper) };
             GameObject target     = new GameObject("AdsHelperObject", components);
             Object.DontDestroyOnLoad(target);
             inst        = target.GetComponent <AdsRequestHelper>();
             inst.config = config;
         }
         catch (Exception exception)
         {
             Debug.LogException(exception);
         }
     }
 }
Пример #2
0
 private void Start()
 {
     MoPubBase.SdkConfiguration sdkConfiguration = default(MoPubBase.SdkConfiguration);
     sdkConfiguration.AdUnitId       = _interstitialAdUnits[0];
     sdkConfiguration.NetworksToInit = new MoPubBase.RewardedNetwork[9]
     {
         MoPubBase.RewardedNetwork.AdColony,
         MoPubBase.RewardedNetwork.Facebook,
         MoPubBase.RewardedNetwork.Unity,
         MoPubBase.RewardedNetwork.AdMob,
         MoPubBase.RewardedNetwork.AppLovin,
         MoPubBase.RewardedNetwork.Chartboost,
         MoPubBase.RewardedNetwork.IronSource,
         MoPubBase.RewardedNetwork.Tapjoy,
         MoPubBase.RewardedNetwork.Vungle
     };
     sdkConfiguration.AdvancedBidders = new MoPubBase.AdvancedBidder[1]
     {
         MoPubBase.AdvancedBidder.Facebook
     };
     MoPubBase.SdkConfiguration sdkConfiguration2 = sdkConfiguration;
     MoPubAndroid.InitializeSdk(sdkConfiguration2);
     MoPubAndroid.LoadBannerPluginsForAdUnits(_bannerAdUnits);
     MoPubAndroid.LoadInterstitialPluginsForAdUnits(_interstitialAdUnits);
     MoPubAndroid.LoadRewardedVideoPluginsForAdUnits(_rewardedVideoAdUnits);
 }
Пример #3
0
    private void Start()
    {
        string anyAdUnitId = this._bannerAdUnits[0];

        MoPubAndroid.InitializeSdk(anyAdUnitId);
        MoPubAndroid.LoadBannerPluginsForAdUnits(this._bannerAdUnits);
        MoPubAndroid.LoadInterstitialPluginsForAdUnits(this._interstitialAdUnits);
        MoPubAndroid.LoadRewardedVideoPluginsForAdUnits(this._rewardedVideoAdUnits);
        MoPubAndroid.LoadRewardedVideoPluginsForAdUnits(this._rewardedRichMediaAdUnits);
        GameObject gameObject = GameObject.Find("MoPubNativeAds");

        if (gameObject != null)
        {
            gameObject.SetActive(false);
        }
    }
Пример #4
0
    private void Start()
    {
        string str = this._bannerAdUnits[0];

        MoPubBase.SdkConfiguration sdkConfiguration = new MoPubBase.SdkConfiguration {
            AdUnitId         = str,
            LogLevel         = MoPubBase.LogLevel.MPLogLevelDebug,
            MediatedNetworks = new MoPubBase.MediatedNetwork[0]
        };
        MoPubAndroid.InitializeSdk(sdkConfiguration);
        MoPubAndroid.LoadBannerPluginsForAdUnits(this._bannerAdUnits);
        MoPubAndroid.LoadInterstitialPluginsForAdUnits(this._interstitialAdUnits);
        MoPubAndroid.LoadRewardedVideoPluginsForAdUnits(this._rewardedVideoAdUnits);
        MoPubAndroid.LoadRewardedVideoPluginsForAdUnits(this._rewardedRichMediaAdUnits);
        GameObject obj2 = GameObject.Find("MoPubNativeAds");

        if (obj2 != null)
        {
            obj2.SetActive(false);
        }
    }
Пример #5
0
 public void InitializeRewarded(string rewardAdUnit)
 {
     MoPubAndroid.EnableLocationSupport(true);
     if (!string.IsNullOrEmpty(rewardAdUnit))
     {
         try
         {
             this.rewardUnit      = rewardAdUnit;
             this.rewardedEnabled = true;
             this.InternalInit(this.rewardUnit);
             MoPubAndroid.LoadRewardedVideoPluginsForAdUnits(new string[]
             {
                 this.rewardUnit
             });
         }
         catch (Exception ex)
         {
             this.rewardUnit      = null;
             this.rewardedEnabled = false;
             FMLogger.Log("failed to init rewarded. error: " + ex.Message);
         }
     }
 }
Пример #6
0
 public void Initialize(string bAdUnit, BannerPosition bannerPos, string fsAdUnit, string rewardAdUnit)
 {
     MoPubAndroid.EnableLocationSupport(true);
     MoPubManager.OnAdLoadedEvent                        += this.onAdLoadedEvent;
     MoPubManager.OnAdFailedEvent                        += this.onAdFailedEvent;
     MoPubManager.OnAdClickedEvent                       += this.onAdClickedEvent;
     MoPubManager.OnAdExpandedEvent                      += this.onAdExpandedEvent;
     MoPubManager.OnAdCollapsedEvent                     += this.onAdCollapsedEvent;
     MoPubManager.OnInterstitialLoadedEvent              += this.onInterstitialLoadedEvent;
     MoPubManager.OnInterstitialFailedEvent              += this.onInterstitialFailedEvent;
     MoPubManager.OnInterstitialShownEvent               += this.onInterstitialShownEvent;
     MoPubManager.OnInterstitialClickedEvent             += this.onInterstitialClickedEvent;
     MoPubManager.OnInterstitialDismissedEvent           += this.onInterstitialDismissedEvent;
     MoPubManager.OnInterstitialExpiredEvent             += this.onInterstitialExpiredEvent;
     MoPubManager.OnRewardedVideoLoadedEvent             += this.onRewardedVideoLoadedEvent;
     MoPubManager.OnRewardedVideoFailedEvent             += this.onRewardedVideoFailedEvent;
     MoPubManager.OnRewardedVideoExpiredEvent            += this.onRewardedVideoExpiredEvent;
     MoPubManager.OnRewardedVideoShownEvent              += this.onRewardedVideoShownEvent;
     MoPubManager.OnRewardedVideoClickedEvent            += this.onRewardedVideoClickedEvent;
     MoPubManager.OnRewardedVideoFailedToPlayEvent       += this.onRewardedVideoFailedToPlayEvent;
     MoPubManager.OnRewardedVideoReceivedRewardEvent     += this.onRewardedVideoReceivedRewardEvent;
     MoPubManager.OnRewardedVideoClosedEvent             += this.onRewardedVideoClosedEvent;
     MoPubManager.OnRewardedVideoLeavingApplicationEvent += this.onRewardedVideoLeavingApplicationEvent;
     if (!string.IsNullOrEmpty(bAdUnit))
     {
         try
         {
             this.bannerAdUnit   = bAdUnit;
             this.bannerEnabled  = true;
             this.bannerPosition = ((bannerPos != BannerPosition.Bottom) ? MoPubBase.AdPosition.TopCenter : MoPubBase.AdPosition.BottomCenter);
             this.InternalInit(this.bannerAdUnit);
             MoPubAndroid.LoadBannerPluginsForAdUnits(new string[]
             {
                 this.bannerAdUnit
             });
         }
         catch (Exception ex)
         {
             this.bannerEnabled = false;
             FMLogger.vAds("failed to init mopab banner. error: " + ex.Message);
         }
     }
     if (!string.IsNullOrEmpty(fsAdUnit))
     {
         try
         {
             this.interstitialAdUnit = fsAdUnit;
             this.fsEnabled          = true;
             this.InternalInit(this.interstitialAdUnit);
             MoPubAndroid.LoadInterstitialPluginsForAdUnits(new string[]
             {
                 this.interstitialAdUnit
             });
         }
         catch (Exception ex2)
         {
             this.fsEnabled = false;
             FMLogger.vAds("failed to init mopab interstitial. error: " + ex2.Message);
         }
     }
     if (!string.IsNullOrEmpty(rewardAdUnit))
     {
         try
         {
             this.rewardUnit      = rewardAdUnit;
             this.rewardedEnabled = true;
             this.InternalInit(this.rewardUnit);
             MoPubAndroid.LoadRewardedVideoPluginsForAdUnits(new string[]
             {
                 this.rewardUnit
             });
         }
         catch (Exception ex3)
         {
             this.rewardUnit      = null;
             this.rewardedEnabled = false;
             FMLogger.Log("failed to init rewarded. error: " + ex3.Message);
         }
     }
     if (this.bannerEnabled || this.fsEnabled || this.rewardedEnabled)
     {
         ApplovinHelper.InitializeSdk();
     }
     this.RequestBanner();
     this.RequestInterstitial();
 }