Skip to content

Unity Mediation is a plugin for Flutter Applications. This plugin is able to display and Unity Rewarded Ads and Interstitial Ads.

License

Notifications You must be signed in to change notification settings

AnmolSethi/unity_ads_mediation

Repository files navigation

Unity Mediation Ads

Pub License

Unity Mediation Ads is a plugin for Flutter Applications. This plugin is able to display and Unity Rewarded Ads and Interstitial Ads.

Note: We are working on the other ad formats as well

Getting Started

1. Initialization:

    UnityAdsMediation.initialize(
      gameId: 'GAME_ID',
      listener: (UnityInitializationState initializationState, Map<String, dynamic> result) {
          if (initializationState == UnityInitializationState.initialized) {
            <!-- This plugin is awesome -->
          } else if(initializationState == UnityInitializationState.error) {
            <!-- Something went wrong -->
          }
      },
    );
  • Get your GAME_ID from Unity Dashboard.

2. Add Adapters:

  1. Open the build.gradle file in your project.
  2. Add the following implementations in the dependencies section of the file, ensuring the dependencies of the adapters you intend to use in your project are declared:
    implementation "com.unity3d.mediation:admob-adapter:0.3.0"
    implementation "com.unity3d.mediation:adcolony-adapter:0.3.0"
    implementation "com.unity3d.mediation:applovin-adapter:0.3.0"
    implementation "com.unity3d.mediation:facebook-adapter:0.3.0"
    implementation "com.unity3d.mediation:ironsource-adapter:0.3.0"
    implementation "com.unity3d.mediation:vungle-adapter:0.3.0"

3. Show Rewarded Ad:

Rewarded Ad

UnityAdsMediation.showRewardedAd(
  placementId: 'REWARDED_AD_ID',
  listener: (UnityAdsState adState, Map<String, dynamic> result) {
    if (state == UnityAdState.rewarded) {
      <!-- User has watched a video. User should get a reward! -->
    } else if (state == UnityAdState.error) {
      <!-- Error -->
    }
  },
);

4. Show Interstitial Ad:

Interstitial Ad

UnityAdsMediation.showInterstitialAd(
  placementId: 'INTERSTITIAL_AD_ID',
  listener: (UnityAdsState adState, Map<String, dynamic> result) {
    if (state == UnityAdState.rewarded) {
      <!-- User has watched a video. User should get a reward! -->
    } else if (state == UnityAdState.error) {
      <!-- Error -->
    }
  },
);

UnityAdsState:

State Description
rewarded Video played till the end. Use it to reward the user.
error Some error occurred.
showed Ad showed to the user
closed Ad closed by the user
clicked User clicked the ad.

Pub likes Pub popularity Pub points Flutter platform GitHub popularity

About

Unity Mediation is a plugin for Flutter Applications. This plugin is able to display and Unity Rewarded Ads and Interstitial Ads.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published