@@ -8,13 +8,12 @@ applications. Plugin features include:
8
8
* A single package with cross platform (Android/iOS) support
9
9
* Mock ad calls when running inside Unity editor
10
10
* Support for Banner Ads
11
+ * Support for Interstitial Ads
11
12
* Custom banner sizes
12
13
* Banner ad events listeners
13
14
* AdRequest targeting methods
14
15
* A sample project to demonstrate plugin integration
15
16
16
- Interstitial support coming soon.
17
-
18
17
The plugin contains a .unitypackage file for those that want to easily import
19
18
the plugin, as well as the source code for those that want to iterate on it.
20
19
@@ -109,6 +108,27 @@ Here is the minimal code needed to create a banner.
109
108
110
109
The _ AdPosition_ enum specifies where to place the banner.
111
110
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
+
112
132
Custom Ad Sizes
113
133
---------------
114
134
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:
161
181
162
182
Ad Events
163
183
---------
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:
165
188
166
189
using GoogleMobileAds.Api;
167
190
...
@@ -182,12 +205,21 @@ _BannerView_ contains ad events that you can register for:
182
205
bannerView.AdLeftApplication += HandleAdLeftApplication;
183
206
...
184
207
185
- public void HandleAdLoaded()
208
+ public void HandleAdLoaded(object sender, EventArgs args )
186
209
{
187
210
print("HandleAdLoaded event received.");
188
211
// Handle the ad loaded event.
189
212
}
190
213
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
+
191
223
You only need to register for the events you care about.
192
224
193
225
Banner Lifecycle
@@ -208,6 +240,15 @@ your reference to it:
208
240
This lets the plugin know you no longer need the object, and can do any
209
241
necessary cleanup on your behalf.
210
242
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
+
211
252
Additional Resources
212
253
====================
213
254
* [ Developer documentation] ( https://developers.google.com/mobile-ads-sdk/docs )
0 commit comments