In this tutorial, we will Learn About how to implement Rewarded video ads in flutter. Because Rewarded video is a way for developers to integrate ads into the app. Consumers can choose to watch them in replacement for points, lives, or virtual goods.

Rewarded Ads can Improve app revenue by 40% which is Exponential in the Form Of Ad revenue. Flutter can make App for Both Platform Android & iOS so its Easy to implement without wasting Extra time.

firebase & admob

What are rewarded ads?

Rewarded ads are Full-Screen Video Ads where user View ads in exchange for Some Value examples Points, lives & victual currency. Rewarded Ads are a win-win For Both Advertiser and Apps or Game Publishers.

How much Revenue gets from rewarded Video Ads?

Rewarded Video ads are the most Preferred ads Method Because of the high Revenue earnings. Rewarded Video ads eCPM can be Varies from location to Location  But let’s say the US will get eCPM from 15$ to 30$, India will get from 2$ to 5$ & Europe will get from 13$ to 15$.

eCPM meaning ‘effective cost per mille'(Per one thousand visitors).

How much Revenue Does Admob Pay for Video Ads?

Rewarded Video Ads revenue is always better than Banner ads or Interstitial ads format ANd Admob absolutely ahead of all the other ad networks in the market. Let’s say if you’re making an average 4$ from rewarded ads is Serving 10,000 impressions a day, you should earn more than 1500$ IN THE revenue from only from Rewarded video ads.

How to implement Rewarded Video Ads in Flutter

 

💻 Installation

First, you will need to add package name flutter_admob 

In the dependencies: section of your pubspec.yaml, add the following lines as :

firebase_admob: ^0.9.0+9

If you Don’t know how to Create a Flutter app, check out Getting started with Flutter official tutorial.

For Android User, AndroidManifest changes:

You Need to Add the Following Line in the androidmanifest.xml to Avoid  crash on the launch of your Android app

<meta-data
    android:name="com.google.android.gms.ads.APPLICATION_ID"
    android:value="[ADMOB_APP_ID]"/>

For iOS User, Info.plist changes:

You Need to Add the Following line Info.plist  to Avoid Crash on the launch of your iOS App

<key>GADApplicationIdentifier</key>
<string>[ADMOB_APP_ID]</string>

Add import 'package:firebase_admob/firebase_admob.dart';

okay After that We need to create variable for storing mobile_id  

const String testDevice = 'Mobile_id';

Let’s create MobileAdTargetingInfo for specifying keywords, test device Id & nonpersonalised ads

static const MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo(
  testDevices: testDevices != null ? <String>['testDevices'] : null,
  keywords: <String>['Book', 'Game'],
  nonPersonalizedAds: true,
);

Create two variables, first variable for Storing Coin value & second for RewardedVideoads  

  int _coins = 0;
  RewardedVideoAd videoAd = RewardedVideoAd.instance;

After that, we need to Create InitState method for Initialize RewardedAds Listener

InitState is the first method called whenever the widget is created by the Flutter App.

@override
void initState() {
  super.initState();
  FirebaseAdMob.instance.initialize(appId: FirebaseAdMob.testAppId);

  videoAd.listener =
      (RewardedVideoAdEvent event, {String rewardType, int rewardAmount}) {
    print("REWARDED VIDEO AD $event");
    if (event == RewardedVideoAdEvent.rewarded) {
      setState(() {
        _coins += rewardAmount;
      });
    }
  };
}

So Above Code videoad.listner will update _coins value with the help of setstate() method

In Scaffold widget, add Two Raised Button for initializing functionality so the first button for Loading the Rewarded Ads & second Variable for showing the Rewarded Ads.

We are using the column widget Because we wanted to show Raised in a vertical manner.

Column(
         mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              Text('LOAD REWARDED VIDEO AD'),
              RaisedButton(
                child: Text("LOAD REWARDED AD"),
                onPressed: () {
                  videoAd.load(
                      adUnitId: RewardedVideoAd.testAdUnitId,
                      targetingInfo: targetingInfo);
                },
              ),
              RaisedButton(
                child: Text("SHOW REWARDED VIDEOAD"),
                onPressed: () {
                  videoAd.show();
                },
              ),
              Text("YOU HAVE $_coins coins"),
            ],
          ),

on the Load RaisedButton onPressed() method implement videoAd.load() which will give a two property

  • First will be used to Add adUnitId
  • The second will be used to add tragetingInfo (All ready implement at top of the code)

& on the Show RaisedButton onPressed() method initialise videoAd.show()

Our 📷Final App will look like this:

🤝 Show some support

If you liked the app, show some love Here⭐️

You can see the full source code of the project here.

Enjoyed the Tutorial? Please leave a LIKE 👍 to show your support For Hardwork

💬 If you have a question about anything in the Tutorial, leave me a comment and I’ll do my best to answer your question.