UnityAdsLoadError.invalidArgument adMarkup 丢失; objectId 丢失

问题描述 投票:0回答:1

我在我的 flutter 应用程序中使用统一广告并遇到一些问题

I/flutter (15728):横幅广告 Banner_Android 失败:UnityAdsBannerError.noFill 放置未收到填充 E/UnityAds(15728): com.unity3d.services.core.api.Sdk.logError() (line:88) :: 标头竞价加载调用失败:adMarkup 丢失;缺少对象 ID I/flutter (15728): 加载失败 Interstitial_Android: UnityAdsLoadError.invalidArgument adMarkup 丢失; objectId 丢失

我在日志中获取此信息,但我的广告没有显示...帮助我解决此问题。 我正在使用

unity_ads_plugin

我想在我的应用程序中展示广告。

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:unity_ads_plugin/unity_ads_plugin.dart';

class Ads {
  bool iscorrect_platform = Platform.isAndroid || Platform.isIOS;
  static Ads_init() async {
    if (Ads().iscorrect_platform) {
      await UnityAds.init(
        gameId: 'XXXXXXXX',
        testMode: true,
        onComplete: () {
          print('Initialization Complete');
          Ads.Load_Banner_Ads();
          Ads.Load_Interstitial_Ads();
        },
        onFailed: (error, message) =>
            print('Initialization Failed: $error $message'),
      );
    }
  }

  static Widget Show_Banner_Ads() {
    if (Ads().iscorrect_platform) {
      return UnityBannerAd(
        placementId: 'Banner_Android',
        onLoad: (placementId) => print('Banner loaded: $placementId'),
        onClick: (placementId) => print('Banner clicked: $placementId'),
        onShown: (placementId) => print('Banner shown: $placementId'),
        onFailed: (placementId, error, message) =>
            print('Banner Ad $placementId failed: $error $message'),
      );
    }
    return Center();
  }

  static Load_Banner_Ads() async {
    if (Ads().iscorrect_platform) {
      String Pid = "Banner_Android";
      await UnityAds.load(
        placementId: Pid,
        onComplete: (placementId) => print('Load Complete $placementId'),
        onFailed: (placementId, error, message) =>
            print('Load Failed $placementId: $error $message'),
      );
    }
  }

  static Load_Interstitial_Ads() async {
    if (Ads().iscorrect_platform) {
      String Pid = "Interstitial_Android";
      await UnityAds.load(
        placementId: Pid,
        onComplete: (placementId) => print('Load Complete $placementId'),
        onFailed: (placementId, error, message) =>
            print('Load Failed $placementId: $error $message'),
      );
    }
  }

  static show_Interstitial_Ads() async {
    if (Ads().iscorrect_platform) {
      String Pid = "Interstitial_Android";
      UnityAds.showVideoAd(
        placementId: Pid,
        onStart: (placementId) => print('Video Ad $placementId started'),
        onClick: (placementId) => print('Video Ad $placementId click'),
        onSkipped: (placementId) => print('Video Ad $placementId skipped'),
        onComplete: (placementId) => print('Video Ad $placementId completed'),
        onFailed: (placementId, error, message) =>
            print('Video Ad $placementId failed: $error $message'),
      );
    }
  }
}

这是我用来展示广告的代码。

flutter ads unityads
1个回答
0
投票

这可能是 Unity 的问题,而不是你的游戏的问题。 Unity 很难为您的游戏拉出足够的广告,甚至很难为演示提供示例横幅。您可能会在此处的 Unity 论坛上找到所需的更多信息。

https://discussions.unity.com/t/could-not-show-banner-due-to-no-fill-for-placement/728083/21

© www.soinside.com 2019 - 2024. All rights reserved.