Using the Fyber Offer Wall

How to display the Offer Wall

Fyber Offer Wall

The Offer Wall is implemented as an Android activity.

If you use Gradle, please disregard this step.

Code to be added to your Application Manifest

<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="@drawable/icon" android:label="@string/app_name">

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

</application>

Receiving Notifications about Offer Wall Availability

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");
    }

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

Then you request the Offer Wall. You use the following snippet to request an Offer Wall ad. When an Intent to show the Offer Wall is available, the RequestCallback shown above will be notified:

OfferWallRequester.create(requestCallback)
        .request(context);

By default, the Offer Wall activity will remain on the top of your application activity stack, and when the user returns to your app it will reload its contents. You can override this behavior by specifying that the Offer Wall activity should close when the user is redirected out of your application. This way, when the user comes back to your game, it will do it to the activity which called the Offer Wall activity. You can achieve this by chaining the closeOnRedirect:

OfferWallRequester.create(requestCallback)
        .closeOnRedirect(shouldCloseOfferwall)
        .request(context);

You can specify the behavior of the Offer Wall activity, once the user clicks on an offer and is redirected outside your app.

Call the android.app.Activity method startActivityForResult(offerWallIntent, OFFERWALL_REQUEST_CODE) where offerWallIntent is the intent you got from the SDK in the previous step and OFFERWALL_REQUEST_CODE a unique integer identifier within your activity. This will show the Offer Wall activity. Don’t forget that the activity must be defined in your application manifest.

If you want to be notified when the Offer Wall activity closes and returns, override the android.app.Activity method onActivityResult(int requestCode, int resultCode, Intent data) in the activity that called the Offer Wall activity. The request code passed to this method will be the same you passed to your offerWallIntent in the step 4, OFFERWALL_REQUEST_CODE.

Alerts and messages presented to the user

If the device’s Internet connection is down or an unknown error happens either on the SDK or on Fyber’s backend while loading the Offer Wall, the OfferWallActivity will present an alert dialog to the user. The dialog will have a title, a message, and one single button to dismiss the alert. We have provided the following default messages in English:

Identifier Description Default Text
ERROR_DIALOG_TITLE Single title for all alert dialogs “Error”
ERROR_LOADING_OFFERWALL_NO_INTERNET_CONNECTION Error message presented when the device seems not to have a Internet connection and, as a consequence, the Offer Wall cannot be loaded. An error happened when loading the Offer Wall (no internet connection)”
ERROR_LOADING_OFFERWALL Error message shown when an unknown issue has prevented the Offer Wall from being loaded. “An error happened when loading the Offer Wall”
GENERIC_ERROR Generic error message. It’s not in use at the moment. “An error happened when performing this operation”
DISMISS_ERROR_DIALOG The caption of the dismiss dialog button. “Dismiss”
LOADING_OFFERWALL A loading message which appears next to the progress bar when loading the mobile Offer Wall “Loading…”

We encourage you to provide your own versions of the error messages in several languages. To accomplish this, we provide the following methods inside the Fyber.Settings class. You are able to obtain this object when you start the SDK:

Fyber.Settings settings = Fyber.with(appID, Activity).start();
  • setCustomUIString(UIStringIdentifier identifier, String message) this method lets you specify one overridden version of a message at a time. You can identify the message you want to customize by using the enumeration UIStringIdentifier.
  • setCustomUIStrings(EnumMap<UIStringIdentifier, String> messages) this will let you specify several or all overridden messages at once by passing an EnumMap instance. If the passed map doesn’t contain keys for each of the possible messages, those not specified will be left to its default value.
  • setCustomString(UIString Identifier identifier, int message, Context context) and setCustomUIStrings(EnumMap<UIStringIdentifier, Integer> messages, Context context) are the localization-friendly versions of the two previous methods. Instead of passing a string with the text for the overridden message, pass an integer reference to your strings and let the Android localization mechanism do the rest! Please refer to the Android documentation about localization for more details.

Activity Code Additions

If you choose to store the Offer Wall intent in a variable when it’s available:

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");
    }
};

OfferWallRequester.create(requestCallback)
        .request(context);

You can then start the Offer Wall Activity as you normally would:

	startActivityForResult(this.ofwIntent, OFFERWALL_REQUEST_CODE);

Adding Custom Parameters for Offer Wall

If you are interested in adding a custom parameter to your Android SDK Offer Wall request, you can pass along custom parameters in this way:

// creating a map of parameters to be used with a specific offer wall requester
Map mapOfParameters = new HashMap<String,String>();
mapOfParameters.put("pub2", "value2");
mapOfParameters.put("pub3", "value3");
OfferWallRequester ofwRequester = OfferWallRequester.create(callback)
	//adding a custom parameter to be used with this offer wall requester
	.addParameter("pub0", "value0")
	.addParameter("pub1", "value1")
	//adding a list of custom parameters to be used in this offer wall requester
	.addParameters(mapOfParameters);