Thông số yêu cầu theo mạng cụ thể

Một số bộ chuyển đổi mạng hỗ trợ các thông số bổ sung có thể được truyền đến bộ chuyển đổi khi yêu cầu quảng cáo được tạo. Đây được gọi là nội dung bổ sung của mạng truyền hình.

Trình bổ trợ Quảng cáo của Google trên thiết bị di động cung cấp các API trên Android và iOS, cho phép bạn truyền các thông tin bổ sung về mạng đến bộ chuyển đổi dàn xếp. Để làm như vậy, bạn cần triển khai MediationNetworkExtrasProvider trên Android và FLTMediationNetworkExtrasProvider trên iOS, sau đó đăng ký việc triển khai trình cung cấp tiện ích bổ sung với trình bổ trợ. Sau đó, trình bổ trợ sẽ sử dụng thông số này để truyền các thông số bổ sung về mạng khi tạo yêu cầu quảng cáo trên Android hoặc iOS.

Đăng ký MediationNetworkExtrasProvider trên Android

Tạo một phương thức triển khai 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;
  }
}

Sau đó, hãy đăng ký bằng 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());
  }
}

Bạn có thể xem những phần bổ sung được các mạng truyền hình hỗ trợ và cách tạo các phần bổ sung đó trong tài liệu tham khảo Android cho mạng truyền hình cụ thể.

Đăng ký FLTMediationNetworkExtrasProvider trên iOS

Tạo một phương thức triển khai 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

Sau đó đăng ký với 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

Bạn có thể xem những phần bổ sung được các mạng truyền hình hỗ trợ và cách tạo các phần bổ sung đó trong tài liệu tham khảo iOS cho mạng truyền hình cụ thể.

Ví dụ hoàn chỉnh trên GitHub

Mẫu của chúng tôi minh hoạ cách đặt các thông số tuỳ chỉnh trên AppLovin trong một quy trình tích hợp.

Dàn xếp