facebook_audience_network 0.2.0 copy "facebook_audience_network: ^0.2.0" to clipboard
facebook_audience_network: ^0.2.0 copied to clipboard

outdated

Facebook Audience Network plugin for Flutter applications. You can show Facebook Banner ads, Interstitial ads, Rewarded video ads and Native ads though this plugin.

facebook_audience_network #

Facebook Audience Network plugin for Flutter applications.

Note: Currently only Android platform is supported.

Pub GitHub

Getting Started #

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 to give proper width and height.

FacebookInStreamVideoAd(
  placementId: "YOUR_PLACEMENT_ID",
  height: 300,
  listener: (result, value) {
    if (result == InStreamVideoAdResult.VIDEO_COMPLETE) {
      setState(() {
        _videoComplete = true;
      });
    }
  },
)

Check out the example for complete implementation.

Future Work #

Implement for iOS platform.

303
likes
0
pub points
96%
popularity

Publisher

verified publisherdsi.dev

Facebook Audience Network plugin for Flutter applications. You can show Facebook Banner ads, Interstitial ads, Rewarded video ads and Native ads though this plugin.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on facebook_audience_network