Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

facebook audience network

facebook audience network plugin for flutter applications.

note: currently only android platform is supported.

banner ad native banner ad native ad
banner ad native banner ad facebook audience
interstitial ad rewarded video ad in-stream video ad
interstitial ad rewarded ad instream ad

getting started with facebook audience network

1. initialization:

for testing purposes you need to obtain the hashed id of your testing device. to obtain the hashed id:

  1. call facebookaudiencenetwork.init() during app initialization.
  2. place the facebookbannerad widget in your app.
  3. run the app.

the hased id will be in printed to the logcat. paste that onto the testingid parameter.

facebookaudiencenetwork.init(
  testingid: "37b1da9d-b48c-4103-a393-2e095e734bd6",
);

2. show banner ad:

container(
  alignment: alignment(0.5, 1),
  child: facebookbannerad(
    placementid: "your_placement_id",
    bannersize: bannersize.standard,
    listener: (result, value) {
      switch (result) {
        case banneradresult.error:
          print("error: $value");
          break;
        case banneradresult.loaded:
          print("loaded: $value");
          break;
        case banneradresult.clicked:
          print("clicked: $value");
          break;
        case banneradresult.logging_impression:
          print("logging impression: $value");
          break;
      }
    },
  ),
)

3. show interstitial ad:

facebookinterstitialad.loadinterstitialad(
  placementid: "your_placement_id",
  listener: (result, value) {
    if (result == interstitialadresult.loaded)
      facebookinterstitialad.showinterstitialad(delay: 5000);
  },
);

4. show rewarded video ad:

facebookrewardedvideoad.loadrewardedvideoad(
  placementid: "your_placement_id",
  listener: (result, value) {
    if(result == rewardedvideoresult.loaded)
      facebookrewardedvideoad.showrewardedvideoad();
    if(result == rewardedvideoresult.video_complete)
      print("video completed");
  },
);

5. show in-stream video ad:

make sure the width and height is 300 at minimum.

facebookinstreamvideoad(
  placementid: "your_placement_id",
  height: 300,
  listener: (result, value) {
    if (result == instreamvideoadresult.video_complete) {
      setstate(() {
        _videocomplete = true;
      });
    }
  },
)

6. show native ad:

facebooknativead(
  placementid: "your_placement_id",
  adtype: nativeadtype.native_ad,
  width: double.infinity,
  height: 300,
  backgroundcolor: colors.blue,
  titlecolor: colors.white,
  descriptioncolor: colors.white,
  buttoncolor: colors.deeppurple,
  buttontitlecolor: colors.white,
  buttonbordercolor: colors.white,
  listener: (result, value) {
    print("native ad: $result --> $value");
  },
),

7. show native banner ad:

use nativebanneradsize to choose the height for native banner ads. height property is ignored for native banner ads.

facebooknativead(
  placementid: "your_placement_id",
  adtype: nativeadtype.native_banner_ad,
  banneradsize: nativebanneradsize.height_100,
  width: double.infinity,
  backgroundcolor: colors.blue,
  titlecolor: colors.white,
  descriptioncolor: colors.white,
  buttoncolor: colors.deeppurple,
  buttontitlecolor: colors.white,
  buttonbordercolor: colors.white,
  listener: (result, value) {
    print("native ad: $result --> $value");
  },
),

check out the example for complete implementation.

future work

implement for ios platform.


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.