Ejemplo n.º 1
0
        private void InitAdContainer()
        {
            ViewModelLocator.Settings.OnAdsMinutesPerDayChanged += SettingsOnOnAdsMinutesPerDayChanged;


            Bindings.Add(this.SetBinding(() => ViewModel.AdsContainerVisibility)
                         .WhenSourceChanges(() =>
            {
                if (ViewModel.AdsContainerVisibility)
                {
                    if (!_initializedAds)
                    {
                        MobileAds.Initialize(ApplicationContext, "ca-app-pub-8220174765620095~3319675764");
                        var adRequest = new AdRequest.Builder().Build();
                        MainPageAdView.LoadAd(adRequest);
                        _initializedAds = true;
                    }
                    MainPageAdView.Visibility = ViewStates.Visible;
                }
                else
                {
                    MainPageAdView.Visibility = ViewStates.Gone;
                }
            }));

            _videoAd = MobileAds.GetRewardedVideoAdInstance(this);
            _videoAd.RewardedVideoAdListener = this;

            StartAdsTimeMeasurements();
        }
Ejemplo n.º 2
0
        private void SetUpViewAndAd()
        {
            if (view != null)
            {
                return;
            }

            view = new View(Xamarin.Forms.Forms.Context);

            var ad = MobileAds.GetRewardedVideoAdInstance(Xamarin.Forms.Forms.Context);

            ad.RewardedVideoAdListener = new RewardedVideoAdListener {
                Ad = ad
            };

            ad.LoadAd("ca-app-pub-3940256099942544/5224354917", new AdRequest.Builder().Build());
            ThreadPool.QueueUserWorkItem(s =>
            {
                // Wait the ad to be loading.
                Thread.Sleep(20000);
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
                {
                    if (ad.IsLoaded)
                    {
                        ad.Show();
                    }
                });
            });
        }
Ejemplo n.º 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            mAdView = FindViewById <AdView> (Resource.Id.adView);
            var adRequest = new AdRequest.Builder().Build();

            mAdView.LoadAd(adRequest);

            mInterstitialAd          = new InterstitialAd(this);
            mInterstitialAd.AdUnitId = GetString(Resource.String.test_interstitial_ad_unit_id);

            mInterstitialAd.AdListener = new AdListener(this);

            mLoadInterstitialButton = FindViewById <Button> (Resource.Id.load_interstitial_button);
            mLoadInterstitialButton.SetOnClickListener(new OnClickListener(this));

            RewardedVideoAd = MobileAds.GetRewardedVideoAdInstance(this);
            RewardedVideoAd.RewardedVideoAdListener = this;
            LoadRewardedVideoAd();

            DisplayVideoButton        = FindViewById <Button>(Resource.Id.DisplayVideoButton);
            DisplayVideoButton.Click += (o, e) =>
            {
                ShowRewardedVideo();
            };
        }
Ejemplo n.º 4
0
        public AdMobAdapter(Activity activity, string appId,
                            string interstitialAdID,
                            string rewardedVideoAdID,
                            string testDeviceID = "",
                            bool childDirected  = false)
        {
            _activity     = activity;
            ChildDirected = childDirected;

            AppID             = appId;
            InterstitialAdID  = interstitialAdID;
            RewardedVideoAdID = rewardedVideoAdID;
            TestDeviceID      = testDeviceID;

            MobileAds.Initialize(_activity, AppID);

            InterstitialAdHandler          = new InterstitialAd(_activity);
            InterstitialAdHandler.AdUnitId = InterstitialAdID;

            interstitialListener             = new InterstitialListener(this);
            InterstitialAdHandler.AdListener = interstitialListener;

            RewardedVideoAdHandler        = MobileAds.GetRewardedVideoAdInstance(_activity);
            RewardedVideoAdHandler.UserId = AppID;

            videoRewardedListener = new RewardedVideoListener(this);
            RewardedVideoAdHandler.RewardedVideoAdListener = videoRewardedListener;
            videoRewardedListener.OnVideoReward           += VideoReward;

            LoadInterstitialAd();
            LoadRewardedVideoAd();
        }
 public AdInterstitial_Droid()
 {
     RewardedVideoAd = MobileAds.GetRewardedVideoAdInstance(Android.App.Application.Context);
     RewardedVideoAd.RewardedVideoAdListener = this;
     //RewardedVideoAd.AdUnitId = "ca-app-pub-2667741859949498/7232000911";
     LoadAd();
 }
Ejemplo n.º 6
0
        public RewardAd(Context context)
        {
            _rewardVideoAd = MobileAds.GetRewardedVideoAdInstance(context);
            _rewardVideoAd.RewardedVideoAdListener = this;

            _currentLoadsCount = 0;
            _completionSource  = new TaskCompletionSource <RewardAdStatus>();
        }
Ejemplo n.º 7
0
        private void AdMobInitialization()
        {
            mInterstitialAd            = new InterstitialAd(this);
            mInterstitialAd.AdUnitId   = "ca-app-pub-8211072909515345/1856723600";
            mInterstitialAd.AdListener = new AdListener(this);

            RewardedVideoAd = MobileAds.GetRewardedVideoAdInstance(this);
            RewardedVideoAd.RewardedVideoAdListener = this;
            LoadRewardedVideoAd();
        }
Ejemplo n.º 8
0
        private void LoadRewardedAd()
        {
            _rewardedVideoAd = MobileAds.GetRewardedVideoAdInstance(this);
            _rewardedVideoAd.RewardedVideoAdListener = this;

            //prod rewarded ad
            _rewardedVideoAd.LoadAd("ca-app-pub-7100837506775638/6637403349", new AdRequest.Builder().Build());

            // test Adunit
            //_rewardedVideoAd.LoadAd("ca-app-pub-3940256099942544/5224354917", new AdRequest.Builder().Build());
        }
Ejemplo n.º 9
0
        public VideoActivity(Action onReward, Action onClose, Action onFailure, string adUnit)
        {
            this.onReward  = onReward;
            this.onClose   = onClose;
            this.onFailure = onFailure;

            rewardedVideoAd = MobileAds.GetRewardedVideoAdInstance(Android.App.Application.Context);
            var adRequest = new AdRequest.Builder().Build();

            rewardedVideoAd.UserId = "pub-1711953563979738";
            rewardedVideoAd.RewardedVideoAdListener = this;
            rewardedVideoAd.LoadAd(adUnit, adRequest);
        }
Ejemplo n.º 10
0
            public void ShowAd(Context context)
            {
                try
                {
                    // Use an activity context to get the rewarded video instance.
                    Rad = MobileAds.GetRewardedVideoAdInstance(context);
                    Rad.RewardedVideoAdListener = this;

                    OnRewardedVideoAdLoaded();
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                }
            }
Ejemplo n.º 11
0
 public void ShowAd(Context context)
 {
     try
     {
         // Use an activity context to get the rewarded video instance.
         Rad        = MobileAds.GetRewardedVideoAdInstance(context);
         Rad.UserId = context.GetString(Resource.String.admob_app_id);
         Rad.RewardedVideoAdListener = this;
         AdRequest adRequest = new AdRequest.Builder().Build();
         Rad.LoadAd(AppSettings.AdRewardVideoKey, adRequest);
     }
     catch (Exception exception)
     {
         Methods.DisplayReportResultTrack(exception);
     }
 }
Ejemplo n.º 12
0
            public void ShowAd(Context context)
            {
                try
                {
                    MobileAds.Initialize(context, Settings.Ad_RewardVideo_Key);

                    // Use an activity context to get the rewarded video instance.
                    Rad = MobileAds.GetRewardedVideoAdInstance(context);
                    Rad.RewardedVideoAdListener = this;

                    OnRewardedVideoAdLoaded();
                }
                catch (Exception exception)
                {
                    Crashes.TrackError(exception);
                }
            }
Ejemplo n.º 13
0
        private void CreateRewardedVideo()
        {
            var context = Application.Context;

            _rewardedAds = MobileAds.GetRewardedVideoAdInstance(context);

            var rewardListener = new MyRewardedVideoAdListener();

            _rewardedAds.RewardedVideoAdListener = rewardListener;

            rewardListener.OnRewardedEvent += RewardListener_OnRewardedEvent;
            rewardListener.OnRewardedVideoAdClosedEvent          += RewardListener_OnRewardedVideoAdClosedEvent;
            rewardListener.OnRewardedVideoAdFailedToLoadEvent    += RewardListener_OnRewardedVideoAdFailedToLoadEvent;
            rewardListener.OnRewardedVideoAdLeftApplicationEvent += RewardListener_OnRewardedVideoAdLeftApplicationEvent;
            rewardListener.OnRewardedVideoAdLoadedEvent          += RewardListener_OnRewardedVideoAdLoadedEvent;
            rewardListener.OnRewardedVideoAdOpenedEvent          += RewardListener_OnRewardedVideoAdOpenedEvent;
            rewardListener.OnRewardedVideoStartedEvent           += RewardListener_OnRewardedVideoStartedEvent;
            rewardListener.OnRewardedVideoCompletedEvent         += RewardListener_OnRewardedVideoCompletedEvent;
        }
Ejemplo n.º 14
0
        public AppSettings(Context context)
        {
            _context = context;
            GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn).RequestEmail().Build();

            _googleApiClient = new GoogleApiClient.Builder(_context)
                               .AddApi(Auth.GOOGLE_SIGN_IN_API, gso)
                               .AddScope(new Scope(Android.Gms.Common.Scopes.Profile))
                               .Build();
            UserData.LoadApplicationSettings(this);
            MobileAds.Initialize(context, AdsApplicationIds); // Ads
            mRewardedVideoAd = MobileAds.GetRewardedVideoAdInstance(context);
            mRewardedVideoAd.RewardedVideoAdListener = new RewardedVideoAdListener(mRewardedVideoAd);
            Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity = context as Activity;
            LocalMusicFolder  = Path.Combine(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryMusic).ToString(), "YoutubeManager");
            Logger            = new Logger(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal));
            UserLocalSettings = FastDeepCloner.DeepCloner.CreateProxyInstance <LocalFileSettings>().ReadSettings(Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "Youtube.Manager.config"));
            UserDialogs.Init(context as MainActivity);
            // Media player
            CrossMediaManager.Current.Init();
        }
Ejemplo n.º 15
0
 public RewardedAd()
 {
     //Set the ad
     videoAd = MobileAds.GetRewardedVideoAdInstance(Android.App.Application.Context);
 }
Ejemplo n.º 16
0
 public void Init(IAdsNotifty adsNotify)
 {
     _adsNotify = adsNotify;
     rewardedAd = MobileAds.GetRewardedVideoAdInstance(Android.App.Application.Context);
     rewardedAd.RewardedVideoAdListener = new AdRewardedView_Droid(_adsNotify);
 }
Ejemplo n.º 17
0
 private void RewardVideoAdInitial()
 {
     SRRewardedVideoAd = MobileAds.GetRewardedVideoAdInstance(this);
     SRRewardedVideoAd.RewardedVideoAdListener = this;
     LoadRewardedVideoAd();
 }