Skip to content

Ads version 3.0.0 (nullsafe) Video not showing up #39

@Marek00Malik

Description

@Marek00Malik

Hello there.
Just wanted to ask if there is anything new how should we display the video ads in the beta version of the null-safe version?

This is my code:

static Future<bool> showRewardAd({required Function userReward, required Function onAdClose}) async {
    return getInstance().setVideoAd(
        show: true,
        testDevices: [],
        childDirected: false,
        adUnitId: AdManager._rewardedAdUnitId,
        contentUrl: 'https://makromapa.pl',
        keywords: <String>['food', 'fit', 'calories'],
        listener: (AdsEvent event, {String? rewardType, int? rewardAmount}) {
          if ([AdsEvent.onAdLoaded, AdsEvent.onAdOpened, AdsEvent.onAppEvent].contains(event)) {
            _logger.d("Reward Ad | Following RewardedVideoAd Event was fired - $event");
            SystemChrome.setEnabledSystemUIOverlays([]);
          }

          if (AdsEvent.onRewardedAdUserEarnedReward == event) {
            _logger.i("Reward Ad | User granted reward - $rewardType, ($rewardAmount)");
            userReward();
          }

          if (AdsEvent.onAdFailedToLoad == event) {
            _logger.e("Reward Ad | failed to load Reward Ad");
            onAdClose();
          }

          if (AdsEvent.onAdClosed == event) {
            _logger.e("Reward Ad | closed");
            onAdClose();
            SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
          }
        })
    .then((value) => getInstance().showVideoAd());
  }

...
static Ads getInstance() {
    if (_ads != null) {
      return _ads!;
    }

    _ads = Ads(
      trackingId: AdManager._appId,
      videoUnitId: AdManager._rewardedAdUnitId,
      testing: false,
      testDevices: [],
      childDirected: false,
      contentUrl: 'https://example.pl',
      keywords: <String>['test'],
      listener: _eventListener,
    );

    return _ads!;
  }

The listener gets with the AdsEvent.onAdLoaded event. There isn't anything else fired. This flow worked on the older version ;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions