Skip to content

Commit

Permalink
Version 3.1.2 of the Google Mobile Ads Unity Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Ram Parameswaran committed Nov 8, 2016
1 parent 280b222 commit 95689b7
Show file tree
Hide file tree
Showing 23 changed files with 494 additions and 188 deletions.
10 changes: 10 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
Google Mobile Ads Unity Plugin Change Log

*************
Version 3.1.2
*************
- Fix NPE when ad events are not hooked up.

Built and tested with:
- Google Play services 9.8.0
- Google Mobile Ads iOS SDK 7.13.0
- Unity Jar Resolver 1.2.2.0

*************
Version 3.1.1
*************
Expand Down
25 changes: 15 additions & 10 deletions source/plugin/Assets/GoogleMobileAds/Api/AdLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,21 @@ private AdLoader(Builder builder)
this.AdTypes = new HashSet<NativeAdType>(builder.AdTypes);
this.adLoaderClient = GoogleMobileAdsClientFactory.BuildAdLoaderClient(this);

this.adLoaderClient.OnCustomNativeTemplateAdLoaded +=
delegate(object sender, CustomNativeEventArgs args)
{
this.OnCustomNativeTemplateAdLoaded(this, args);
};
this.adLoaderClient.OnAdFailedToLoad += delegate(
object sender, AdFailedToLoadEventArgs args)
{
this.OnAdFailedToLoad(this, args);
};
this.adLoaderClient.OnCustomNativeTemplateAdLoaded += (sender, args) =>
{
if(this.OnCustomNativeTemplateAdLoaded != null)
{
this.OnCustomNativeTemplateAdLoaded(this, args);
}
};

this.adLoaderClient.OnAdFailedToLoad += (sender, args) =>
{
if(this.OnAdFailedToLoad != null)
{
this.OnAdFailedToLoad(this, args);
}
};
}

public event EventHandler<AdFailedToLoadEventArgs> OnAdFailedToLoad;
Expand Down
12 changes: 12 additions & 0 deletions source/plugin/Assets/GoogleMobileAds/Api/AdLoader.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion source/plugin/Assets/GoogleMobileAds/Api/AdRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace GoogleMobileAds.Api
{
public class AdRequest
{
public const string Version = "3.1.1";
public const string Version = "3.1.2";
public const string TestDeviceSimulator = "SIMULATOR";

public class Builder
Expand Down
65 changes: 40 additions & 25 deletions source/plugin/Assets/GoogleMobileAds/Api/BannerView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,42 +23,57 @@ public class BannerView
private IBannerClient client;

// These are the ad callback events that can be hooked into.
public event EventHandler<EventArgs> OnAdLoaded = delegate {};
public event EventHandler<AdFailedToLoadEventArgs> OnAdFailedToLoad = delegate {};
public event EventHandler<EventArgs> OnAdOpening = delegate {};
public event EventHandler<EventArgs> OnAdClosed = delegate {};
public event EventHandler<EventArgs> OnAdLeavingApplication = delegate {};
public event EventHandler<EventArgs> OnAdLoaded;
public event EventHandler<AdFailedToLoadEventArgs> OnAdFailedToLoad;
public event EventHandler<EventArgs> OnAdOpening;
public event EventHandler<EventArgs> OnAdClosed;
public event EventHandler<EventArgs> OnAdLeavingApplication;

// Creates a BannerView and adds it to the view hierarchy.
public BannerView(string adUnitId, AdSize adSize, AdPosition position)
{
client = GoogleMobileAdsClientFactory.BuildBannerClient();
client.CreateBannerView(adUnitId, adSize, position);

client.OnAdLoaded += delegate(object sender, EventArgs args)
{
OnAdLoaded(this, args);
};
this.client.OnAdLoaded += (sender, args) =>
{
if(this.OnAdLoaded != null)
{
this.OnAdLoaded(this, args);
}
};

client.OnAdFailedToLoad += delegate(object sender, AdFailedToLoadEventArgs args)
{
OnAdFailedToLoad(this, args);
};
this.client.OnAdFailedToLoad += (sender, args) =>
{
if(this.OnAdLoaded != null)
{
this.OnAdLoaded(this, args);
}
};

client.OnAdOpening += delegate(object sender, EventArgs args)
{
OnAdOpening(this, args);
};
this.client.OnAdOpening += (sender, args) =>
{
if(this.OnAdOpening != null)
{
this.OnAdOpening(this, args);
}
};

client.OnAdClosed += delegate(object sender, EventArgs args)
{
OnAdClosed(this, args);
};
this.client.OnAdClosed += (sender, args) =>
{
if(this.OnAdClosed != null)
{
this.OnAdClosed(this, args);
}
};

client.OnAdLeavingApplication += delegate(object sender, EventArgs args)
{
OnAdLeavingApplication(this, args);
};
this.client.OnAdLeavingApplication += (sender, args) =>
{
if(this.OnAdLeavingApplication != null)
{
this.OnAdLeavingApplication(this, args);
}
};
}

// Loads an ad into the BannerView.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 35 additions & 20 deletions source/plugin/Assets/GoogleMobileAds/Api/InterstitialAd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,45 @@ public InterstitialAd(string adUnitId)
client = GoogleMobileAdsClientFactory.BuildInterstitialClient();
client.CreateInterstitialAd(adUnitId);

client.OnAdLoaded += delegate(object sender, EventArgs args)
{
OnAdLoaded(this, args);
};
this.client.OnAdLoaded += (sender, args) =>
{
if(this.OnAdLoaded != null)
{
this.OnAdLoaded(this, args);
}
};

client.OnAdFailedToLoad += delegate(object sender, AdFailedToLoadEventArgs args)
{
OnAdFailedToLoad(this, args);
};
this.client.OnAdFailedToLoad += (sender, args) =>
{
if(this.OnAdLoaded != null)
{
this.OnAdLoaded(this, args);
}
};

client.OnAdOpening += delegate(object sender, EventArgs args)
{
OnAdOpening(this, args);
};
this.client.OnAdOpening += (sender, args) =>
{
if(this.OnAdOpening != null)
{
this.OnAdOpening(this, args);
}
};

client.OnAdClosed += delegate(object sender, EventArgs args)
{
OnAdClosed(this, args);
};
this.client.OnAdClosed += (sender, args) =>
{
if(this.OnAdClosed != null)
{
this.OnAdClosed(this, args);
}
};

client.OnAdLeavingApplication += delegate(object sender, EventArgs args)
{
OnAdLeavingApplication(this, args);
};
this.client.OnAdLeavingApplication += (sender, args) =>
{
if(this.OnAdLeavingApplication != null)
{
this.OnAdLeavingApplication(this, args);
}
};
}

// Loads an InterstitialAd.
Expand Down
45 changes: 37 additions & 8 deletions source/plugin/Assets/GoogleMobileAds/Api/NativeExpressAdView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,45 @@ public NativeExpressAdView(string adUnitId, AdSize adSize, AdPosition position)
this.client = GoogleMobileAdsClientFactory.BuildNativeExpressAdClient();
this.client.CreateNativeExpressAdView(adUnitId, adSize, position);

this.client.OnAdLoaded += (sender, args) => this.OnAdLoaded(this, args);

this.client.OnAdFailedToLoad += (sender, args) => this.OnAdFailedToLoad(this, args);

this.client.OnAdOpening += (sender, args) => this.OnAdOpening(this, args);

this.client.OnAdClosed += (sender, args) => this.OnAdClosed(this, args);
this.client.OnAdLoaded += (sender, args) =>
{
if(this.OnAdLoaded != null)
{
this.OnAdLoaded(this, args);
}
};

this.client.OnAdFailedToLoad += (sender, args) =>
{
if(this.OnAdLoaded != null)
{
this.OnAdLoaded(this, args);
}
};

this.client.OnAdOpening += (sender, args) =>
{
if(this.OnAdOpening != null)
{
this.OnAdOpening(this, args);
}
};

this.client.OnAdClosed += (sender, args) =>
{
if(this.OnAdClosed != null)
{
this.OnAdClosed(this, args);
}
};

this.client.OnAdLeavingApplication += (sender, args) =>
this.OnAdLeavingApplication(this, args);
{
if(this.OnAdLeavingApplication != null)
{
this.OnAdLeavingApplication(this, args);
}
};
}

// These are the ad callback events that can be hooked into.
Expand Down
77 changes: 49 additions & 28 deletions source/plugin/Assets/GoogleMobileAds/Api/RewardBasedVideoAd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,40 +50,61 @@ private RewardBasedVideoAd()
client = GoogleMobileAdsClientFactory.BuildRewardBasedVideoAdClient();
client.CreateRewardBasedVideoAd();

client.OnAdLoaded += delegate(object sender, EventArgs args)
{
OnAdLoaded(this, args);
};
this.client.OnAdLoaded += (sender, args) =>
{
if (this.OnAdLoaded != null)
{
this.OnAdLoaded(this, args);
}
};

client.OnAdFailedToLoad += delegate(object sender, AdFailedToLoadEventArgs args)
{
OnAdFailedToLoad(this, args);
};
this.client.OnAdFailedToLoad += (sender, args) =>
{
if (this.OnAdLoaded != null)
{
this.OnAdLoaded(this, args);
}
};

client.OnAdOpening += delegate(object sender, EventArgs args)
{
OnAdOpening(this, args);
};
this.client.OnAdOpening += (sender, args) =>
{
if (this.OnAdOpening != null)
{
this.OnAdOpening(this, args);
}
};

client.OnAdStarted += delegate(object sender, EventArgs args)
{
OnAdStarted(this, args);
};
this.client.OnAdStarted += (sender, args) =>
{
if (this.OnAdStarted != null)
{
this.OnAdStarted(this, args);
}
};

client.OnAdRewarded += delegate(object sender, Reward args)
{
OnAdRewarded(this, args);
};
this.client.OnAdClosed += (sender, args) =>
{
if (this.OnAdClosed != null)
{
this.OnAdClosed(this, args);
}
};

client.OnAdClosed += delegate(object sender, EventArgs args)
{
OnAdClosed(this, args);
};
this.client.OnAdLeavingApplication += (sender, args) =>
{
if (this.OnAdLeavingApplication != null)
{
this.OnAdLeavingApplication(this, args);
}
};

client.OnAdLeavingApplication += delegate(object sender, EventArgs args)
{
OnAdLeavingApplication(this, args);
};
this.client.OnAdRewarded += (sender, args) =>
{
if (this.OnAdRewarded != null)
{
this.OnAdRewarded(this, args);
}
};
}

// Loads a new reward based video ad request
Expand Down
Loading

0 comments on commit 95689b7

Please sign in to comment.