public void BuildInterstitial(){ failedLoading = false; interstitial = new InterstitialAd(adUnitID); // Events interstitial.OnAdClosed += HandleInterstitialClosed; interstitial.OnAdFailedToLoad += HandleInterstitialFailedToLoad; interstitial.OnAdLeavingApplication += HandleLeftApplication; interstitial.OnAdLoaded += HandleLoaded; interstitial.OnAdOpening += HandleOpened; // AdRequest AdRequest.Builder builder = new AdRequest.Builder (); if (useEmulatorAsATestDevice) { builder.AddTestDevice(AdRequest.TestDeviceSimulator); } if (testDeviceIDs != null && testDeviceIDs.Length > 0) { foreach(string testDeviceID in testDeviceIDs){ builder.AddTestDevice(testDeviceID); } } if (keywords != null && keywords.Length > 0) { foreach (string keyword in keywords) { builder.AddKeyword (keyword); } } if (gender.HasValue) { builder.SetGender (gender.Value); } if (childDirectedTreatment.HasValue) { builder.TagForChildDirectedTreatment (childDirectedTreatment.Value); } AdRequest request = builder.Build(); interstitial.LoadAd(request); }
// Use this for initialization void Start() { // 초기화 // 앱아이디, 배너 사이즈, 배너 위치 m_BannerView = new BannerView("ca-app-pub-3215701313685151/6171564220", AdSize.SmartBanner, AdPosition.Bottom); // 전면광고 m_InterstitialAd = new InterstitialAd("ca-app-pub-3215701313685151/7648297427"); // 테스트 단말기 등록 // AdRequest.Builder adBuilder = new AdRequest.Builder(); // 테스트기기가 많으면 .AddTestDevice(""). 으로 계속 추가 AdRequest adRequst = adBuilder.AddTestDevice("3AEB4134537BE358").AddTestDevice(AdRequest.TestDeviceSimulator).Build(); // 광고 요청 m_BannerView.LoadAd(adRequst); // 광고 출력 m_BannerView.Show(); // 광고 요청 m_InterstitialAd.LoadAd(adRequst); // 이벤트 종료후 callback함수 호출 추가 m_InterstitialAd.AdClosed += AdCloseCallback; }
private AdRequest CreateAdRequest() { // リクエストの生成 // テスト端末設定があった場合は取得 var builder = new AdRequest.Builder (); builder.AddTestDevice (AdRequest.TestDeviceSimulator); if (Android_TestDevices != null) { foreach(var str in Android_TestDevices){ builder.AddTestDevice(str);//MyAndroid } } return builder.Build (); }
void Start() { if (bannerView == null) { // BannerView(애드몹 사이트에 등록된 아이디, 크기, 위치) / AdSize.SmartBanner : 화면 해상도에 맞게 늘임, AdPosition.Bottom : 화면 바닥에 붙음 bannerView = new BannerView("ca-app-pub-5905358959749177/1254674846", AdSize.SmartBanner, AdPosition.Bottom); //서버 광고 요청 AdRequest.Builder builder = new AdRequest.Builder(); // 테스트 디바이스 등록 ( 테스트 디바이스에서는 결제가 안된다 ) // request 요청 정보를 담는다. AdRequest request = builder.AddTestDevice(AdRequest.TestDeviceSimulator).AddTestDevice("D8A7E633E004B1E5").Build(); //3D005AAC7FC7C0C5 : 디바이스 아이디 //AdRequest request = builder.Build();// 실제 빌드 bannerView.LoadAd(request); //배너 광고 요청 } if (bannerOn) bannerView.Show(); else bannerView.Hide(); }
private static void CreateInterstitialRequest() { #if ADMOB_IMPLEMENTED #if UNITY_ANDROID string adUnitId = Instance.interstitialAndroid; #elif UNITY_IPHONE string adUnitId = Instance.interstitialIOS; #else string adUnitId = "unexpected_platform"; #endif // Initialize an InterstitialAd. interstitial = new InterstitialAd(adUnitId); // Create an empty ad request. AdRequest.Builder request = new AdRequest.Builder(); //add test devices foreach(DeviceID device in Instance.testDevices) request.AddTestDevice(device.id); // Load the interstitial with the request. interstitial.LoadAd(request.Build()); #endif }
private static void CreateBannerRequest() { #if ADMOB_IMPLEMENTED #if UNITY_ANDROID string adUnitId = Instance.bannerAndroid; #elif UNITY_IPHONE string adUnitId = Instance.bannerIOS; #else string adUnitId = "unexpected_platform"; #endif // Create a 320x50 banner at the top of the screen. bannerView = new BannerView(adUnitId, _adSize, _adPosition); // Create an) empty ad request. AdRequest.Builder request = new AdRequest.Builder(); //add test devices foreach(DeviceID device in Instance.testDevices) request.AddTestDevice(device.id); request.AddTestDevice(AdRequest.TestDeviceSimulator); // Load the banner with the request. bannerView.LoadAd(request.Build()); // Called when an ad request has successfully loaded. bannerView.OnAdLoaded += HandleOnBannerLoaded; // Called when an ad request failed to load. bannerView.OnAdFailedToLoad += HandleOnBannerFailedToLoad; // Called when an ad is clicked. bannerView.OnAdOpening += HandleOnBannerOpened; // Called when the user returned from the app after an ad click. bannerView.OnAdClosed += HandleOnBannerClosed; // Called when the ad click caused the user to leave the application. bannerView.OnAdLeavingApplication += HandleOnBannerLeavingApplication; #endif }
private AdRequest getAdRequest(){ // Creating the request builder AdRequest.Builder requestBuilder = new AdRequest.Builder(); // Test devices if(useEmulatorAsATestDevice){ requestBuilder.AddTestDevice(AdRequest.TestDeviceSimulator); } foreach(string deviceID in testDevices){ if(!string.IsNullOrEmpty(deviceID)){ requestBuilder.AddTestDevice(deviceID); } } // Keywords string[] words = keywords.Split(','); foreach(string word in words){ if(word.Trim() != string.Empty) requestBuilder.AddKeyword(word.Trim()); } // Gender if(gender != Gender.Unknown) requestBuilder.SetGender(gender); // Tag for child directed treatment if (tagForChildDirectedTreatment != TagForChildDirectedTreatment.NotTagged) { requestBuilder.TagForChildDirectedTreatment (tagForChildDirectedTreatment == TagForChildDirectedTreatment.True); } return requestBuilder.Build(); }