loadRewardedVideoAd static method

Future<bool?> loadRewardedVideoAd({
  1. String placementId = "YOUR_PLACEMENT_ID",
  2. dynamic listener(
    1. RewardedVideoAdResult,
    2. dynamic
    )?,
})

Loads a rewarded video Ad in background. Replace the default placementId with the one which you obtain by signing-up for Facebook Audience Network.

listener passes RewardedVideoAdResult and information associated with the result to the implemented callback.

Information will generally be of type Map with details such as:

{
  'placement\_id': "YOUR\_PLACEMENT\_ID",
  'invalidated': false,
  'error\_code': 2,
  'error\_message': "No internet connection",
}

Implementation

static Future<bool?> loadRewardedVideoAd({
  String placementId = "YOUR_PLACEMENT_ID",
  Function(RewardedVideoAdResult, dynamic)? listener,
}) async {
  try {
    final args = <String, dynamic>{
      "id": placementId,
    };

    if(Platform.isIOS)
      return false;

    final result = await _channel.invokeMethod(
      LOAD_REWARDED_VIDEO_METHOD,
      args,
    );
    _channel.setMethodCallHandler(_rewardedMethodCall);
    _listener = listener;

    return result;
  } on PlatformException {
    return false;
  }
}