Related Resources

Our Services

You May Also Like

How to Implement Ads in your application - Flutter

karan chodavadiya

Dec 20, 2022

4 min readLast Updated Jan 03, 2023

Generating value from apps is foremost among objectives for many decision makers — it’s crucial for developers to understand how to effectively monetize the applications they create.

Mobile compatible ads are shown while interacting with the app.

On this blog we are going for getting some extra knowledge about Ads.

there are so many Ads platforms available for your applications here is the list of some ads platforms:

  1. Google AD mob
  2. Facebook Ads SDK
  3. MOpub - by twitter
  4. StartApp SDK
  5. Vungle

You can use any of this for monetize your application in both platform Android and iOS.

Prepare test ads

While you are still developing your app, it’s advisable to test your app with test ads and not the real ads.

(Note: Testing the real ads by yourself can send the wrong signal to Google and your account may be suspended. Additionally, if you are testing the app on an emulator, test ads are automatically enabled)

There are a couple of ways you can enable the test ads for real devices.

  1. Using demo test IDs
  2. Adding your device to the testing list

Using demo test IDs

Using the demo test IDs is the easiest and fastest way to test ads. You just need to copy and paste the IDs and you can continue testing your app.

You can keep these demo IDs in a separate Dart file and then call from the app when required like this:

// ad_helper.dart
import 'dart:io';

class AdHelper {
  static String get bannerAdUnitId {
    if (Platform.isAndroid) {
      return 'ca-app-pub-3940256099942544/6300978111';
    } else if (Platform.isIOS) {
      return 'ca-app-pub-3940256099942544/2934735716';
    } else {
      throw new UnsupportedError('Unsupported platform');
    }
  }
}

in android there is no any privacy and security requirement for impliment the Ads but in iOS we have to work also with ATT("App Tracking Transparency").

What is ATT("App Tracking Transparency") :

App Tracking Transparency, or ATT for short, is Apple's opt-in privacy framework that requires all iOS apps to ask users for permission to share their data. This is done in the form of a popup where users can either consent or deny tracking.

  • You must use the AppTrackingTransparency framework if your app collects data about end users and shares it with other companies for purposes of tracking across apps and web sites.
  • The AppTrackingTransparency framework presents an app-tracking authorization request to the user and provides the tracking authorization status.

Advantage of using ATT("App Tracking Transparency") is ads platform are not able to steal your user personal data and device data.

How to implement ATT("App Tracking Transparency") In your  flutter application :

For Using ATT(App Tracking Transparency) in flutter there is a one package available:

package :- app_tracking_transparency

Implementing is not difficult. You can simply follow the example in the package.

On your main page you can add something like this:


  @override
  void initState() {
    initPlugin();
    super.initState();
  }


Future<void> initPlugin() async {

//if you have any conditions, you can add a if loop here
  try {
    final TrackingStatus status =
    await AppTrackingTransparency.trackingAuthorizationStatus;
    setState(() => _authStatus = '$status');
    // If the system can show an authorization request dialog
    if (status == TrackingStatus.notDetermined) {
      // Show a custom explainer dialog before the system dialog
      if (await showCustomTrackingDialog(context)) {
        // Wait for dialog popping animation
        await Future.delayed(const Duration(milliseconds: 200));
        // Request system's tracking authorization dialog
        final TrackingStatus status =
        await AppTrackingTransparency.requestTrackingAuthorization();
        setState(() => _authStatus = '$status');
      }
    }
  } on PlatformException {
    setState(() => _authStatus = 'PlatformException was thrown');
  }

  final uuid = await AppTrackingTransparency.getAdvertisingIdentifier();
  print("UUID: $uuid");

  // Platform messages may fail, so we use a try/catch PlatformException.

}

Also, you will need to create the following alert box for users to enter. Before users select whether they want to be tracked, you can have a pop-up that tries to encourage users to allow themselves to be tracked.

Future<bool> showCustomTrackingDialog(BuildContext context) async =>
    await showDialog<bool>(
      context: context,
      builder: (context) =>
          AlertDialog(
            title: const Text('Dear User'),
            content: const Text(
              'We care about your privacy and data security. We keep this app free by showing ads. '
                  'Can we continue to use your data to tailor ads for you?\n\nYou can change your choice anytime in the app settings. '
                  'Our partners will collect data and use a unique identifier on your device to show you ads.',
            ),
            actions: [
              TextButton(
                onPressed: () => Navigator.pop(context, true),
                child: const Text('Continue'),
              ),
            ],
          ),
    ) ??
        false;

Once you are done, the app transparency should be working fine. The end result should look something like this:

its time to show user that app is using your personal data it should be look like this:

This is all done for implement Ads in your flutter application with android and iOS with provided security and also with ATT.

Projects Completed till now.

Discover how we can help your business grow.

"Third Rock Techkno's work integrates complex frameworks and features to offer everything researchers need. They are open-minded and worked smoothly with the academic subject matter."

- Dr Daniel T. Michaels, NINS