Rewarded ads

To get advertisement placement reward a contract is required:

Rewarded ads is a type of fullscreen video ads on Android that can be shown on user permission.

This type of ads allows you to search for an ad and then if it was found shown it to a user

Set up

To enable this feature you need to:

  1. check of your app is opened in an iframe on our mobile platforms. If it’s still opened as an external page you can request us to enable iframe-launch for your app by sending a request to this e-mail api-support@ok.ru

  2. request us to enable FAPI support for your mobile app via this e-mail - api-support@ok.ru.

After iframe and FAPI are enabled for your app you can import FAPI SDK like this:

<script type="text/javascript" src="//api.ok.ru/js/fapi5.js" defer="defer"></script>

Then you should define a global callback function API-callback. In example:

window.API_callback = function(method, result, data) {
   console.log("method=" + method + ", result=" + result + ", data=" + data);
};

Checking for ads availability

Before showing an ad you need to check if this feature is available.

FAPI.UI.isNativeAdSupported() is used for this.

Example usage:

/*
* Ads availability check
*/
function isAdsEnabled() {
    if (FAPI && FAPI.UI.isNativeAdSupported) {
        return FAPI.UI.isNativeAdSupported();
    }
}

Result is a boolean:

  • false - if ads are not available;
  • true - if ads are available.

Finding an ad

If previous step was successful (method returned true value) you can show ads to user.

To show an ad you first need to find it. For this you should use FAPI.UI.requestManualAd() method.

Example usage:

/*
* Find an in-app ad
*/
function requestAds() {
    if (FAPI && FAPI.UI.requestManualAd) {
        FAPI.UI.requestManualAd();
    }
}

API_callback function will be invoked as a result.

Showing an ad

If an ad was found on a previous step you can show it using FAPI.UI.showLoadedAd() method.

Example usage:

/*
* Show an in-app ad
*/
function showAds() {
    if (FAPI && FAPI.UI.showLoadedAd) {
        FAPI.UI.showLoadedAd();
    }
}

API_callback function will be invoked as a result.

Callback function

As all other FAPI-methods global FAPI-callback function is invoked when an ad is requested - API_callback(method, result, data).

Depending on a result following parameters can be passed to it:

  • if there are no ads for current user:
    • method = requestManualAd;
    • result = error;
    • data = no_ads;
  • ad is found and is ready to be shown:
    • method = requestManualAd;
    • result = event;
    • data = ad_prepared;
  • ad is successfully shown:
    • method = showLoadedAd;
    • result = ok;
    • data = ad_shown;
  • an error occurred on method invocation:
    • method = requestManualAd / showLoadedAd;
    • result = error;
    • data = native ads failed.

Test application

You can view how this ads work in our test application. This app is available by a following link http://m.ok.ru/game/inappadstest

To test this type of ads you need to:

  • to check if ads are supported - press FAPI.UI.isNativeAdSupported button;
  • to find an ad - press FAPI.UI.requestManualAd button;
  • to show found ad - press FAPI.UI.showLoadedAd button.