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);
	}
Beispiel #2
0
    // Use this for initialization
    void Awake()
    {
        bannerView = new BannerView("ca-app-pub-5325622833123971/2069584440", AdSize.SmartBanner, AdPosition.Bottom);
        AdRequest.Builder builder = new AdRequest.Builder();
        //AdRequest request = builder.AddTestDevice(AdRequest.TestDeviceSimulator).AddTestDevice(SystemInfo.deviceUniqueIdentifier).Build();
        AdRequest request = builder.Build();// 실제 빌드

        bannerView.LoadAd(request); //배너 광고 요청
        bannerView.Show();  // 배너 광고 출력
    }
	private static void CreateRewardedVideoRequest()
	{
		#if ADMOB_IMPLEMENTED

		#if UNITY_EDITOR
		string adUnitId = "unused";
		#elif UNITY_ANDROID
		string adUnitId = Instance.rewardedVideoAndroid;
		#elif UNITY_IPHONE
		string adUnitId = Instance.rewardedVideoIOS;
		#else
		string adUnitId = "unexpected_platform";
		#endif

		//note: Rewarded Video Request is third party for AdMob and it's only hanlded by them. No test devices are permited. If you want rewarded video, set as test on the third party
		AdRequest.Builder request = new AdRequest.Builder();
		rewardBasedVideo.LoadAd(request.Build(), adUnitId);
		#endif
		}
	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();
	}
Beispiel #7
0
 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 ();
 }