Git Product home page Git Product logo

flutter_unity_mediation's Introduction

Unity Mediation

Pub License Pub likes Pub popularity Pub points Flutter platform

Buy Me A Coffee PayPal

Unity Mediation plugin for Flutter Applications. This plugin is able to display Rewarded and Interstitial Ads from different ad sources.

If your application uses only ads from Unity Ads source use Unity Ads Plugin.

Getting Started

1. Configure

iOS

  • set iOS version to 9.0 or higher in ios/Podfile file
  • in ios/Podfile file add next lines after platform :ios line:
source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/Unity-Technologies/unity-mediation-cocoapods-prod.git'

Android

  • set minSdkVersion to 21 in android/app/build.gradle file

2. Configure ad sources

For using additional advertising sources, it's needed to configure them.

iOS

Add dependencies of configured ad sources to ios/Podfile file from the table below

target 'Runner' do
  use_frameworks!
  use_modular_headers!
  # list of adapters
  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

AdMob ad source requires additional configuration. If you use AdMob add your AdMob app ID to ios/Runner/Info.plist file

<key>GADApplicationIdentifier</key>
<string>YOUR_ADMOB_APP_ID</string>

Android

Add dependencies of configured ad sources to android/app/build.gradle file

dependencies {
    // list of adapters
}

AdMob ad source requires additional configuration. If you use AdMob add your AdMob app ID to android/app/src/main/AndroidManifest.xml file

<manifest>
    <application>
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="YOUR_ADMOB_APP_ID"/>
    </application>
</manifest>

Ad Sources

Source iOS Android
AdColony pod 'UnityMediationAdColonyAdapter' implementation "com.unity3d.mediation:adcolony-adapter:0.5.0"
AppLovin pod 'UnityMediationAppLovinAdapter' implementation "com.unity3d.mediation:applovin-adapter:0.5.0"
IronSource pod 'UnityMediationIronSourceAdapter' implementation "com.unity3d.mediation:ironsource-adapter:0.5.0"
Vungle pod 'UnityMediationVungleAdapter' implementation "com.unity3d.mediation:vungle-adapter:0.5.0"
Meta Audience Network pod 'UnityMediationFacebookAdapter' implementation "com.unity3d.mediation:facebook-adapter:0.5.0"
AdMob pod 'UnityMediationAdmobAdapter' implementation "com.unity3d.mediation:admob-adapter:0.5.0"

3. Initialization

Initialize Unity Mediation with your game ID

UnityMediation.initialize(
  gameId: 'GAME_ID',
  onComplete: () => print('Initialization Complete'),
  onFailed: (error, message) => print('Initialization Failed: $error $message'),
);

4. Rewarded Ad

Rewarded Video Ad

Load an ad before show it.

UnityMediation.loadRewardedAd(
  adUnitId: 'REWARDED_AD_UNIT_ID',
  onComplete: (adUnitId) => print('Rewarded Ad Load Complete $adUnitId'),
  onFailed: (adUnitId, error, message) => print('Rewarded Ad Load Failed $adUnitId: $error $message'),
);

Show a loaded rewarded ad.

UnityMediation.showRewardedAd(
  adUnitId: 'REWARDED_AD_UNIT_ID',
  onStart: (adUnitId) => print('Rewarded Ad $adUnitId started'),
  onClick: (adUnitId) => print('Rewarded Ad $adUnitId click'),
  onRewarded: (adUnitId, reward) => print('Rewarded Ad $adUnitId rewarded $reward'),
  onClosed: (adUnitId) => print('Rewarded Ad $adUnitId closed'),
  onFailed: (adUnitId, error, message) => print('Rewarded Ad $adUnitId failed: $error $message'),
);

Server-to-server redeem callbacks

To use server-to-server callbacks, you need to set userId parameter when call showRewardedAd.

Read more on docs.unity.com.

5. Interstitial Ad

Interstitial Video Ad

Load an ad before show it.

UnityMediation.loadInterstitialAd(
    adUnitId: 'INTERSTITIAL_AD_UNIT_ID',
    onComplete: (adUnitId) => print('Interstitial Ad Load Complete $adUnitId'),
    onFailed: (adUnitId, error, message) => print('Interstitial Ad Load Failed $adUnitId: $error $message'),
);

Show a loaded interstitial ad.

UnityMediation.showInterstitialAd(
    adUnitId: 'INTERSTITIAL_AD_UNIT_ID',
    onStart: (adUnitId) => print('Interstitial Ad $adUnitId started'),
    onClick: (adUnitId) => print('Interstitial Ad $adUnitId click'),
    onClosed: (adUnitId) => print('Interstitial Ad $adUnitId closed'),
    onFailed: (adUnitId, error, message) => print('Interstitial Ad $adUnitId failed: $error $message'),
);

Donate

Your donation motivates me to work more on plugins and packages. If you found this plugin helpful and would like to thank me:

Donate Buy Me A Coffee PayPal

flutter_unity_mediation's People

Contributors

pavelzaichyk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.