Skip to content

Commit

Permalink
Update README with API updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ericleich committed May 8, 2014
1 parent 95e6ea1 commit e490f2d
Showing 1 changed file with 45 additions and 4 deletions.
49 changes: 45 additions & 4 deletions unity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ applications. Plugin features include:
* A single package with cross platform (Android/iOS) support
* Mock ad calls when running inside Unity editor
* Support for Banner Ads
* Support for Interstitial Ads
* Custom banner sizes
* Banner ad events listeners
* AdRequest targeting methods
* A sample project to demonstrate plugin integration

Interstitial support coming soon.

The plugin contains a .unitypackage file for those that want to easily import
the plugin, as well as the source code for those that want to iterate on it.

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

The _AdPosition_ enum specifies where to place the banner.

Basic Interstitial Flow
-----------------------
Here is the minimal banner code to create an interstitial.

using GoogleMobileAds.Api;
...
// Initialize an InterstitialAd.
InterstitialAd interstitial = new InterstitialAd("MY_AD_UNIT_ID");
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the interstitial with the request.
interstitial.LoadAd(request);

Unlike banners, interstitials need to be explicitly shown. At an appropriate
stopping point in your app, check that the interstitail is ready before
showing it:

if (interstitial.isLoaded()) {
interstitial.Show();
}

Custom Ad Sizes
---------------
In addition to constants on _AdSize_, you can also create a custom size:
Expand Down Expand Up @@ -161,7 +181,10 @@ also want to get test ads on the simulator. Here is how to set up the request:

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

using GoogleMobileAds.Api;
...
Expand All @@ -182,12 +205,21 @@ _BannerView_ contains ad events that you can register for:
bannerView.AdLeftApplication += HandleAdLeftApplication;
...

public void HandleAdLoaded()
public void HandleAdLoaded(object sender, EventArgs args)
{
print("HandleAdLoaded event received.");
// Handle the ad loaded event.
}

The only event with special event args is _AdFailedToLoad_. It passes an
instance of _AdFailedToLoadEventArgs_ with a _Message_ describing the error.

public void HandleAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
{
print("Interstitial Failed to load: " + args.Message);
// Handle the ad failed to load event.
};

You only need to register for the events you care about.

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

Interstitial Lifecycle
----------------------
Similar to banners, interstitials also have a destroy method:

interstitial.Destroy();

It is important to explicitly destroy the interstitial before letting it go
out of scope so that it can be properly released by the plugin.

Additional Resources
====================
* [Developer documentation](https://developers.google.com/mobile-ads-sdk/docs)
Expand Down

0 comments on commit e490f2d

Please sign in to comment.