avory_ad_control 1.0.2 copy "avory_ad_control: ^1.0.2" to clipboard
avory_ad_control: ^1.0.2 copied to clipboard

PlatformAndroidiOS
unlisted

Avory Ad Control is a wrapper around Google Admob which let you integrate ads easily

Avory Ad Control #

Avory Ad Control is a comprehensive Flutter package that provides easy integration for both Google AdMob and AppLovin MAX ad networks. It supports multiple ad formats including app open ads, interstitial ads, rewarded ads, banner ads, and more.

Features #

Dual Ad Network Support - Seamlessly integrate both AdMob and AppLovin MAX
Intelligent Ad Mediation - 70% AppLovin / 30% AdMob distribution for app open ads
Multiple Ad Formats - App open, interstitial, rewarded, banner, and native ads
Automatic Fallback - Smart fallback between ad networks for maximum fill rate
Revenue Optimization - Maximize revenue with intelligent ad network selection
Easy Integration - Simple setup with minimal configuration
Lifecycle Management - Automatic ad loading and lifecycle handling

Supported Ad Networks #

  • Google AdMob - Industry-leading mobile advertising platform
  • AppLovin MAX - High-performance mobile advertising platform with superior eCPMs

Ad Formats Supported #

Ad Format AdMob AppLovin
App Open Ads
Interstitial Ads
Rewarded Ads 🚧
Banner Ads
Native Ads 🚧

🚧 = Coming soon

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  avory_ad_control: ^1.0.0

Platform Setup #

Android #

Update AndroidManifest.xml

Add your AdMob App ID to android/app/src/main/AndroidManifest.xml:

<manifest>
    <application>
        <!-- AdMob App ID -->
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
    </application>
</manifest>

iOS #

Update Info.plist

Add your AdMob App ID to ios/Runner/Info.plist:

<key>GADApplicationIdentifier</key>
<string>ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy</string>

For AppLovin integration, also add:

<key>AppLovinSdkKey</key>
<string>YOUR_APPLOVIN_SDK_KEY</string>

Quick Start #

1. Create Ad ID Manager #

Create a class that implements IAdIdManager to manage your ad unit IDs:

import 'dart:io';
import 'package:avory_ad_control/avory_ad_control.dart';

class MyAdIdManager extends IAdIdManager {
  const MyAdIdManager();

  @override
  AppAdIds? get admobAdIds => AppAdIds(
    appId: Platform.isAndroid
        ? 'ca-app-pub-3940256099942544~3347511713'
        : 'ca-app-pub-3940256099942544~1458002511',
    appOpenId: Platform.isAndroid
        ? 'ca-app-pub-3940256099942544/9257395921'
        : 'ca-app-pub-3940256099942544/5575463023',
    bannerId: 'ca-app-pub-3940256099942544/6300978111',
    interstitialId: 'ca-app-pub-3940256099942544/1033173712',
    rewardedId: 'ca-app-pub-3940256099942544/5224354917',
    rewardedInterstitialId: Platform.isAndroid
        ? 'ca-app-pub-3940256099942544/5354046379'
        : 'ca-app-pub-3940256099942544/6978759866',
  );

  @override
  AppLovinAdIds? get appLovinAdIds => AppLovinAdIds(
    sdkKey: 'YOUR_APPLOVIN_SDK_KEY',
    appOpenId: 'YOUR_APPLOVIN_APP_OPEN_AD_UNIT_ID',
    bannerId: 'YOUR_APPLOVIN_BANNER_AD_UNIT_ID',
    interstitialId: 'YOUR_APPLOVIN_INTERSTITIAL_AD_UNIT_ID',
    rewardedId: 'YOUR_APPLOVIN_REWARDED_AD_UNIT_ID',
  );
}

2. Initialize the SDK #

Initialize both AdMob and AppLovin SDKs in your app's main function:

import 'package:avory_ad_control/avory_ad_control.dart';
import 'package:flutter/material.dart';

const IAdIdManager adIdManager = MyAdIdManager();

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // Handle consent (GDPR/CCPA)
  await ConsentManager.gatherGdprConsent();
  await ConsentManager.gatherPrivacyConsent();

  // Initialize ad networks with configurable mediation rates
  await AivoryAdControl.instance.initialize(
    adIdManager,
    isShowAppOpenOnAppStateChange: true,
    // Configure mediation rates for different ad types
    mediationConfig: const AdMediationConfig(
      appOpenRate: 0.7,      // 70% AppLovin for app open ads
      interstitialRate: 0.7, // 70% AppLovin for interstitial ads
      bannerRate: 0.5,       // 50% AppLovin for banner ads
    ),
    enableLogger: true,
  );

  runApp(MyApp());
}

3. Show Ads #

App Open Ads (with Intelligent Mediation)

App open ads automatically use intelligent mediation with 70% AppLovin preference:

// Show app open ad with automatic network selection
bool success = AivoryAdControl.instance.showAd(AdUnitType.appOpen);

// Or specify a specific network
bool success = AivoryAdControl.instance.showAd(
  AdUnitType.appOpen,
  adNetwork: AdNetwork.applovin,
);

Interstitial Ads

// Show interstitial ad with automatic network selection (mediated)
bool success = AivoryAdControl.instance.showAd(AdUnitType.interstitial);

// Or specify a specific network
bool success = AivoryAdControl.instance.showAd(
  AdUnitType.interstitial,
  adNetwork: AdNetwork.applovin,
);

Rewarded Ads

bool success = AivoryAdControl.instance.showAd(AdUnitType.rewarded);
// AdMob banner ad
Widget admobBanner = ACBannerAd(
  adNetwork: AdNetwork.admob,
  adSize: AdSize.banner,
);

// AppLovin banner ad
Widget appLovinBanner = ACBannerAd(
  adNetwork: AdNetwork.applovin,
  adFormat: AdFormat.banner,
  isAdaptiveBannerEnabled: true,
  isAutoRefreshEnabled: true,
);

// AppLovin MREC ad
Widget appLovinMREC = ACBannerAd(
  adNetwork: AdNetwork.applovin,
  adFormat: AdFormat.mrec,
  isAdaptiveBannerEnabled: false,
  isAutoRefreshEnabled: true,
);

Advanced Features #

Custom Mediation Rates #

You can customize the mediation rates for different ad types:

await AivoryAdControl.instance.initialize(
  adIdManager,
  // Configure mediation rates for different ad types
  mediationConfig: const AdMediationConfig(
    appOpenRate: 0.8,      // 80% AppLovin for app open ads
    interstitialRate: 0.6, // 60% AppLovin for interstitial ads
    bannerRate: 0.4,       // 40% AppLovin for banner ads
  ),
);

Supported Ad Types for AppLovin Mediation #

  • App Open Ads - Full mediation support
  • Interstitial Ads - Full mediation support
  • Banner Ads - Full mediation support
  • Rewarded Ads - AdMob only (AppLovin implementation pending)
  • Native Ads - AdMob only (AppLovin implementation pending)

Ad Event Listening #

Listen to ad events for analytics and debugging:

AivoryAdControl.instance.onEvent.listen((AdEvent event) {
  switch (event.type) {
    case AdEventType.adLoaded:
      print('Ad loaded: ${event.adNetwork} ${event.adUnitType}');
      break;
    case AdEventType.adShowed:
      print('Ad showed: ${event.adNetwork} ${event.adUnitType}');
      break;
    case AdEventType.adFailedToLoad:
      print('Ad failed to load: ${event.error}');
      break;
    // Handle other events...
  }
});

Check Ad Availability #

// Check if specific ad types are loaded
bool isAppOpenLoaded = AivoryAdControl.instance.isAppOpenAdLoaded();
bool isInterstitialLoaded = AivoryAdControl.instance.isInterstitialAdLoaded();
bool isRewardedLoaded = AivoryAdControl.instance.isRewardedAdLoaded();

// Check for specific networks
bool isAppLovinAppOpenLoaded = AivoryAdControl.instance.isAppOpenAdLoaded(
  adNetwork: AdNetwork.applovin,
);

Manual Ad Loading #

// Load all ad types
AivoryAdControl.instance.loadAd();

// Load specific ad type
AivoryAdControl.instance.loadAd(adUnitType: AdUnitType.appOpen);

// Load for specific network
AivoryAdControl.instance.loadAd(
  adNetwork: AdNetwork.applovin,
  adUnitType: AdUnitType.appOpen,
);

Revenue Optimization #

Why 70% AppLovin? #

AppLovin MAX typically provides:

  • Higher eCPMs - Often 20-40% higher than AdMob alone
  • Better Fill Rates - Advanced bidding algorithms
  • Global Demand - Access to premium demand sources
  • Real-time Optimization - Dynamic price floors and optimization

Intelligent Fallback #

The package automatically implements intelligent fallback:

  1. Primary: Try AppLovin (70% of the time)
  2. Fallback: Use AdMob if AppLovin fails
  3. Preloading: Both networks preload ads for instant display

Testing #

Use the provided TestAdIdManager for development and testing:

const IAdIdManager adIdManager = TestAdIdManager();

This includes test ad unit IDs for both AdMob and AppLovin networks.

Production Setup #

For production, create your own ad ID manager with real ad unit IDs:

class ProductionAdIdManager extends IAdIdManager {
  @override
  AppAdIds? get admobAdIds => AppAdIds(
    appId: 'ca-app-pub-YOUR_PUBLISHER_ID~YOUR_APP_ID',
    appOpenId: 'ca-app-pub-YOUR_PUBLISHER_ID/YOUR_APP_OPEN_ID',
    // ... other ad unit IDs
  );

  @override
  AppLovinAdIds? get appLovinAdIds => AppLovinAdIds(
    sdkKey: 'YOUR_APPLOVIN_SDK_KEY',
    appOpenId: 'YOUR_APPLOVIN_APP_OPEN_ID',
    // ... other ad unit IDs
  );
}

Best Practices #

  1. Initialize Early - Call initialize() as early as possible in your app
  2. Handle Consent - Always handle GDPR/CCPA consent before showing ads
  3. Preload Ads - Ads are automatically preloaded for better user experience
  4. Monitor Performance - Use ad event listeners to track performance
  5. Test Thoroughly - Test with both test and real ad unit IDs
  6. Respect User Experience - Don't show ads too frequently

Troubleshooting #

Common Issues #

  1. Ads not showing: Check ad unit IDs and network initialization
  2. Low fill rates: Ensure both networks are properly configured
  3. Revenue lower than expected: Verify mediation rates and ad unit setup

Debug Mode #

Enable logging to see detailed ad events:

await AivoryAdControl.instance.initialize(
  adIdManager,
  enableLogger: true, // Enable detailed logging
);

Contributing #

Contributions are welcome! Please read our contributing guidelines and submit pull requests to our repository.

License #

This project is licensed under the MIT License - see the LICENSE file for details.

Support #

For support and questions:

  • Create an issue on GitHub
  • Check our documentation
  • Review the example app for implementation details
0
likes
125
points
55
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Avory Ad Control is a wrapper around Google Admob which let you integrate ads easily

Repository (GitHub)

License

MIT (license)

Dependencies

applovin_max, collection, flutter, google_mobile_ads, logger

More

Packages that depend on avory_ad_control