Unity Ads plugin for Flutter Applications. This plugin is able to display Unity Banner Ads and Unity Video Ads.
If you want to try Unity Mediation (Beta) use Unity Mediation plugin instead of this one.
UnityAds.init(
gameId: 'PROJECT_GAME_ID',
onComplete: () => print('Initialization Complete'),
onFailed: (error, message) => print('Initialization Failed: $error $message'),
);
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. |
Load a video ad before show it.
UnityAds.load(
placementId: 'PLACEMENT_ID',
onComplete: (placementId) => print('Load Complete $placementId'),
onFailed: (placementId, error, message) => print('Load Failed $placementId: $error $message'),
);
Show a loaded ad.
UnityAds.showVideoAd(
placementId: 'PLACEMENT_ID',
onStart: (placementId) => print('Video Ad $placementId started'),
onClick: (placementId) => print('Video Ad $placementId click'),
onSkipped: (placementId) => print('Video Ad $placementId skipped'),
onComplete: (placementId) => print('Video Ad $placementId completed'),
onFailed: (placementId, error, message) => print('Video Ad $placementId failed: $error $message'),
);
UnityAds.showVideoAd
has serverId
parameter.
To use server-to-server callbacks, you need to set this parameter.
Read more on docs.unity.com.
Place UnityBannerAd
widget in your app.
UnityBannerAd(
placementId: 'PLACEMENT_ID',
onLoad: (placementId) => print('Banner loaded: $placementId'),
onClick: (placementId) => print('Banner clicked: $placementId'),
onFailed: (placementId, error, message) => print('Banner Ad $placementId failed: $error $message'),
)
Read more about privacy consent in Unity Ads documentation.
Use the following code to pass the appropriate consent flags to the Unity Ads SDK:
UnityAds.setPrivacyConsent(<Privacy Consent type>, true)
Your donation motivates me to work more on plugins and packages. If you found this plugin helpful and would like to thank me: