Android and Unity Banner API v2 documentation#38
Merged
Sunmeng1985 merged 12 commits into4.4.0from Nov 12, 2021
Merged
Conversation
Update Proguard file
Update Yodo1MasBannerAdView gravity on xml
Update Proguard file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part Banner(V2) Integration of integration-android.md file needs to be reviewed
Part Banner(V2) Integration of integration-unity.md file needs to be reviewed
Update Proguard
-keep class com.yodo1.mas.banner.** { *; }Android Banner(V2) Integration
1. Add Yodo1MasBannerAdView to the layout
The first step toward displaying a banner is to place
Yodo1MasBannerAdViewin the layout for the Activity or Fragment in which you'd like to display it. The easiest way to do this is to add one to the corresponding XML layout file. Here's an example that shows an activity'sYodo1MasBannerAdView:Note the following required attributes:
You can alternatively create
Yodo1MasBannerAdViewprogrammatically:For Java
For Kotlin
Banner sizes
2. Load an ad
Once the
Yodo1MasBannerAdViewis in place, the next step is to load an ad. That's done with theloadAd()method in theYodo1MasBannerAdViewclass.Here's an example that shows how to load an ad in the
onCreate()method of anActivity:For Java
For Kotlin
That's it! Your app is now ready to display banner ads.
3. Ad events
To further customize the behavior of your ad, you can hook onto a number of events in the ad's lifecycle: loading, opening, closing, and so on. You can listen for these events through the
Yodo1MasBannerAdListenerclass.For Java
For Kotlin
Unity Banner(V2) Integration
1. Create a Yodo1U3dBannerAdView
The first step toward displaying a banner is to create a Yodo1U3dBannerAdView object in a C# script attached to a GameObject.
The constructor for a
Yodo1U3dBannerAdViewhas the following parameters:Yodo1U3dBannerAdSize- The MAS ad size you'd like to use.Yodo1U3dBannerAdPosition- The position where the banner ad should be placed. TheYodo1U3dBannerAdPositionenum lists the valid ad position values.2. (Optional) Custom ad position
For greater control over where a
Yodo1U3dBannerAdViewis placed on screen than what's offered byYodo1U3dBannerAdPositionvalues, use theYodo1U3dBannerAdViewconstructor that has x- and y-coordinates as parameters:The top-left corner of the
Yodo1U3dBannerAdViewwill be positioned at the x and y values passed to the constructor, where the origin is the top-left of the screen.3. Load an ad
Once the BannerView is instantiated, the next step is to load an ad. That's done with the loadAd() method in the BannerView class.
Here's an example that shows how to load an ad:
That's it! Your app is now ready to display banner ads from MAS.
4. Ad events
To further customize the behavior of your ad, you can hook into a number of events in the ad's lifecycle: loading, opening, closing, and so on.
5. Clean up banner ads
When you are finished with a BannerView, make sure to call the Destroy() method before dropping your reference to it:
6. Create a Banner Placement
Simply add the placement name as a string in the parentheses.