Network Specific Request Parameters

Some network adapters support additional parameters which can be passed to the adapter when the ad request is created. These are referred to as network extras.

The Google Mobile Ads plugin provides APIs on Android and iOS that let you pass network extras to mediation adapters. To do so, you need to implement MediationNetworkExtrasProvider on Android and FLTMediationNetworkExtrasProvider on iOS, and then register your extras provider implementation with the plugin. Afterwards the plugin will use it to pass through network extras when it creates the ad request on Android or iOS.

Register your MediationNetworkExtrasProvider on Android

Create an implementation of MediationNetworkExtrasProvider:

class MyMediationNetworkExtrasProvider implements MediationNetworkExtrasProvider {

  @Override
  public Map<Class<? extends MediationExtrasReceiver>, Bundle> getMediationExtras(
      String adUnitId, @Nullable String identifier) {
    // This example passes extras to the AppLovin adapter.
    // This method is called with the ad unit of the associated ad request, and
    // an optional string parameter which comes from the dart ad request object.
    Bundle appLovinBundle = new AppLovinExtras.Builder().setMuteAudio(true).build();
    Map<Class<? extends MediationExtrasReceiver>, Bundle> extras = new HashMap<>();
    extras.put(ApplovinAdapter.class, appLovinBundle);
    // Note: You can pass extras to multiple adapters by adding more entries.
    return extras;
  }
}

Then register it with the GoogleMobileAdsPlugin:

// Register a MediationNetworkExtrasProvider with the plugin.
public class MainActivity extends FlutterActivity {

  @Override
  public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
    super.configureFlutterEngine(flutterEngine);

    // Register your MediationNetworkExtrasProvider to provide network extras to ad requests.
    GoogleMobileAdsPlugin.registerMediationNetworkExtrasProvider(
        flutterEngine, new MyMediationNetworkExtrasProvider());
  }
}

You can see which extras are supported by different networks and how to construct them in the Android reference for the specific network.

Register your FLTMediationNetworkExtrasProvider on iOS

Create an implementation of FLTMediationNetworkExtrasProvider:

@implementation MyFLTMediationNetworkExtrasProvider

- (NSArray<id<GADAdNetworkExtras>> *_Nullable)getMediationExtras:(NSString *_Nonnull)adUnitId
                                       mediationExtrasIdentifier:
                                           (NSString *_Nullable)mediationExtrasIdentifier {
  // This example passes extras to the AppLovin adapter.
  // This method is called with the ad unit of the associated ad request, and
  // an optional string parameter which comes from the dart ad request object.
  GADMAdapterAppLovinExtras *appLovinExtras = [[GADMAdapterAppLovinExtras alloc] init];
  appLovinExtras.muteAudio = NO;
  // Note: You can pass extras to multiple adapters by adding more entries.

  return @[ appLovinExtras ];
}
@end

And register it with FLTGoogleMobileAdsPlugin:


@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [GeneratedPluginRegistrant registerWithRegistry:self];

  // Register your network extras provider if you want to provide
  // network extras to specific ad requests.
  MyFLTMediationNetworkExtrasProvider *networkExtrasProvider =
      [[MyFLTMediationNetworkExtrasProvider alloc] init];
  [FLTGoogleMobileAdsPlugin registerMediationNetworkExtrasProvider:networkExtrasProvider
                                                          registry:self];
  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

@end

You can see which extras are supported by different networks and how to construct them in the iOS reference for the specific network.