unity_ads_plugin 0.3.19 copy "unity_ads_plugin: ^0.3.19" to clipboard
unity_ads_plugin: ^0.3.19 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 #

Pub License Pub likes Pub popularity Pub points Flutter platform

Buy Me A Coffee PayPal

Unity Ads plugin for Flutter Applications. This plugin is able to display Unity Banner Ads and Unity Video Ads.

Flutter Unity Ads Example for Andoid

Table of Contents #

Getting Started #

1. Initialization: #

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.

UnityAds.isInitialized() can be used to check if the SDK is initialized successfully.


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.

Add shrinkResources false and minifyEnabled false to the /android/app/build.gradle file to prevent the runtime exception when running the application on Android in release mode.

android {
...
    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug

            shrinkResources false
            minifyEnabled false
        }
    }
}

2. Show Rewarded/Interstitial Video Ad: #

Rewarded Video Ad Interstitial Video Ad

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'),
);

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 docs.unity.com.

3. Show Banner Ad: #

Banner Ad

Place UnityBannerAd widget in your app.

UnityBannerAd(
  placementId: 'PLACEMENT_ID',
  onLoad: (placementId) => print('Banner loaded: $placementId'),
  onClick: (placementId) => print('Banner clicked: $placementId'),
  onShown: (placementId) => print('Banner shown: $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)

FAQ #

Getting 'Unhandled Exception: PlatformException(error, Field loadTimeoutMs_ for j2.b2 not found....' when running the application on Android in release mode

Adding shrinkResources false and minifyEnabled false to the /android/app/build.gradle file resolves the problem.

android {
...
    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug

            shrinkResources false
            minifyEnabled false
        }
    }
}

If you find this package helpful and would like to support its continued development, please consider making a donation. Your contributions are greatly appreciated and motivate the further enhancement of this and other plugins.

Donate Buy Me A Coffee PayPal

Your support helps in maintaining and improving this package, ensuring it remains up-to-date and useful for the community.

Thank you for your generosity!

156
likes
0
pub points
96%
popularity

Publisher

verified publisherrebeloid.com

Unity Ads plugin for Flutter Applications. This plugin is able to display Unity Banner Ads and Unity Video Ads.

Repository (GitHub)
View/report issues

Funding

Consider supporting this project:

paypal.me
www.buymeacoffee.com
www.paypal.com

License

unknown (license)

Dependencies

flutter

More

Packages that depend on unity_ads_plugin