Facebook Audience Network Unity SDK 4.99 Upgrade Guide

What's New?

  1. We added NativeBannerAd in the Unity SDK 4.99 release. NativeBannerAd is used for showing a native ad without the ad image or video. In a native banner ad, ad icon, ad title, ad CTA button, and ad choices icon are still required to be shown to users.

    If using NativeBannerAd, you will need to select the 'Native banner' format for your placement in Monetization Manager. If you are updating from NativeAd to NativeBannerAd you may continue to use the same placement, but you will need to update the format type.



  2. We added following new properties in the NativeAd and NativeBannerAd interfaces:
    New Method Description

    AdvertiserName

    Get the name of the Facebook Page or mobile app that represents the business running each ad.

    Headline

    Get the headline that the advertiser entered when they created their ad. This is usually the ad's main title.

    LinkDescription

    Get additional information that the advertiser may have entered.

    SponsoredTranslation

    Get the word 'sponsored', translated into the language based upon Facebook app language setting.

    AdTranslation

    Get the word 'ad', translated into the language based upon Facebook app language setting.

    PromotedTranslation

    Get the word 'promoted', translated into the language based upon Facebook app language setting.


What has changed?

In this new release, we have a few APIs that have been changed for better ad quality.

  1. In order to enable a wider variety of native ad types (video ads, carousel, etc...), instead of using Unity game objects to present the native ad, the Audience Network SDK will overlay native iOS/Android views on top of Unity's game objects by calling RegisterGameObjectsForInteraction.
  2. Minor NativeAd interface changes (notice that NativeBannerAd shares the same interface): RegisterGameObjectForImpression is replaced by RegisterGameObject and is no longer being used for registering objects for impression/interaction. It is still mandatory to call RegisterGameObject before loading an ad.
  3. Ad Choices prefab now downloads the Ad Choices Image on itself by calling SetAd.

What has been removed?

In this new release, we have removed some APIs for better ad quality.

  1. CoverImageURL and IconImageURL are no longer exposed and you don't need to download them separatly from loading the ad. Calling RegisterGameObjectsForInteraction will present the ad assets.

  2. NativeAd interface removal:
    • LoadCoverImage is removed.
    • LoadIconImage is removed.
    • LoadAdChoicesImage is removed.

Migration Steps

Remove the older version of Audience Network Android SDK from your Android Studio project and replace with the latest one, downloaded from the downloads page.

Code to load native ad before:

private NativeAd nativeAd;
// Create a native ad request with a unique placement ID 
nativeAd = new AudienceNetwork.NativeAd("YOUR_PLACEMENT_ID");
nativeAd.RegisterGameObjectForImpression(gameObject, new Button[] { callToActionButton });
nativeAd.NativeAdDidLoad = (delegate() {
    // Download images and show text once ad is loaded
    StartCoroutine(nativeAd.LoadIconImage(nativeAd.IconImageURL));
    StartCoroutine(nativeAd.LoadCoverImage(nativeAd.CoverImageURL));
    StartCoroutine(nativeAd.LoadAdChoicesImage(nativeAd.AdChoicesImageURL));
    title.text = nativeAd.Title;
    socialContext.text = nativeAd.SocialContext;
    callToAction.text = nativeAd.CallToAction;
});
...
// Initiate a request to load an ad.
nativeAd.LoadAd();

Code to load native ad using Unity 4.99 release:

private  NativeAd nativeAd;
// Create a native ad request with a unique placement ID 
nativeAd = new AudienceNetwork.NativeAd("YOUR_PLACEMENT_ID");
nativeAd.RegisterGameObject(gameObject);
nativeAd.NativeAdDidLoad = (delegate() {
            // Register game objects for interactions. MediaView will be used for impression logging. CallToActionButton will be used for click logging.
            nativeAd.RegisterGameObjectsForInteraction((RectTransform)mediaView.transform, (RectTransform)callToActionButton.transform,
                    (RectTransform)iconImage.transform);
            advertiserName.text = nativeAd.AdvertiserName;
            socialContext.text = nativeAd.SocialContext;
            callToActionButton.text = nativeAd.CallToAction;
        });
...
// Initiate a request to load an ad.
nativeAd.LoadAd();