private void LoadAd() { _ad = new InterstitialAd("ca-app-pub-8694775969775805/2188634215"); AdRequest req = new AdRequest(); _ad.LoadAd(req); _ad.ReceivedAd += AdView_ReceivedAd; _ad.FailedToReceiveAd += AdView_FailedToReceiveAd; }
private void Ad_GoogleMob_Interstitial() { _inter = new InterstitialAd("ca-app-pub-8694775969775805/8881111019"); AdRequest _adrequest = new AdRequest(); _adrequest.ForceTesting = true; _inter.ReceivedAd += _inter_ReceivedAd; _inter.FailedToReceiveAd += _inter_FailedToReceiveAd; _inter.LoadAd(_adrequest); }
private void OnRequestInterstitialClick() { // NOTE: Edit "UA-51287516-7" with your interstitial // ad unit id. interstitialAd = new InterstitialAd("ca-app-pub-9908242075575541/9823166712"); // NOTE: You can edit the event handler to do something custom here. Once the // interstitial is received it can be shown whenever you want. AdRequest adRequest = new AdRequest(); adRequest.ForceTesting = false; interstitialAd.LoadAd(adRequest); }
public void Show(string adUnit) { var context = Application.Context; _ad = new InterstitialAd(context); _ad.AdUnitId = adUnit; var intlistener = new InterstitialAdListener(_ad); intlistener.OnAdLoaded(); _ad.AdListener = intlistener; var requestbuilder = new AdRequest.Builder(); _ad.LoadAd(requestbuilder.Build()); }
/// <summary> /// Sends out a request to load an interstitial. Note that testMode doesn't yet work in the AdMob SDK. /// </summary> /// <param name="adUnitId"></param> /// <param name="enableTestMode"></param> public static void LoadInterstitial(string adUnitId, bool enableTestMode = false) { interstitialAdUnit = adUnitId; interstitialAd = new InterstitialAd(adUnitId); interstitialAd.DismissingOverlay += (o, a) => InterstitialAdOnDismissingOverlay(o, a, interstitialAdUnit); interstitialAd.FailedToReceiveAd += (o, a) => InterstitialAdOnFailedToReceiveAd(o, a, interstitialAdUnit); interstitialAd.LeavingApplication += (o, a) => InterstitialAdOnLeavingApplication(o, a, interstitialAdUnit); interstitialAd.ReceivedAd += (o, a) => InterstitialAdOnReceivedAd(o, a, interstitialAdUnit); interstitialAd.ShowingOverlay += (o, a) => InterstitialAdOnShowingOverlay(o, a, interstitialAdUnit); var adRequest = new AdRequest { ForceTesting = enableTestMode }; interstitialAd.LoadAd(adRequest); }
private void OnRequestInterstitialClick(object sender, EventArgs e) { // NOTE: Edit "MY_AD_UNIT_ID" with your interstitial // ad unit id. interstitialAd = new InterstitialAd("MY_AD_UNIT_ID"); // NOTE: You can edit the event handler to do something custom here. Once the // interstitial is received it can be shown whenever you want. interstitialAd.ReceivedAd += OnAdReceived; interstitialAd.FailedToReceiveAd += OnFailedToReceiveAd; interstitialAd.DismissingOverlay += OnDismissingOverlay; AdRequest adRequest = new AdRequest(); adRequest.ForceTesting = true; interstitialAd.LoadAd(adRequest); showInterstitial.IsEnabled = false; }
//reklam hazırlama private void OnRequestInterstitialClick() { // NOTE: Edit "MY_AD_UNIT_ID" with your interstitial // ad unit id. interstitialAd = new InterstitialAd("ca-app-pub-9952422283209342/4928163069"); // NOTE: You can edit the event handler to do something custom here. Once the // interstitial is received it can be shown whenever you want. AdRequest adRequest = new AdRequest(); adRequest.ForceTesting = false; interstitialAd.LoadAd(adRequest); interstitialAd.ReceivedAd += İnterstitialAd_ReceivedAd; }
private void RequestInterstitial() { #if UNITY_ANDROID string adUnitId = "ca-app-pub-3270795222614514/2236020819"; #elif UNITY_IPHONE string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE"; #else string adUnitId = "unexpected_platform"; #endif // Initialize an InterstitialAd. interstitial = new InterstitialAd(adUnitId); // Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the interstitial with the request. interstitial.LoadAd(request); }
public void LoadAd() { // Request var requestBuilder = new AdRequest.Builder(); // 20E75139BBF24DC580420774CC012DCD //20949F1881259988F94C570F5D49D8E9 //.addTestDevice("1FFA91E56002E80EC2232FD6A6053E5B") requestBuilder.AddTestDevice("253DD8B545DDC577263C615CE187A856"); requestBuilder.AddTestDevice("9AC63F0BB5D8E04512D0A4ED0202C018"); requestBuilder.AddTestDevice("17F5056C2003A19B27CF2896B7BE699D"); requestBuilder.AddTestDevice("20E75139BBF24DC580420774CC012DCD"); requestBuilder.AddTestDevice("20949F1881259988F94C570F5D49D8E9"); requestBuilder.AddTestDevice("1FFA91E56002E80EC2232FD6A6053E5B"); requestBuilder.AddTestDevice("2A26CA09A9309EE2CCDA1B239A1472D1"); _interstitialAd.LoadAd(requestBuilder.Build()); }
public void RequestInterstitial() { // Request a banner ad, with optional custom ad targeting. AdRequest request = new AdRequest.Builder() // .AddTestDevice(AdRequest.TestDeviceSimulator) .AddTestDevice("A431B6F2AB563BE62EAC8CBB5ECCD43F") // Mark S2 .AddTestDevice("6e2d8b66674d9ef3225b90cb584e5975") .AddTestDevice("C359AF1E66C7AFFCC94663B0EEF0D544") // Galaxy Alpha .AddKeyword("game") .SetGender(Gender.Male) .SetBirthday(new System.DateTime(1985, 1, 1)) .TagForChildDirectedTreatment(TagForChildDirectedTreatment) .AddExtra("color_bg", "9B30FF") .Build(); _interstitialAd.LoadAd(request); }
private void RequestInterstitial() { #if UNITY_ANDROID string adUnitId = interstitialIdAndroid; #elif UNITY_IPHONE string adUnitId = interstitialIdIOS; #else string adUnitId = "unexpected_platform"; #endif // Initialize an InterstitialAd. interstitial = new InterstitialAd(adUnitId); // Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the interstitial with the request. interstitial.LoadAd(request); }
private void RequestInterstitial() { #if UNITY_ANDROID string adUnitId = "ca-app-pub-3840620948536981/4605268153"; #elif UNITY_IPHONE string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE"; #else string adUnitId = "ca-app-pub-3840620948536981/4605268153"; #endif // Initialize an InterstitialAd. InterstitialAd interstitial = new InterstitialAd(adUnitId); // Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the interstitial with the request. interstitial.LoadAd(request); }
public void RequestInterstitial() { #if UNITY_ANDROID string adUnitId = "ca-app-pub-3940256099942544/1033173712"; #elif UNITY_IPHONE string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE"; #else string adUnitId = "unexpected_platform"; #endif // Initialize an InterstitialAd. interstitial = new InterstitialAd(adUnitId); // Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the interstitial with the request. interstitial.LoadAd(request); }
private InterstitialAd RequestInterstitial() { #if UNITY_ANDROID string adUnitId = "PRIVATE KEY"; #elif UNITY_IPHONE string adUnitId = "PRIVATE KEY"; #else string adUnitId = "unexpected_platform"; #endif // Initialize an InterstitialAd. InterstitialAd intAD = new InterstitialAd(adUnitId); // Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the interstitial with the request. intAD.LoadAd(request); return(intAD); }
private void RequestInterstitial() { #if UNITY_ANDROID string adUnitId = Interstitial_ID; #elif UNITY_IPHONE string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE"; #else string adUnitId = "unexpected_platform"; #endif SceneHandler.GetInstance().DebugLog("Request Interstitial"); interstitial = new InterstitialAd(adUnitId); AdRequest request = new AdRequest.Builder().Build(); // interstitial.OnAdLoaded += InterstitilLoaded; // interstitial.OnAdClosed += InterstitilClosed; interstitial.LoadAd(request); }
private void RequestInterstitialAd() { string adUnitId = string.Empty; #if UNITY_ANDROID adUnitId = android_interstitial_id; #elif UNITY_IOS adUnitId = ios_interstitialAdUnitId; #endif interstitialAd = new InterstitialAd(adUnitId); AdRequest request = new AdRequest.Builder().Build(); interstitialAd.LoadAd(request); interstitialAd.OnAdClosed += HandleOnInterstitialAdClosed; }
public void RequestInterstial() { // myreal ca-app-pub-3487858250679116/8642271885 string insterstitialid = "ca-app-pub-3487858250679116/8642271885"; // test ca-app-pub-3940256099942544/1033173712 if (interstitial != null) { interstitial.Destroy(); } interstitial = new InterstitialAd(insterstitialid); interstitial.OnAdLoaded += HandleOnAdLoaded; interstitial.LoadAd(CreateNewRequest()); }
// Admob interstitial ads fuctions public void initAdmobInterstitial() { if (PlayerPrefs.GetInt("Removeads", 0) == 0) { myInterstitialAd = new InterstitialAd(InterstitialAdID); AdRequest request = new AdRequest.Builder().Build(); myInterstitialAd.LoadAd(request); myInterstitialAd.OnAdClosed += admobClosed; myInterstitialAd.OnAdLoaded += delegate(object sender, EventArgs args) { if (showAdmobInsterstitial) { showAdmobInsterstitial = false; myInterstitialAd.Show(); } }; } }
private void RequestInterstitial() { #if UNITY_EDITOR string adUnitId = "unused"; #elif UNITY_ANDROID string adUnitId = "ca-app-pub-1991895393724672/8186664146"; #elif UNITY_IPHONE string adUnitId = "INSERT_IOS_BANNER_AD_UNIT_ID_HERE"; #else string adUnitId = "unexpected_platform"; #endif interstitial = new InterstitialAd(adUnitId); interstitial.AdFailedToLoad += HandleAdFailedToLoad; interstitial.LoadAd(createAdRequest()); }
void RequestInterstitial() { #if UNITY_ANDROID string interstitialID = "ca-app-pub-3940256099942544/1033173712"; #else string interstitialID = "unexpected_platform"; #endif interstitialAd = new InterstitialAd(interstitialID); HandleinterstitialAdEvents(true); AdRequest adRequest = new AdRequest.Builder() //.AddTestDevice("33BE2250B43518CCDA7DE426D04EE231") .Build(); interstitialAd.LoadAd(adRequest); }
private void RequestInterstitial() { #if UNITY_ANDROID string adUnitId = InterstitialId; #elif UNITY_IPHONE string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE"; #else string adUnitId = "unexpected_platform"; #endif // SceneHandler.GetInstance().DebugLog("Interstitial Request ..."); // Initialize an InterstitialAd. interstitial = new InterstitialAd(adUnitId); // Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the interstitial with the request. interstitial.LoadAd(request); }
void Start() { MobileAds.Initialize(AppID); interstitialAd = new InterstitialAd(InterstitialAdUnitID); interstitialAd.LoadAd(new AdRequest.Builder().Build()); // Called when an ad request has successfully loaded. this.interstitialAd.OnAdLoaded += HandleOnAdLoaded; // Called when an ad request failed to load. this.interstitialAd.OnAdFailedToLoad += HandleOnAdFailedToLoad; // Called when an ad is shown. this.interstitialAd.OnAdOpening += HandleOnAdOpened; // Called when the ad is closed. this.interstitialAd.OnAdClosed += HandleOnAdClosed; // Called when the ad click caused the user to leave the application. this.interstitialAd.OnAdLeavingApplication += HandleOnAdLeavingApplication; }
void MakeNewInterstial() { #if UNITY_ANDROID interstitial = new InterstitialAd(AdmobID_Android); #endif #if UNITY_IPHONE interstitial = new InterstitialAd(AdmobID_IOS); #endif Debug.Log("AdMob ID: " + AdmobID_Android); interstitial.OnAdClosed += HandleInterstialAdClosed; interstitial.OnAdFailedToLoad += HandleOnAdFailedToLoad; AdRequest request = new AdRequest.Builder() .AddTestDevice(AdRequest.TestDeviceSimulator) .AddTestDevice("357513062042313") .Build(); interstitial.LoadAd(request); Debug.Log("Ad Loaded"); }
/* <Interstital Ad>*/ public void ShowInterstitalAd() { request = new AdRequest.Builder().Build(); interstitalAd.LoadAd(request); if (interstitalAd.IsLoaded()) { interstitalLoaded = true; interstitalAd.Show(); print("Loaded and showed Interstital Ad"); } else { print("Not ready yet"); } interstitalAd.OnAdClosed += InterstitalAd_OnAdClosed; }
public void PrepareInterstital() { #if UNITY_ANDROID // string adUnitId = "ca-app-pub-3940256099942544/1033173712"; // TEST string adUnitId = "ca-app-pub-2228911308495304/1226106249"; // LIVE #elif UNITY_IPHONE // string adUnitId = "ca-app-pub-3940256099942544/4411468910"; // TEST string adUnitId = "ca-app-pub-2228911308495304/9914731582"; // LIVE #else string adUnitId = "unexpected_platform"; #endif // Initialize an InterstitialAd. interstitial = new InterstitialAd(adUnitId); // Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the interstitial with the request. interstitial.LoadAd(request); }
public void RequestInterstitial() { #if UNITY_ANDROID string adUnitId = "ca-app-pub-1598053448886416/7127302011"; #elif UNITY_IPHONE string adUnitId = "ca-app-pub-3940256099942544/4411468910"; #else string adUnitId = "unexpected_platform"; #endif // Initialize an InterstitialAd. interstitial = new InterstitialAd(adUnitId); // Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the interstitial with the request. interstitial.LoadAd(request); }
private void RequestInterstitial() { interstitial = new InterstitialAd(interstitialID); // Called when an ad request has successfully loaded. interstitial.OnAdLoaded += HandleOnAdLoaded; // Called when an ad request failed to load. interstitial.OnAdFailedToLoad += HandleOnAdFailedToLoad; // Called when an ad is shown. interstitial.OnAdOpening += HandleOnAdOpened; // Called when the ad is closed. interstitial.OnAdClosed += HandleOnAdClosed; // Called when the ad click caused the user to leave the application. interstitial.OnAdLeavingApplication += HandleOnAdLeavingApplication; AdRequest request = new AdRequest.Builder().Build(); interstitial.LoadAd(request); }
void Start() { if (PlayerPrefs.GetInt("ads_enabled") == 0 && PlayerPrefs.GetInt("partidas__jugadas") >= 3) { if (Application.loadedLevelName == "menu") { bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Top); AdRequest request = new AdRequest.Builder().Build(); bannerView.LoadAd(request); } interstitial = new InterstitialAd("ca-app-pub-5148252281838435/5983205100"); AdRequest request2 = new AdRequest.Builder().Build(); // Load the interstitial with the request. interstitial.LoadAd(request2); } DontDestroyOnLoad(this.gameObject); }
public void RequestInterstitialAd() { string str = ""; #if UNITY_ANDROID str = and_inter; #elif UNITY_IOS str = ios_inter; #endif inter = new InterstitialAd(str); AdRequest.Builder builder = new AdRequest.Builder(); AdRequest req = builder.AddTestDevice(AdRequest.TestDeviceSimulator).AddTestDevice("3FB7AE355826BE23").Build(); //AdRequest req = builder.Build(); inter.LoadAd(req); inter.OnAdClosed += EventAdClose; }
// Use this for initialization void Start() { // Create a 320x50 banner at the top of the screen. BannerView bannerView = new BannerView(smallBanerID, AdSize.Banner, AdPosition.Bottom); // Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the banner with the request. bannerView.LoadAd(request); // Initialize an InterstitialAd. interstitial = new InterstitialAd(interestialID); // Create an empty ad request. AdRequest requestIner = new AdRequest.Builder().Build(); // Load the interstitial with the request. interstitial.LoadAd(requestIner); }
private void BuildInterstitial () { #if UNITY_ANDROID //TODO change from test ads to production //string adUnitId = "ca-app-pub-6843199568696689/8160607342"; string adUnitId = "ca-app-pub-3940256099942544/1033173712"; #elif UNITY_IOS string adUnitId = ""; #else string adUnitId = "unexpected-platform; #endif interAd = new InterstitialAd(adUnitId); interAd.OnAdClosed += DestroyInterstitial; interAd.OnAdFailedToLoad += OnFailedToLoad; AdRequest request = new AdRequest.Builder().Build(); interAd.LoadAd(request); }
public void GecisReklam() { Debug.Log("Gecis Reklam= tam ekran"); kontrol_metni.text = "Gecis reklam= tam ekran "; gecisReklam = new InterstitialAd(interstitialID); gecisReklam.OnAdClosed += InterstitialClosed; AdRequest yeniReklam = new AdRequest.Builder().Build(); kontrol_metni.text = "Gecis reklam= tam ekran request "; Debug.Log("Gecis Reklam= tam ekran request"); gecisReklam.LoadAd(yeniReklam); kontrol_metni.text = "Gecis reklam= tam ekran gosterildi"; Debug.Log("Gecis Reklam= tam ekran gosterildi"); }
private void RequestInterstitial() { #if UNITY_ANDROID string adUnitId = "ca-app-pub-3713536706122475/7789478341"; #else string adUnitId = "unexpected_platform"; #endif // Initialize an InterstitialAd. interstitial = new InterstitialAd(adUnitId); // Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the interstitial with the request. interstitial.LoadAd(request); // Called when the ad is closed. interstitial.OnAdClosed += HandleOnAdClosed; }
public void RequestInterstitialAd() { string adUnitId = string.Empty; #if UNITY_ANDROID adUnitId = android_interstitial_id; #elif UNITY_IOS adUnitId = ios_interstitialAdUnitId; #endif interstitialAd = new InterstitialAd(adUnitId); //AdRequest request = new AdRequest.Builder().AddTestDevice(AdRequest.TestDeviceSimulator).AddTestDevice("4FB88470E3887CDA").Build(); AdRequest request = new AdRequest.Builder().Build(); interstitialAd.LoadAd(request); interstitialAd.OnAdClosed += HandleOnInterstitialAdClosed; }
private void RequestInterstitial() { #if UNITY_ANDROID string adUnitId = AndroidInterstitialID; #elif UNITY_IPHONE string adUnitId = IOSInterstitialID; #else string adUnitId = "unexpected_platform"; #endif // Initialize an InterstitialAd. interstitial = new InterstitialAd(adUnitId); interstitial.OnAdClosed += HandleEventHandler1; // Create an empty ad request. request = new AdRequest.Builder().Build(); // Load the interstitial with the request. interstitial.LoadAd(request); }
public void RequestInterstitial() { #if UNITY_ANDROID string adUnitId = "ca-app-pub-9394422553721458/5922252324"; #elif UNITY_IPHONE string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE"; #else string adUnitId = "unexpected_platform"; #endif // Initialize an InterstitialAd. interstitial = new InterstitialAd(adUnitId); // Create an empty ad request. AdRequest request = new AdRequest.Builder().Build(); // Load the interstitial with the request. interstitial.LoadAd(request); interstitial.OnAdLoaded += Show; }
void RequestInterstitial() { if (testMode) { interstitial = new InterstitialAd(Android_Admob_Interstitial_ID); } else { interstitial = new InterstitialAd(Android_Admob_Interstitial_ID_Real); } request = new AdRequest.Builder().Build(); interstitial.LoadAd(request); interstitial.OnAdClosed += HandleOnAdClosed; }
public void AddInterstitialAd(string adUnitID) { try { const string product = "productRemoveAds"; if (!settings.Contains(product)) { interstitialAd = new InterstitialAd(adUnitID); AdRequest adRequest = new AdRequest(); adRequest.ForceTesting = true; interstitialAd.DismissingOverlay += OnDismissingOverlay; interstitialAd.ReceivedAd += OnAdReceived; interstitialAd.LoadAd(adRequest); } } catch (Exception ex) { } }
public Task Show(Action OnPresented = null) { if (showTask != null) { showTask.TrySetResult(false); showTask.TrySetCanceled(); } else { showTask = new TaskCompletionSource<bool>(); } AdInterstitial = new InterstitialAd(Xamarin.Forms.Forms.Context); AdInterstitial.AdUnitId = CrossAdmobManager.AdmobKey; var intlistener = new AdInterstitialListener(AdInterstitial); intlistener.AdLoaded = () => { OnPresented?.Invoke(); }; intlistener.AdClosed = () => { if (showTask != null) { showTask.TrySetResult(AdInterstitial.IsLoaded); showTask = null; } }; intlistener.AdFailed = () => { OnPresented?.Invoke(); if (showTask != null) { showTask.TrySetResult(AdInterstitial.IsLoaded); showTask = null; } }; //intlistener.OnAdLoaded(); AdInterstitial.AdListener = intlistener; AdInterstitial.LoadAd(requestBuilder.Build()); return Task.WhenAll(showTask.Task); }
void AdmobFullAdsShow() { // if (interstitialAd == null) { interstitialAd = new InterstitialAd("ca-app-pub-7413680112188055/5907404528");//hoangcaoagia interstitialAd.ReceivedAd += OnAdReceivedFull; interstitialAd.FailedToReceiveAd += OnFailedToReceiveAdFull; } //adRequest.ForceTesting = true;//here to rem interstitialAd.LoadAd(adRequest); }
void AdmobFullAdsShow() { // if (interstitialAd == null) { interstitialAd = new InterstitialAd("ca-app-pub-6844968633010430/3066015502");//mobilewp8 interstitialAd.ReceivedAd += OnAdReceivedFull; interstitialAd.FailedToReceiveAd += OnFailedToReceiveAdFull; } //adRequest.ForceTesting = true;//here to rem interstitialAd.LoadAd(adRequest); }
/// <summary> /// Displays Ads according to input from the JSON object /// </summary> /// <param name="parameters"></param> private async void AdmobAction(String parameters) { try { if (parameters != null) { System.Windows.VerticalAlignment verticalposition = System.Windows.VerticalAlignment.Top; System.Windows.HorizontalAlignment horizontalposition = System.Windows.HorizontalAlignment.Left; AdFormats adformat = AdFormats.Banner; screenwidth = Application.Current.Host.Content.ActualWidth; screenheight = Application.Current.Host.Content.ActualHeight; JObject optionsJson = JObject.Parse(parameters); if (optionsJson != null) { JToken argsJson = optionsJson["args"]; if (argsJson != null) { string adUnitId = string.Empty; string adSize = string.Empty; string adPosition = string.Empty; string callback = string.Empty; string gender = string.Empty; JToken adUnitIdJToken = null; adUnitIdJToken = argsJson["adUnitId"]; if (adUnitIdJToken != null) adUnitId = (adUnitIdJToken as JValue).Value.ToString(); JToken admarginsJToken = argsJson["margins"]; admargins = admarginsJToken; JToken adSizeJToken = null; adSizeJToken = argsJson["adSize"]; if (adSizeJToken != null) { adSize = (adSizeJToken as JValue).Value.ToString().ToUpper(); if (adSize != "INTERSTITIAL") { #region Standard banner and Smart banner switch (adSize) { case "BANNER": adformat = AdFormats.Banner; validationofStandardBannerMargin(); break; case "SMART_BANNER": adformat = AdFormats.SmartBanner; validationofSmartBannerMargin(); break; } JToken adPositionJToken = argsJson["adPosition"]; if (adPositionJToken != null) { adPosition = (adPositionJToken as JValue).Value.ToString(); char[] delimiterChars = { '_' }; string[] Positions = adPosition.Split(delimiterChars); if (Positions.Count() > 0) { switch (Positions[0].ToLower()) { case "top": verticalposition = System.Windows.VerticalAlignment.Top; break; case "bottom": verticalposition = System.Windows.VerticalAlignment.Bottom; break; case "center": verticalposition = System.Windows.VerticalAlignment.Center; break; case "stretch": verticalposition = System.Windows.VerticalAlignment.Stretch; break; default: verticalposition = System.Windows.VerticalAlignment.Top; break; } } if (Positions.Count() > 1) { switch (Positions[1].ToLower()) { case "left": horizontalposition = System.Windows.HorizontalAlignment.Left; break; case "right": horizontalposition = System.Windows.HorizontalAlignment.Right; break; case "center": horizontalposition = System.Windows.HorizontalAlignment.Center; break; case "stretch": horizontalposition = System.Windows.HorizontalAlignment.Stretch; break; default: horizontalposition = System.Windows.HorizontalAlignment.Left; break; } } } JToken callbackJToken = argsJson["callback"]; if (callbackJToken != null) callback = (callbackJToken as JValue).Value.ToString(); AdGrid = new Grid(); AdView bannerAd = new AdView { Format = adformat, AdUnitID = adUnitId, VerticalAlignment = verticalposition, HorizontalAlignment = horizontalposition, Margin = new Thickness(leftmagin, topmagin, rightmagin, bottommagin), }; AdRequest adRequest = new AdRequest(); JToken targetingJToken = argsJson["targeting"]; if (targetingJToken != null) { JToken locationJToken = targetingJToken["location"]; JToken xJToken = locationJToken["x"]; string x = (xJToken as JValue).Value.ToString(); JToken yJToken = locationJToken["y"]; string y = (yJToken as JValue).Value.ToString(); Geolocator geolocator = new Geolocator(); geolocator.DesiredAccuracyInMeters = 1; Geoposition geoposition = await geolocator.GetGeopositionAsync( TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(10)); adRequest.Location = geoposition.Coordinate; JToken genderJToken = targetingJToken["gender"]; if (genderJToken != null) gender = (genderJToken as JValue).Value.ToString(); if (gender.ToLower() == "male") adRequest.Gender = UserGender.Male; else if (gender.ToLower() == "female") adRequest.Gender = UserGender.Female; JToken birthdayJToken = targetingJToken["birthday"]; string birthday = (birthdayJToken as JValue).Value.ToString(); double unixTimeStamp = Convert.ToDouble(birthday); System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc); adRequest.Birthday = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime(); } adRequest.ForceTesting = true; // Enable test ads AdGrid.Children.Add(bannerAd); bannerAd.LoadAd(adRequest); this.ApplicationFrame.Content = AdGrid; #endregion } else { #region Interstitial Banner JToken callbackJToken = argsJson["callback"]; if (callbackJToken != null) callback = (callbackJToken as JValue).Value.ToString(); interstitialAd = new InterstitialAd(adUnitId); AdRequest interstitialadRequest = new AdRequest(); JToken targetingJToken = argsJson["targeting"]; if (targetingJToken != null) { JToken locationJToken = targetingJToken["location"]; JToken xJToken = locationJToken["x"]; string x = (xJToken as JValue).Value.ToString(); JToken yJToken = locationJToken["y"]; string y = (yJToken as JValue).Value.ToString(); Geolocator geolocator = new Geolocator(); JToken accuracyJToken = targetingJToken["accuracy"]; string accuracy = (accuracyJToken as JValue).Value.ToString(); if (string.IsNullOrEmpty(accuracy)) geolocator.DesiredAccuracyInMeters = 1; else geolocator.DesiredAccuracyInMeters = Convert.ToUInt32(accuracy, 16); Geoposition geoposition = await geolocator.GetGeopositionAsync( TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(10)); interstitialadRequest.Location = geoposition.Coordinate; JToken genderJToken = targetingJToken["gender"]; if (genderJToken != null) gender = (genderJToken as JValue).Value.ToString(); if (gender.ToLower() == "male") interstitialadRequest.Gender = UserGender.Male; else if (gender.ToLower() == "female") interstitialadRequest.Gender = UserGender.Female; JToken birthdayJToken = targetingJToken["birthday"]; string birthday = (birthdayJToken as JValue).Value.ToString(); double unixTimeStamp = Convert.ToDouble(birthday); System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc); interstitialadRequest.Birthday = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime(); } interstitialadRequest.ForceTesting = true;// Enable test ads interstitialAd.ReceivedAd += OnAdReceived; interstitialAd.FailedToReceiveAd += OnFailedToReceiveAd; interstitialAd.LoadAd(interstitialadRequest); #endregion } } } } } } catch (Exception e) { e.ToString(); System.Diagnostics.Debugger.Break(); } }
void prepareInterstitial(string unit_id) { try{ Deployment.Current.Dispatcher.BeginInvoke(() => { try{ lock (_interstitial_lock) { if (_interstitial == null) { _interstitial = new InterstitialAd(unit_id); AdRequest adRequest = new AdRequest(); _interstitial_loaded = false; _interstitial.ReceivedAd += OnAdReceived; _interstitial.LoadAd(adRequest); } } } catch (Exception e){} }); } catch (Exception e){} }
protected override void OnCreate(Bundle bundle) { try { base.OnCreate (bundle); RPSArcadeGame.Activity = this; currentGame = new RPSArcadeGame (); FrameLayout fl = new FrameLayout (this); LinearLayout ll = new LinearLayout (this); ll.Orientation = Orientation.Vertical; ll.SetGravity (GravityFlags.Top); fl.AddView (currentGame.Window); adView = new AdView (this, AdSize.Banner, "ca-app-pub-3805641000844271/9009097745"); ll.AddView (adView); fl.AddView (ll); SetContentView (fl); AdRequest adRequest = new AdRequest (); #if DEBUG adRequest.SetTesting (true); adRequest.AddTestDevice (AdRequest.TestEmulator); #endif adView.LoadAd (adRequest); interstitialAd = new InterstitialAd (this, "ca-app-pub-3805641000844271/7877114945"); AdRequest adRequest2 = new AdRequest (); #if DEBUG adRequest2.SetTesting (true); adRequest2.AddTestDevice (AdRequest.TestEmulator); #endif interstitialAd.LoadAd (adRequest2); interstitialAd.DismissScreen += (sender, e) => FullAdOn = false; currentGame.Run (); } catch (Exception e) { NotifyViaToast (e.Message); } }
protected void loadinterstitialAd() { //if (interstitialView == null) //need to comment on wp8 //{ //interstitialView = new InterstitialAd("ca-app-pub-4906074177432504/4879304879");//x cf) wp8 //interstitialView = new InterstitialAd("ca-app-pub-4906074177432504/5150650074");//o cf) android interstitialView = new InterstitialAd(this.interstitialAdUnit); //http://forums.xamarin.com/discussion/849/binding-library-for-inneractive-sdk interstitialView.ReceivedAd += interstitialView_ReceivedAd; interstitialView.FailedToReceiveAd += interstitialView_FailedToReceiveAd; interstitialView.ShowingOverlay += interstitialView_ShowingOverlay; interstitialView.DismissingOverlay += interstitialView_DismissingOverlay; //} AdRequest adRequest = new AdRequest(); if(isTest) { adRequest.ForceTesting = true; } interstitialView.LoadAd(adRequest); }
void LoadBillboard() { interstitialAd = new InterstitialAd("ca-app-pub-7103992668654583/8183469755"); interstitialAd.ReceivedAd += interstitialAd_ReceivedAd; interstitialAd.FailedToReceiveAd += interstitialAd_FailedToReceiveAd; AdRequest adRequest = new AdRequest(); interstitialAd.LoadAd(adRequest); }
protected void __prepareInterstitial(string adId, Boolean autoShow) { if (isTesting) adId = TEST_INTERSTITIAL_ID; if (adId && (adId.Length > 0)) { interstitialId = adId; } else { adId = interstitialId; } autoShowInterstitial = autoShow; // Asynchronous UI threading call Deployment.Current.Dispatcher.BeginInvoke(() => { interstitialAd = new InterstitialAd( interstitialId ); // Add event listeners interstitialAd.ReceivedAd += interstitial_onAdLoaded; interstitialAd.FailedToReceiveAd += interstitial_onAdFailLoad; interstitialAd.ShowingOverlay += interstitial_onAdPresent; interstitialAd.DismissingOverlay += interstitial_onAdDismiss; AdRequest adRequest = new AdRequest(); adRequest.ForceTesting = isTesting; interstitialAd.LoadAd(adRequest); }); }