0

谁能告诉我如何使用 FBNativeAdBridgeCallback 函数?我基本上想知道图像何时完成加载,以便我可以显示它们。. 否则我有一个带有空值的原生横幅,直到 Facebook 完成加载它们。如果每个图像/文本一次加载一个,它看起来真的很难看。

它只是基本的原生广告示例脚本,我尝试像登录一样使用 IResult,但这使它变红。互联网上没有这方面的文档,甚至在 Facebook 开发者网站上也没有,我根本找不到 api。

谁能向我解释如何在下面提供的脚本中使用它?

using UnityEngine;
using UnityEngine.UI;
using System;
using System.Collections;
using System.Collections.Generic;
using AudienceNetwork;

[RequireComponent (typeof(CanvasRenderer))]
[RequireComponent (typeof(RectTransform))]
public class NativeAdTest : MonoBehaviour
{
    private NativeAd nativeAd;

    // UI elements in scene
    [Header("Text:")]
    public Text
        title;
    public Text socialContext;
    [Header("Images:")]
    public Image
        coverImage;
    public Image iconImage;
    [Header("Buttons:")]
    public Text
        callToAction;
    public Button callToActionButton;

    public GameObject hide;

    void Awake ()
    {
        // Create a native ad request with a unique placement ID (generate your own on the Facebook app settings).
        // Use different ID for each ad placement in your app.
        NativeAd nativeAd = new AudienceNetwork.NativeAd ("your placement id");
        this.nativeAd = nativeAd;

        // Wire up GameObject with the native ad; the specified buttons will be clickable.
        nativeAd.RegisterGameObjectForImpression (gameObject, new Button[] { callToActionButton });

        // Set delegates to get notified on changes or when the user interacts with the ad.
        nativeAd.NativeAdDidLoad = (delegate() {
            Debug.Log ("Native ad loaded.");
            Debug.Log ("Loading images...");
            // Use helper methods to load images from native ad URLs
            StartCoroutine (nativeAd.LoadIconImage (nativeAd.IconImageURL));
            StartCoroutine (nativeAd.LoadCoverImage (nativeAd.CoverImageURL));
            Debug.Log ("Images loaded.");
            title.text = nativeAd.Title;
            socialContext.text = nativeAd.SocialContext;
            callToAction.text = nativeAd.CallToAction;
            Debug.Log ("Native ad Luke.");
        //  hide.SetActive(false);
            //FBNativeAdBridgeCallback


        });
        nativeAd.NativeAdDidFailWithError = (delegate(string error) {
            Debug.Log ("Native ad failed to load with error: " + error);
        });
        nativeAd.NativeAdWillLogImpression = (delegate() {
            Debug.Log ("Native ad logged impression.");
        });
        nativeAd.NativeAdDidClick = (delegate() {
            Debug.Log ("Native ad clicked.");
        });



        // Initiate a request to load an ad.
        nativeAd.LoadAd ();
        //nativeAd.nat
    }

    void OnGUI ()
    {
        // Update GUI from native ad
        coverImage.sprite = nativeAd.CoverImage;
        iconImage.sprite = nativeAd.IconImage;
    }

    void OnDestroy ()
    {
        // Dispose of native ad when the scene is destroyed
        if (this.nativeAd) {
            this.nativeAd.Dispose ();
        }
        Debug.Log ("NativeAdTest was destroyed!");
    }

//  void FBNativeAdBridgeCallback(IResult result)
//  {
//      
//  }

}

提前致谢!

4

1 回答 1

0

AdView不允许您从FBNativeAdBridgeCallback(). AdView已经提供了 5 个回调,包括NativeAdDidLoad().

您的问题的解决方案是先隐藏广告,然后在您收到NativeAdDidLoad()并完成加载图像后,将广告放在前面并使其可见。无需创建新的FBNativeAdBridgeCallback().

于 2016-04-18T23:33:07.190 回答