initialize static method

Future<void> initialize({
  1. required String gameId,
  2. Function? onComplete,
  3. dynamic onFailed(
    1. InitializationError error,
    2. String errorMessage
    )?,
})

Initializes the Unity Mediation. It is mandatory to call this method before any InterstitialAd and RewardedAd can load.

  • gameId - The game ID listed in publisher dashboard.
  • onComplete - called when initialization has completed successfully.
  • onFailed - called when initialization has failed.

Implementation

static Future<void> initialize({
  required String gameId,
  Function? onComplete,
  Function(InitializationError error, String errorMessage)? onFailed,
}) async {
  Map<String, dynamic> arguments = {
    gameIdParameter: gameId,
  };
  _channel.setMethodCallHandler(
      (call) => _initMethodCall(call, onComplete, onFailed));
  await _channel.invokeMethod(initMethod, arguments);
}