Unified Platform – Android SDK 10

SDK 10 is the launch of our unified platform with Fyber and unifies the core features of Heyzap and Fyber into a single stack. With the unified platform, you’ll be able to use our newest features while also gaining access to both dashboards.

From an integration perspective, the only major change is the replacement of network SDKs with adapter bundles.

Requirements

The Heyzap/Fyber Unified Platform works on Android 2.3.3 and above.

Step 1. Configure Dynamic Documentation

Select the version of the SDK you wish to view documentation for, and then select the networks you are integrating. The documentation on this page will update with specific instructions that may apply to your selections.

Network Selection:

Step 2. Add the SDK and third party networks to your project

Upgrading from SDK 9? Start by deleting your old Heyzap SDK, and all 3rd-party ads SDKs.

SDK v10.3.0

Unzip the downloaded file.

Android Studio Users

Add the following to your build.gradle

  
  

Copy the included heyzap-unified-platform-10.3.0.aar to your libs folder.

Eclipse Users

Copy the included heyzap-unified-platform-10.3.0.jar to your libs folder.

AdColony

AdMob

Apple iAd

AppLovin

Chartboost

Facebook Audience Network

HyprMX

InMobi

MoPub

Tapjoy

UnityAds

Vungle

Step 3. Modify your Android Manifest

Network Credentials

Add the following entries to the application section of your AndroidManifest.xml:



Android Studio Users

All permissions and activities are automatically included through the gradle dependencies added above. No additional manifest changes are required.

Eclipse Users

Mandatory Permissions

Add the following permissions to your AndroidManifest.xml:



Optional Permissions

The following permissions are not required for our SDK and 3rd-party SDKs to function, but including them in your AndroidManifest.xml may result in improved eCPM and user experience:



Activities

Add the following activities to your AndroidManifest.xml:



Google Play Services

The Google Play Services SDK must be added to your project for these networks. Follow Google's documentation on integrating the Google Play Services SDK into your app. Only the Ads and Location APIs need to be included.

Step 4. Initialize the SDK

In your root Activity, start the Heyzap SDK:

import com.heyzap.sdk.ads.HeyzapAds;

Activity activity = this; // must be an Activity
// Your Publisher ID is: <PUBLISHER ID>
HeyzapAds.start("<PUBLISHER ID>", activity);

Step 5: Test your 3rd-party Integrations (Optional)

The mediation SDK comes with a Mediation Test Suite that you can use to test each of the networks you've chosen:

The first screen lets you pick a network. Once you choose a network, you'll see if:

  1. The network is installed correctly.
  2. The network has valid credentials on your dashboard.
  3. The network is enabled on your dashboard.

From here, you can select a type of ad (Interstitial, Video, Incentivized, or Banner), fetch that ad, and then display it.

To use the Mediation Test Suite, simply call this method after you start the SDK:

HeyzapAds.startTestActivity(activity);

At this point, you should launch the Mediation Test Suite and verify that each network you want to use has the correct credentials and shows ads correctly.

Step 6. Show Ads

Methods you call on the Heyzap SDK will automatically dispatch to your enabled 3rd-party SDKs; a call to display will iterate over ad networks in order of expected CPM until it finds one that has an ad, optimizing CPM and fill rate. Use the code below to display your preferred ad format:

Interstitial Ads

import com.heyzap.sdk.ads.InterstitialAd;

// InterstitialAds are automatically fetched from our server
InterstitialAd.display(this);

Video Ads

Version 9 of the Heyzap SDK included an API that could be used to display only interstitial video ads. The unified platform's server-side configuration options have made this API redundant, and it has been removed. If you would like to display only video ads, please use the InterstitialAd API, and set your game's "Blended Video" option to "Enabled: show ONLY video". This option can be found under "Publisher Settings" for your game.

Rewarded Video Ads

Unlike interstitial ads, video ads are not pre-cached automatically. They must be fetched manually. Depending on the available internet connection, it may take some time to fully download the necessary assets, so it is strongly recommended fetching at the earliest point in your application lifecycle, and following the view of any video ad.

import com.heyzap.sdk.ads.IncentivizedAd;

// As early as possible, and after showing a rewarded video, call fetch
IncentivizedAd.fetch();

Later, such as after a level is completed, you can check if the ad has fetched, and display the ad if it is available.

if (IncentivizedAd.isAvailable()) {
    IncentivizedAd.display(this);
}

Banner Ads

Heyzap mediates banners from AdMob and Facebook Audience Network. We don't currently have our own banners offering, so you'll need to have one of these networks integrated to use them.

Note: Most banner networks have a setting on their dashboard to automatically refresh at a given time interval. If you want to use this feature, it is strongly recommended that you use the same time interval on all of the banner networks you are using. Different refresh rates for different networks can result in confusing impression statistics.

import com.heyzap.sdk.ads.BannerAdView;

private BannerAdView bannerAdView;

@Override
public void onCreate(Bundle savedInstanceState) {
    // ...

    Activity activity = this; // Must be an Activity.
    bannerAdView = new BannerAdView(activity);

    // This must be some view in your layout.
    FrameLayout bannerWrapper = (FrameLayout) findViewById(R.id.banner_wrapper);

    // Add the banner ad view to the wrapper.
    bannerWrapper.addView(bannerAdView);

    // Load the banner ad.
    bannerAdView.load();
}

You should also destroy the banner ad view in the onDestroy method of your Activity.

@Override
protected void onDestroy() {
  bannerAdView.destroy();
  super.onDestroy();
}

Offer Wall

The combined platform SDK provides access to the Fyber Offer Wall as of SDK version 10.0. The Offer Wall allows your users to complete certain activities in exchange for in-game currency.

First, make sure you have this activity in your Manifest:

<activity android:name="com.fyber.ads.ofw.OfferWallActivity" android:configChanges="orientation|screenSize" />

To receive notifications about the Offer Wall intent availability, implement the RequestCallback interface:

RequestCallback requestCallback = new RequestCallback() {

    @Override
    public void onRequestError(RequestError requestError) {
        Log.d(TAG, "Something went wrong with the request: " + requestError.getDescription());
    }

    @Override
    public void onAdAvailable(Intent intent) {
        Log.d(TAG, "Offers are available");
        this.ofwIntent = intent;
    }

    @Override
    public void onAdNotAvailable(AdFormat adFormat) {
        Log.d(TAG, "No ad available");
        this.ofwIntent = null;
    }
};

Request an Offer Wall:

OfferWallRequester.create(requestCallback)
    .closeOnRedirect(true) // using this optional line will make the Offer Wall close after the user interacts with one offer
    .request(context);

Show an Offer Wall:

 if (this.ofwIntent) {
     startActivityForResult(this.ofwIntent, OFFERWALL_REQUEST_CODE);
 }

Fyber's docs have more advanced information on configuring the Offer Wall if you are interested.

Reward the user:

Whenever you think the user may have earned more currency, make a virtual currency request. If the user has earned more currency since the last time a virtual currency request was made, the amount of new currency the user has earned will be returned to the onSuccess callback.

VirtualCurrencyCallback virtualCurrencyCallback = new VirtualCurrencyCallback() {
    @Override
    public void onRequestError(RequestError requestError) {
        Log.d(TAG, "request error: " + requestError.getDescription());
    }

    @Override
    public void onSuccess(VirtualCurrencyResponse virtualCurrencyResponse) {
        // Process the deltaOfCoins in the way that makes most sense for your application
        double deltaOfCoins = virtualCurrencyResponse.getDeltaOfCoins();
    }

    @Override
    public void onError(VirtualCurrencyErrorResponse virtualCurrencyErrorResponse) {
        Log.d(TAG, "VCS error received - " + virtualCurrencyErrorResponse.getErrorMessage());
    }
};

VirtualCurrencyRequester.create(virtualCurrencyCallback)
    .request(activity);

Fyber's docs have more advanced information on configuring the user if you are interested.