unity_ads_plugin 0.2.4
unity_ads_plugin: ^0.2.4 copied to clipboard
Unity Ads plugin for Flutter Applications. This plugin is able to display Unity Banner Ads and Unity Video Ads.
Unity Ads Plugin #
Unity Ads plugin for Flutter Applications. This plugin is able to display Unity Banner Ads and Unity Video Ads.
Getting Started #
1. Initialization: #
UnityAds.init(
gameId: 'game_id',
listener: (state, args) => print('Init Listener: $state => $args'),
);
Set your Game id.
For testing purposes set testMode to true.
Android only: To change ads behavior in Firebase Test Lab use firebaseTestLabMode parameter. Possible values:
| Mode | Description |
|---|---|
| disableAds | Ads are not displayed in the Firebase Test Lab (by default) |
| showAdsInTestMode | Ads are displayed in test mode. |
| showAds | Real ads are displayed, if testMode is false. |
2. Show Rewarded/Interstitial Video Ad: #

UnityAds.showVideoAd(
placementId: 'video_placement_id',
listener: (state, args) {
if (state == UnityAdState.complete) {
print('User watched a video. User should get a reward!');
} else if (state == UnityAdState.skipped) {
print('User cancel video.');
}
},
);
Check if the video ad is ready:
UnityAds.isReady(placementId: 'video_placement_id');
Possible unity ad state:
| State | Description |
|---|---|
| ready | Ad loaded successfully. |
| error | Some error occurred. |
| started | Video ad started. |
| complete | Video played till the end. Use it to reward the user. |
| skipped | Video ad closed. |
Server-to-server redeem callbacks
UnityAds.showVideoAd has serverId parameter.
To use server-to-server callbacks, you need to set this parameter.
Read more on unity3d.com.
3. Show Banner Ad: #

Place UnityBannerAd widget in your app.
UnityBannerAd(
placementId: "banner_placement_id",
listener: (state, args) {
print('Banner Listener: $state => $args');
},
)
Possible unity banner ad state:
| State | Description |
|---|---|
| loaded | Banner is loaded. |
| clicked | Banner is clicked. |
| error | Error during loading banner. |
Donate #
If you found this plugin helpful and would like to thank me: