Skip to main content

unified_ads_admob 1.1.0 copy "unified_ads_admob: ^1.1.0" to clipboard
unified_ads_admob: ^1.1.0 copied to clipboard

AdMob (Google Mobile Ads) adapter for unified_ads. Add it to link only the AdMob (Google Mobile Ads) SDK into your Android and iOS app.

example/README.md

unified_ads_admob example #

Add the core package and this adapter. Only the AdMob SDK is linked into your app.

dependencies:
  unified_ads: ^1.1.0
  unified_ads_admob: ^1.1.0

The adapter registers itself through Flutter's plugin registrant. Import it only for AdmobConsentProvider.

import 'package:flutter/widgets.dart';
import 'package:unified_ads/unified_ads.dart';
import 'package:unified_ads_admob/unified_ads_admob.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  // Optional: iOS App Tracking Transparency, then Google UMP consent.
  await UnifiedAds.requestTrackingAuthorization();
  await UnifiedAds.gatherConsent(const AdmobConsentProvider());

  await UnifiedAds.init(AdConfig(
    testMode: true, // never ship with test mode on
    networks: {
      AdNetwork.admob: NetworkConfig(
        appId: 'ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy', // also in AndroidManifest + Info.plist
        bannerAdUnitId: 'your-banner-id',
        interstitialAdUnitId: 'your-interstitial-id',
        rewardedAdUnitId: 'your-rewarded-id',
      ),
    },
  ));

  final rewarded = RewardedAd(
    onEarnedReward: (ad, reward) =>
        debugPrint('${reward.amount} ${reward.type} from ${ad.servedBy}'),
  );
  if ((await rewarded.load()).isSuccess) await rewarded.show();
}

Banner: UnifiedBannerWidget(ad: BannerAd(size: const BannerSize.adaptiveAnchored()), anchored: true).

Platform setup (manifest, Info.plist, SKAdNetwork IDs): doc/setup/admob.md. For a full app with every network, a settings screen and a live event log, see the example app.

0
likes
160
points
495
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

AdMob (Google Mobile Ads) adapter for unified_ads. Add it to link only the AdMob (Google Mobile Ads) SDK into your Android and iOS app.

Repository (GitHub)
View/report issues
Contributing

Topics

#ads #admob #monetization

License

MIT (license)

Dependencies

flutter, meta, unified_ads_platform_interface

More

Packages that depend on unified_ads_admob

Packages that implement unified_ads_admob