Skip to main content

thinkingit_fb_ads 0.1.1 copy "thinkingit_fb_ads: ^0.1.1" to clipboard
thinkingit_fb_ads: ^0.1.1 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 FacebookAudienceNetwork.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.

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

Native and native banner #

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

FacebookNativeAd(
  placementId: 'YOUR_PLACEMENT_ID',
  adType: NativeAdType.nativeBannerAd,
  bannerAdSize: NativeBannerAdSize.height100,
)

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

Interstitial #

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

Rewarded video #

FacebookRewardedVideoAd.loadRewardedVideoAd(
  placementId: 'YOUR_PLACEMENT_ID',
  listener: (result, value) {
    if (result == RewardedVideoAdResult.loaded) {
      FacebookRewardedVideoAd.showRewardedVideoAd();
    }
    if (result == RewardedVideoAdResult.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. Enum values and constants now use lowerCamelCase. For example, BannerSize.STANDARD is now BannerSize.standard, and InterstitialAdResult.LOADED is now InterstitialAdResult.loaded.
  3. placementId is required.
  4. expandAnimationDuraion (milliseconds) is now expandAnimationDuration (a Duration).

Credits #

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

0
likes
0
points
43
downloads

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

unknown (license)

Dependencies

flutter

More

Packages that depend on thinkingit_fb_ads

Packages that implement thinkingit_fb_ads