Can anyone provide guidance to implement mediation in flutter?

301 views
Skip to first unread message

Alex Cretney

unread,
Nov 21, 2023, 5:04:01 AM11/21/23
to Google Mobile Ads SDK Developers
I am trying to setup some waterfall mediation partners in my flutter project because i understand this is the only way to get un-targeted ads. 

If i understand the flutter mediation guidance correctly, the implementation steps are as follows..

1) Setup my account with the mediation partner 

2) Add the partners mediation adapters in my build.gradle (android) and podfile (ios) as per the network specific instructions under the Android/IOS docs 

3) Use each networks API (which i can now access via those adapters) to pass it my users consent info

Under point 3 - The whole area of using a 'method channel' to invoke platform specific code is totally new to me. I am not very familiar with Java or Swift and need a bit of help. 

I have attached a screenshot of my MainActivity.java file where i have created a function as per the implementation guidance for InMobi

Having added this code... my project fails to build with an error suggesting that a class 'JSONObject' is unrecognised. My understanding is that this class is MEANT to provided by the InMobi SDK... 

I am wondering if the InMobi SDK has actually imported correctly... I followed both the instructions given..

i.e, Added the following 2 implementation dependencies in my app level build.grade
  • implementation 'com.google.android.gms:play-services-ads:22.5.0'
  • implementation 'com.google.ads.mediation:inmobi:10.6.0.0'
I added the following imports into my MainActivity.java file
  • import com.inmobi.sdk.InMobiSdk;
  • import com.google.ads.mediation.inmobi.InMobiConsent;
Is there some other step i need to do to import the SDK? If anyone can provide any guidance it would be much appreciated. 

I've attached a screenshot showing my full MainActivity.java file along with my error log when i try to create a build

Screenshot 2023-11-21 at 09.04.07.png

Test Dvd

unread,
Nov 21, 2023, 7:10:41 AM11/21/23
to Google Mobile Ads SDK Developers
Hi Alex,

How does inmobi work?
If the user accepts the consent, will you get Google ads and if they reject it, will you get non-personalized ads?

Is inmobi allowed by Google Admob?

Who makes your deposit?

I use flutter but my knowledge is very little so I wouldn't know how to implement the sdk.

Alex Cretney

unread,
Nov 21, 2023, 10:19:02 AM11/21/23
to Google Mobile Ads SDK Developers
Hey Test,

InMobi is basically another version of Admob https://www.inmobi.com/ 

However they don't seem to have a Flutter SDK so i'm trying to use them as a network provider within a Waterfall mediation setup. Some sort of waterfall setup is apparently necessary to get  limited ads as per the below comment from one of the support folks on another thread. 

"Regarding mediation for limited ads:
Beginning January 16, 2024, if a partner does not adopt a Google-certified CMP, only Limited Ads will be eligible to serve on EEA and UK traffic. Per the Limited Ads “Demand Eligibility” section, the initial offering for Limited Ads is just waterfall mediation, meaning no ads are returned from the AdMob network."

The problem is that the instructions for adding a mediation partner in the flutter guidances is basically to "go write some platform specific android (Java) and ios (Swift) code" which leaves a flutter developer like me a bit stumped when it doesn't simply work hence the request for help

In answer to your questions:

Would Inmobi serve ads? I hope so so long as the users don't uncheck any of the legitimate interest toggles (which they shouldn't be given the ability to do in the first place but enough has been said on that). My problem right now is getting them the consent data to start with

Is it allowed by Admob? Absolutely, inmobi are listed as an official ad network partner and admob even provide implementation instructions for Android and IOS [https://developers.google.com/admob/android/mediation/inmobi] (This is where the flutter guidance sends you)

Who pays you? I have no idea... I was just going to see what account the money lands in... ;)

Test Dvd

unread,
Nov 21, 2023, 11:19:01 AM11/21/23
to Google Mobile Ads SDK Developers
Hi Alex,

You mean if there is no consent, limited ads will be shown. Since Admob does not serve them, would inmobi.com ads be displayed? is that so?

I understand that inmobi must be added to the mediation in Admob, right?

On the website you told me [https://developers.google.com/admob/android/mediation/inmobi] you can see the configuration and how to add inmobi to Admob.

But something will have to be done in the app for it to use mediation, right?

I found this package but I don't know if it works: https://pub.dev/packages/inmobi_plugin/versions

We should ask inmobi directly if it is possible to use it with Flutter

Test Dvd

unread,
Nov 21, 2023, 11:26:31 AM11/21/23
to Google Mobile Ads SDK Developers
I see that inmobi pay because they ask for a payment method

Mobile Ads SDK Forum Advisor

unread,
Nov 21, 2023, 10:03:17 PM11/21/23
to monkey...@gmail.com, google-adm...@googlegroups.com

Hi Alex,

Thank you for contacting the Mobile Ads SDK support team.

After reviewing your concern, I understand that you need guidance to implement mediation in Flutter.

AdMob mediation is a feature that lets you serve ads to your apps from multiple sources, including the AdMob Network, third-party ad networks, and AdMob campaigns. AdMob mediation helps maximize your fill rate and increase your monetization by sending ad requests to multiple networks to ensure you find the best available network to serve ads. Case study.

Prerequisites: Integrate Google Mobile Ads SDK for Flutter.

Step 1: Create an AdMob Account

  • If you don’t already have an AdMob account, head over to the AdMob website and sign up. Once you have an account, create a new AdMob ad unit for your app. An ad unit is a unique identifier for the ad placement within your app.

Step 2: Add AdMob Plugin

  • In your Flutter project, open the `pubspec.yaml` file, and add the AdMob plugin to your  dependencies. The AdMob plugin for Flutter can be found on pub.dev.
    • yaml
      • dependencies:
        flutter:
        sdk: flutter
        firebase_admob: ^0.11.0+1
  • After adding the dependency, run `flutter pub get` to download and install the plugin.

Step 3: Initialize AdMob

  • In your main.dart file, import the AdMob plugin and initialize it with your AdMob app ID. You can find your app ID in the AdMob console.
    • dart
      import ‘package:flutter/material.dart’;
      import ‘package:firebase_admob/firebase_admob.dart’;
      • void main() {WidgetsFlutterBinding.ensureInitialized();
      • FirebaseAdMob.instance.initialize(appId: ‘YOUR_ADMOB_APP_ID’);
      • runApp(MyApp()); }

Step 4: Create Ad Widgets

  • Next, you need to create widgets to display the ads in your app. 
  • Banner Ad:
    • dart
      • class BannerAdWidget extends StatelessWidget {
        @override
        Widget build(BuildContext context) {
        return Container(
        alignment: Alignment.center,
        child: AdWidget(
        ad: AdManager.bannerAdUnitId != null
        ? BannerAd(
        adUnitId: AdManager.bannerAdUnitId,
        size: AdSize.banner,
        )
        : SizedBox(), // Handle case when adUnitId is not set.
        ),);}}

Kindly refer to our Google Flutter sample application for your implementation as a reference. Kindly make sure that you've followed this guide on getting started with Flutter for mediation.

I hope this helps!

This message is in relation to case "ref:!00D1U01174p.!5004Q02qUGYB:ref"

Thanks,
 
Google Logo Mobile Ads SDK Team


Mobile Ads SDK Forum Advisor

unread,
Nov 21, 2023, 10:09:53 PM11/21/23
to testear....@gmail.com, google-adm...@googlegroups.com

Hi,

Thank you for contacting the Mobile Ads SDK support team.

I see that you have already raised this concern on another thread with the subject 'Can anyone provide guidance to implement mediation in flutter?', and we have already responded there for this issue. To avoid multiple threads on the same issue, please take a look at that thread and continue the discussion on the same for further updates on the issue.

This message is in relation to case "ref:!00D1U01174p.!5004Q02qUH0A:ref"


Thanks,
 
Google Logo Mobile Ads SDK Team


Test Dvd

unread,
Nov 22, 2023, 5:55:47 AM11/22/23
to Google Mobile Ads SDK Developers
What kind of answer is that?

The firebase_admob plugin will be deprecated in April 2021 in favor of Google Mobile Ads SDK for Flutter (https://pub.dev/documentation/firebase_admob/latest/)

With this kind of help, this is how we are doing....

Alex Cretney

unread,
Nov 23, 2023, 5:24:58 AM11/23/23
to Google Mobile Ads SDK Developers
Thanks for the response but the admob plugin is discontinued and these instructions no longer match the reality. 

If you used ChatGPT to generate that answer then this would explain it... The knowledge base of ChatGPT only runs up until 2021 which is why it cannot be used to provide implementation guidance on anything recent. 

I need someone who has actually successfully implemented mediation in a flutter project to respond, or a google engineer who know's how to do it since the move to google_mobile_ads

Kind regards
Alex

Test Dvd

unread,
Nov 23, 2023, 6:05:18 AM11/23/23
to Google Mobile Ads SDK Developers
Hi Alex,

To use inmobi, does the ump sdk work? Or do we have to install another one?

P.S. I have written an email to inmobi and have not had a response in two days.

Mobile Ads SDK Forum Advisor

unread,
Nov 23, 2023, 9:13:20 AM11/23/23
to testear....@gmail.com, google-adm...@googlegroups.com

Hi Alex,

Thank you for getting back to us.

I can help answer your questions regarding AdMob mediation consent for partner networks:

Yes, you will need to display a consent screen for each partner network separately, as Google is currently unable to pass the user's consent choice to such networks automatically.

The User Messaging Platform (UMP) SDK is enough to obtain user consent for AdMob, but it is not enough to pass the user's consent choice to partner networks automatically. You will need to use the partner network's API to provide user consent to them.

I will check with our team regarding your query related to implementing mediation in flutter 

and one of my team members will reach out to you once we have an update on this. Meanwhile, your patience is highly appreciated.

 

Test Dvd

unread,
Nov 24, 2023, 4:08:39 AM11/24/23
to Google Mobile Ads SDK Developers
Hi Mobile Ads,

Do you mean that if we have two advertising networks with mediation, we have to ask for consent twice?

And if we have 7 networks, do we have to request it 7 times?
If the user accepts the consent of the 7 networks, for example, what ads appear? from what network?

Mobile Ads SDK Forum Advisor

unread,
Nov 28, 2023, 12:02:35 AM11/28/23
to testear....@gmail.com, google-adm...@googlegroups.com
@TestDvd

You only need to gather consent once. You will need to check with each ad network how they read consent. 
Sivasathyamoorthy Sakthivel is correct that depending on the ad network, you may have to forward to consent information the ad network. Please check the ad network APIs for more specific information. 

@AlexCretney

To further troubleshoot you original question, can you share a sample application of the issue you are seeing so I can take a closer look?
 

If the file(s) you are looking to share are less than 25mb in total you can attach them to this case on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, you can share your files with me by performing the following steps:

 

1. Navigate to

https://docs.google.com/forms/d/e/1FAIpQLSfkAiXMeYP-fw1W3Z-tT9uwmATEKO5X6S-th0gR2ezdKaaqfg/viewform?usp=pp_url&entry.400550049=Mobile+Ads+SDK&entry.460850823=5004Q00002qUGYBQA4&entry.80707362=00211788

2. Fill out all fields, and attach your file(s).

3. Please reply back on this thread when you have uploaded your file(s). Please do not share this link.


Thanks,
Justin



ref:!00D1U01174p.!5004Q02qUGYB:ref
Reply all
Reply to author
Forward
0 new messages