2016-04-15 7 views
0

誰でもFBNativeAdBridgeCallback関数の使い方を教えてください。私は基本的に、画像がロードされて表示できるようになったときを知りたいと思っています。 。そうでなければ、Facebookが読み込みを完了するまで、空の値でネイティブのバナーを飛ばしています。各画像/テキストが一度に1つずつ読み込まれると、実際には見苦しいように見えます。誰でも、視聴者ネットワークのユニティでFBNativeAdBridgeCallback関数を使用する方法を知っています

これは基本的なネイティブ広告のサンプルスクリプトですが、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) 
// { 
//  
// } 

} 

ありがとうございます!

+0

「画像がロードされた」とはどういう意味ですか?バナー広告が読み込まれるようにしますか? –

+0

@NikaKasradze公開オブジェクトに実際の値がいつ含まれているかを知りたい。そうでなければ、Facebookが読み込みを完了するまで、空の値でネイティブのバナーを飛ばしています。各画像/テキストが一度に1つずつ読み込まれると、実際には見苦しいように見えます。 –

答えて

0

AdViewでは、カスタマイズしたリスナーをFBNativeAdBridgeCallback()から定義することはできません。既にAdViewが提供されています。コールバックには、NativeAdDidLoad()が含まれています。

質問を解決するには、最初に広告を非表示にしてからNativeAdDidLoad()を受信して​​画像の読み込みを完了したら、広告を前面に表示して見えるようにします。新しいFBNativeAdBridgeCallback()を作成する必要はありません。

+0

okクールな感謝はすぐにそれをテストする –

+0

問題は、CoroutineがNativeAdDidLoad()内で開始するので、私は自分のadViewを利用可能にするときに、CoroutineがDebug.Log( "ネイティブ広告ルーク」)が表示されます。カバー画像が読み込まれ、ボタン名が変わっているのを見ることができます。だから、広告を表示するにはどうすればよいですか? –

関連する問題