Facebook Ads In Flutter
How to add facebook ads in flutter app

This article will show you , how to quickly make money from your Flutter application using Facebook ads.

By incorporating Facebook ads into their Flutter apps developers can monetize their work by displaying Facebook ads inside of them. To ensure that the ads are appearing as intended.it is necessary to create a Facebook Ads account, configure the Facebook SDK, add the Facebook Audience Network plugin, initialise the Facebook Audience Network SDK, create an ad widget using the FacebookBannerAd widget and run the app. Developers can easily integrate Facebook ads into their Flutter apps using these steps to start making money. This article will show you how to quickly monetize your Flutter application using Facebook ads.

Create an App in facebook console

The app development flow gets the bare minimum of data required to create an exclusive ID for your app. After completing the flow, you will arrive at the App Dashboard where you can either continue designing and testing your app or add more details about it.

Starting…..

Your Facebook developer account must be active

Launch the app development process.

1) : Click the “Get Started” button in the upper right corner of the page while you are on the Facebook for Developers website.

2) : You’ll need to open a Facebook account if you don’t already have one. Use your login information to access your account if you have one.

Step 1) : Creating Facebook Application & get APP name & App ID

To create Facebook App Id & App name, you can follow these steps.

A) : Open https://developers.facebook.com and create your application and you have to show like this type page

Create an app

Choose your app type , the recommended option here is Consumer. Then click on Next,.

Fill in the appName and email address here then choose Create app.

B): After you’ve finished creating the application .begin adding the Facebook Login project.

In this step select the Facebook login option and click on the Setup button. Your app ID which you can use in your Facebook ads, is located here. You’ll need this ID later so , make a note of it.

Step2 🙂 Once you have created your application click the “Set Up” button and choose “Audience Network” from  list of possibilities.

Your app ID which you can use in your Facebook ads is located here.

i)Visit Facebook Ads Manager at  https://www.facebook.com/adsmanager/ and log in to your account to get placement ID.

ii) first selecting platform then decide on the purpose of your advertisement. such as Audience Network, Facebook, Instagram etc….

iii) To create an advertisement

iv) When deciding on the platform you want to use decide what your advertisement will be used for.

v) You will be given a placement ID after choosing the placement. which you can use in your Facebook advertisements. You’ll need this ID later so make note of it.

You should able to register an app in the Facebook console and get an app ID and placement ID by following the instructions and visible screenshots provided here. Let me know if you have any other inquiries.

The steps below can be used to add Facebook Ads to a Flutter app:

You should be able to register an app in the Facebook console and get an app ID and placement ID by following the instructions and visible screenshots provided here. 

The steps below can be used to add Facebook Ads to a Flutter app:

Step 1) : Set up an app in the Facebook Developer Dashboard after creating a Facebook Developer account.

Step 2) : Your Flutter app should now include the Facebook Ads SDK. This is accomplished by including the following dependencies in your pubspec.yaml file:

dependencies:
  flutter_facebook_ads: ^any

Step 3) : Packages can be installed using the command line:

flutter pub get

Step 4) : Import file

import 'package:facebook_audience_network/facebook_audience_network.dart';

We will use testing project id and placement id to display different ads, such as banner ads and interstitial ads. To obtain a real project id, we must submit our application to Facebook for review. Once they approve, we receive project id, and we can then create placement id in accordance with our needs.

Step 5) :Install Facebook Ads SDK into your app . You can do by adding the following code your main method :

void main() {
  FacebookAds.instance.initialize(
    appId: 'your_app_id',
  );
  runApp(MyApp());
}

Types of Facebook Mobile Ads

Adding Banner Ad In Flutter App

In an app’s layout, banner ads take up space at the top or bottom of the device screen. They remain visible while users use the app and can automatically refresh after a set amount of time.

FacebookBannerAd(
       bannerSize: BannerSize.LARGE,
       keepAlive: true,
       placementId: "Your Placement ID",
     ),

Adding an Interstitial Ad

Interstitial advertisements are interactive, full-screen advertisements that hide the host app or website’s interface. These advertisements are placed at natural transition points or breaks, such as in between activities or game levels, because they appear between content.

We must first create a method to call the interstitial ad in order to add an interstitial ad to your Flutter project. If the advertisement loads successfully, the user will see it.

 FacebookInterstitialAd.loadInterstitialAd(
    placementId: "Your Placement Id",
    listener: (result, value) {
      if (result == InterstitialAdResult.LOADED)
        FacebookInterstitialAd.showInterstitialAd(delay: 2000);
    },
  );

Reward ad

Users who view Facebook reward ads receive virtual currency or other in-app rewards in exchange for watching a video ad. These advertisements are made to encourage user interaction with advertising in way that is advantageous to both the advertiser and the user.

Using the Facebook Ads SDK, you can incorporate Facebook reward ads into a Flutter application. The procedure involves loading a paid video ad, initializing the Facebook Ads SDK in your app, and presenting it to the user. The specified virtual currency or another in-app reward is given to the user after they watch the advertisement.

 _rewardedVideoAd = RewardedVideoAd(
      placementId: 'your_placement_id',
      listener: (result, value) {
        print('Rewarded Video Ad $result => $value');
        if (result == RewardedVideoAdResult.rewarded) {
          // reward user
        }
      },
    );
    _rewardedVideoAd.load();
onPressed: () {
            if (_rewardedVideoAd.isLoaded) {
              _rewardedVideoAd.show();
            }
          },

Your_placement_id should be replaced with the Placement ID you obtained from the Facebook Developer Dashboard.

The entire implementation is contained in this GitHub repository.

link here : 


Conclusion

Try out your ads. To test your ads and make sure they are functioning properly, use Facebook’s Ad Manager or the Facebook Ads Helper tool.

I hope you found this Flutter facebook ads tutorial to be useful.

I’m done now! These instructions explain how to set up paid facebook ads in a Flutter app using the Facebook Ads SDK.

Thanks for reading this article…..

Have a good day…..