Skip to main content

thinkingit_fb_ads 0.3.0 copy "thinkingit_fb_ads: ^0.3.0" to clipboard
thinkingit_fb_ads: ^0.3.0 copied to clipboard

Meta (Facebook) Audience Network ads for Flutter. Banner, native, native banner, interstitial and rewarded video ads on Android and iOS.

thinkingit_fb_ads #

Show Meta Audience Network ads in Flutter apps on Android and iOS.

Ad type Android iOS
Banner ✅ ✅
Native ✅ ✅
Native banner ✅ ✅
Interstitial ✅ ✅
Rewarded video ✅ ✅

Uses Meta Audience Network SDK 6.22.0.

Requirements #

  • Flutter 3.27 or newer
  • Android: minSdk 24 or higher
  • iOS: 15.0 or higher, Xcode 26 or newer

Installation #

flutter pub add thinkingit_fb_ads

iOS setup #

Set the deployment target to 15.0 in ios/Podfile:

platform :ios, '15.0'

Also set Minimum Deployments to 15.0 for the Runner target in Xcode.

Meta asks iOS apps to add the SKAdNetworkItems listed in Meta's iOS setup guide and an NSUserTrackingUsageDescription to ios/Runner/Info.plist.

Usage #

Initialize the SDK once, before loading any ad:

import 'package:thinkingit_fb_ads/thinkingit_fb_ads.dart';

await FbAds.init(
  testingId: 'YOUR_DEVICE_TESTING_ID', // optional, for test ads
  iOSAdvertiserTrackingEnabled: true, // the user's ATT choice
);

The testing ID is printed to the device log the first time an ad is requested without one.

FbBannerAd(
  placementId: 'YOUR_PLACEMENT_ID',
  bannerSize: FbBannerSize.standard, // standard, large, mediumRectangle
  listener: (result, value) {
    print('Banner ad: $result --> $value');
  },
)

Native and native banner #

FbNativeAd(
  placementId: 'YOUR_PLACEMENT_ID',
  adType: FbNativeAdType.nativeAd,
  height: 300,
  backgroundColor: Colors.white,
  buttonColor: Colors.blue,
  buttonTitleColor: Colors.white,
  listener: (result, value) {
    print('Native ad: $result --> $value');
  },
)

FbNativeAd(
  placementId: 'YOUR_PLACEMENT_ID',
  adType: FbNativeAdType.nativeBannerAd,
  bannerAdSize: FbNativeBannerAdSize.height100,
)

FbNativeAdType.nativeAdHorizontal and FbNativeAdType.nativeAdVertical are custom layouts on iOS. Android shows the standard native template for them.

Interstitial #

FbInterstitialAd.loadInterstitialAd(
  placementId: 'YOUR_PLACEMENT_ID',
  listener: (result, value) {
    if (result == FbInterstitialAdResult.loaded) {
      FbInterstitialAd.showInterstitialAd();
    }
  },
);

Rewarded video #

FbRewardedVideoAd.loadRewardedVideoAd(
  placementId: 'YOUR_PLACEMENT_ID',
  listener: (result, value) {
    if (result == FbRewardedVideoAdResult.loaded) {
      FbRewardedVideoAd.showRewardedVideoAd();
    }
    if (result == FbRewardedVideoAdResult.videoComplete) {
      // Grant the reward.
    }
  },
);

Interstitial and rewarded ads can be shown only once. Load a new ad after dismissed or videoClosed.

Listener values #

Listeners receive a map like this:

{
  'placement_id': 'YOUR_PLACEMENT_ID',
  'invalidated': false,
  'error_code': 1001,          // errors only
  'error_message': 'No fill',  // errors only
}

Migrating from facebook_audience_network #

  1. Change the import to package:thinkingit_fb_ads/thinkingit_fb_ads.dart.
  2. Rename the classes and enums: FacebookAudienceNetwork → FbAds, FacebookBannerAd → FbBannerAd, FacebookNativeAd → FbNativeAd, FacebookInterstitialAd → FbInterstitialAd, FacebookRewardedVideoAd → FbRewardedVideoAd, and add Fb to every other class and enum, for example BannerSize → FbBannerSize and NativeAdType → FbNativeAdType.
  3. Enum values and constants now use lowerCamelCase. For example, BannerSize.STANDARD is now FbBannerSize.standard, and InterstitialAdResult.LOADED is now FbInterstitialAdResult.loaded.
  4. placementId is required.
  5. expandAnimationDuraion (milliseconds) is now expandAnimationDuration (a Duration).

Credits #

Based on facebook_audience_network by Dreamsoft Innovations, released under the MIT License.

0
likes
140
points
43
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Meta (Facebook) Audience Network ads for Flutter. Banner, native, native banner, interstitial and rewarded video ads on Android and iOS.

Homepage
Repository (GitHub)
View/report issues

Topics

#ads #facebook #monetization #audience-network

License

MIT (license)

Dependencies

flutter

More

Packages that depend on thinkingit_fb_ads

Packages that implement thinkingit_fb_ads