loadRewardedVideoAd method

Future<PangleResult> loadRewardedVideoAd({
  1. IOSRewardedVideoConfig? iOS,
  2. AndroidRewardedVideoConfig? android,
  3. PangleEventCallback? callback,
})

Display video ad.

iOS config for iOS android config for Android callback event callback return code & message

Implementation

Future<PangleResult> loadRewardedVideoAd({
  IOSRewardedVideoConfig? iOS,
  AndroidRewardedVideoConfig? android,
  PangleEventCallback? callback,
}) async {
  final subscription = _eventChannel
      .receiveBroadcastStream(PangleEventType.rewardedVideo.index)
      .listen((dynamic event) {
    callback?.call(event);
  });
  Map<String, dynamic>? result;
  try {
    if (Platform.isIOS && iOS != null) {
      result = await _methodChannel.invokeMapMethod<String, dynamic>(
        'loadRewardedVideoAd',
        iOS.toJSON(),
      );
    } else if (Platform.isAndroid && android != null) {
      result = await _methodChannel.invokeMapMethod<String, dynamic>(
        'loadRewardedVideoAd',
        android.toJSON(),
      );
    }
  } finally {
    subscription.cancel();
  }
  return PangleResult.fromJson(result);
}