Version 5 completely changes the way adverts are displayed, including more control over the ad units that are displayed. Migration is simple as laid out below.
The major difference is that you now will create an
AdView or an
InterstitialAd instance and use this to configure, load and display your adverts. Whereas you used to only have access to a single advert with one ad unit id, you can now create multiple and use as required. This means that you will need to hold onto an instance of your
InterstitialAd to set properties, listen for events, load, and display your advert.
With v5.0 you specify the unit id on the advert view. So you no longer have to set the unit id on the initialisePlatform functions.
This means the follow version 4 code,
Note: You must set an AdSize and a unit id on an AdView before attempting to load or display the ad.
Displaying an Banner Advert
Previously to display an advert:
This now becomes:
There is a bit more to the code now, however we believe this gives you much more functionality to control the way adverts are displayed in your application.
Listening for events is much more specified now. The following:
You can listen for many more events on the
AdView now as well.
Hiding an Advert
Hiding an advert is a simple change, the following:
Refreshing/Updating an advert
If you wish to manually refresh the advert you can call the refresh function. This will make the advert update with a new ad request.
This now changes to a new load request:
Interstitials are still provided through the
Adverts.service.interstitials singleton, however the process is now similar to the
AdView process above.
Previously to load an interstitial you called
load on the
Interstitials class, however now you need to create an instance of an
InterstitialAd and then call
load on that instance.
interstitial instance should be held onto and reused in your application.
Displaying an Interstitial
Previously to display an interstitial:
This now becomes:
uniqueId function has been deprecated. If you need access to the device unique id (vendorForIdentifier etc)
please use the
This will now only return the advertisting identifier, however we have improved its functionality to retrieve more information about the advertising identifier.
The asynchronous nature of the new implementation resolves issues with the previous implementation sometimes returning incorrect values.