Skip to content

Commit e490f2d

Browse files
committed
Update README with API updates
1 parent 95e6ea1 commit e490f2d

File tree

1 file changed

+45
-4
lines changed

1 file changed

+45
-4
lines changed

unity/README.md

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ applications. Plugin features include:
88
* A single package with cross platform (Android/iOS) support
99
* Mock ad calls when running inside Unity editor
1010
* Support for Banner Ads
11+
* Support for Interstitial Ads
1112
* Custom banner sizes
1213
* Banner ad events listeners
1314
* AdRequest targeting methods
1415
* A sample project to demonstrate plugin integration
1516

16-
Interstitial support coming soon.
17-
1817
The plugin contains a .unitypackage file for those that want to easily import
1918
the plugin, as well as the source code for those that want to iterate on it.
2019

@@ -109,6 +108,27 @@ Here is the minimal code needed to create a banner.
109108

110109
The _AdPosition_ enum specifies where to place the banner.
111110

111+
Basic Interstitial Flow
112+
-----------------------
113+
Here is the minimal banner code to create an interstitial.
114+
115+
using GoogleMobileAds.Api;
116+
...
117+
// Initialize an InterstitialAd.
118+
InterstitialAd interstitial = new InterstitialAd("MY_AD_UNIT_ID");
119+
// Create an empty ad request.
120+
AdRequest request = new AdRequest.Builder().Build();
121+
// Load the interstitial with the request.
122+
interstitial.LoadAd(request);
123+
124+
Unlike banners, interstitials need to be explicitly shown. At an appropriate
125+
stopping point in your app, check that the interstitail is ready before
126+
showing it:
127+
128+
if (interstitial.isLoaded()) {
129+
interstitial.Show();
130+
}
131+
112132
Custom Ad Sizes
113133
---------------
114134
In addition to constants on _AdSize_, you can also create a custom size:
@@ -161,7 +181,10 @@ also want to get test ads on the simulator. Here is how to set up the request:
161181

162182
Ad Events
163183
---------
164-
_BannerView_ contains ad events that you can register for:
184+
Both _BannerView_ and _InterstitialAd_ contain the same ad events that you can
185+
register for. These events are of type
186+
[EventHandler](http://msdn.microsoft.com/en-us/library/db0etb8x%28v=vs.110%29.aspx).
187+
Here we'll demonstrate setting ad events on a banner:
165188

166189
using GoogleMobileAds.Api;
167190
...
@@ -182,12 +205,21 @@ _BannerView_ contains ad events that you can register for:
182205
bannerView.AdLeftApplication += HandleAdLeftApplication;
183206
...
184207

185-
public void HandleAdLoaded()
208+
public void HandleAdLoaded(object sender, EventArgs args)
186209
{
187210
print("HandleAdLoaded event received.");
188211
// Handle the ad loaded event.
189212
}
190213

214+
The only event with special event args is _AdFailedToLoad_. It passes an
215+
instance of _AdFailedToLoadEventArgs_ with a _Message_ describing the error.
216+
217+
public void HandleAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
218+
{
219+
print("Interstitial Failed to load: " + args.Message);
220+
// Handle the ad failed to load event.
221+
};
222+
191223
You only need to register for the events you care about.
192224

193225
Banner Lifecycle
@@ -208,6 +240,15 @@ your reference to it:
208240
This lets the plugin know you no longer need the object, and can do any
209241
necessary cleanup on your behalf.
210242

243+
Interstitial Lifecycle
244+
----------------------
245+
Similar to banners, interstitials also have a destroy method:
246+
247+
interstitial.Destroy();
248+
249+
It is important to explicitly destroy the interstitial before letting it go
250+
out of scope so that it can be properly released by the plugin.
251+
211252
Additional Resources
212253
====================
213254
* [Developer documentation](https://developers.google.com/mobile-ads-sdk/docs)

0 commit comments

Comments
 (0)