VCS Rewarding
VCS is the default rewarding option in the dashboard, so you should not have to make any configuration changes unless you have previously altered the setting.
If modifications to the rewarding settings are required, you can refer back to modifying your app settings.
Implementing the Virtual Currency Callback
Handling VCS is based on asynchronous operations. You must implement a VirtualCurrencyCallback
to pass to the request for currency.
This callback provides you with information about the reward that should be provided to your user. In particular, you should use the getDeltaOfCoins
method on the VirtualCurrencyReponse
object to get the total reward amount to provide to the user.
importclass="cm-variable">com.fyber.requesters.VirtualCurrencyCallback;
import com.fyber.currency.VirtualCurrencyResponse;
import com.fyber.currency.VirtualCurrencyErrorResponse;
import com.fyber.requesters.RequestError;
[...]
VirtualCurrencyCallback virtualCurrencyCallback = new VirtualCurrencyCallback() {
public void onSuccess(VirtualCurrencyResponse virtualCurrencyResponse) {
// Reward your user based on the deltaOfCoins parameter
double deltaOfCoins = virtualCurrencyResponse.getDeltaOfCoins();
}
public void onRequestError(RequestError requestError) {
// No reward has been returned, so nothing can be provided to the user
Log.d(TAG, "request error: " + requestError.getDescription());
}
public void onError(VirtualCurrencyErrorResponse virtualCurrencyErrorResponse) {
// No reward has been returned, so nothing can be provided to the user
Log.d(TAG, "VCS error received - " + virtualCurrencyErrorResponse.getErrorMessage());
}
};
Request for New Rewards
To reward your users after they have engaged with a rewarded ad format, you need to make a request to VCS. Unless specified otherwise, a request to VCS will ask for the default currency.
Requesting Rewards import com.fyber.requesters.VirtualCurrencyRequester;
[...]
// We can create the requester and make the request in the same line
VirtualCurrencyRequester.create(virtualCurrencyCallback)
.request(activity);
Best Practice Check
Most DT Offer Wall offers will complete and reward the user immediately when they have performed the required action for the offer. Some DT Offer Wall offers may take some time to complete and reward the user.
To handle both scenarios, we recommend you place requests to VCS in two places in your app:
- When the DT Offer Wall closes, you may make an immediate request for VCS to get most of the rewards, which should come through as soon as the user completes the offer.
- Whenever you direct the user to a view in which their total currency is visible, you may make a request for VCS to gather any rewards that may have been credited since the user's last visit to the DT Offer Wall.
Handling Multiple Currencies
If you have created multiple currencies for your application on your dashboard, chaining a call to forCurrencyID(...)
will allow you to request VCS for a specific currency.
Requesting Rewards from New Currency
import com.fyber.requesters.VirtualCurrencyRequester;
[...]
// We can create the requester, set the currency we want, and make the request in the same line
VirtualCurrencyRequester.create(virtualCurrencyCallback)
.forCurrencyID(currencyId)
.request(activity);
You have now completed the set up the DT Offer Wall via the SDK.
VCS Error Types Reference
The provided NSError
helps you determine the cause of the error.
The error.code
contains the general type of the error, defined in the FYBVirtualCurrencyErrorType
enum type. See the table below for a description of the possible error types.
Error Type | Description |
---|---|
FYBVirtualCurrencyErrorTypeNoConnection | Request couldn't be sent, usually due to a non-working network connection. |
FYBVirtualCurrencyErrorTypeInvalidResponse | Returned response is not formatted in an expected way. |
FYBVirtualCurrencyErrorTypeInvalidResponseSignature | Response doesn't contain a valid signature. The response signature is verified against your secret token. |
FYBVirtualCurrencyErrorTypeServer | The server returned an error described in errorCode. |
FYBVirtualCurrencyErrorTypeInvalidResponseSignature | Response doesn't contain a valid signature. The response signature is verified against your secret token. |
FYBVirtualCurrencyErrorTypeServer | The server returned an error described in errorCode. |
FYBVirtualCurrencyErrorTypeOther | An error occurred whose cause couldn't be determined. |
Adding Custom Parameters
If you are hosting your own currency service, you can pass custom parameters to the DT platform when requesting the offers, so you can perform any kind of tracking you need. The custom parameters are passed back to your system during the callback.
// Add the custom parameters
mapOfParameters = new HashMap(String,String)();
mapOfParameters.put("pub0", "value0");
mapOfParameters.put("pub1", "value1");
InterstitialRequester interstitialRequester =
InterstitialRequester.create(callback);
//Adding a custom parameter to be used with this
interstitial requester
interstitialRequester.addParameter("pub2", "pub2")
//Adding a list of custom parameters to be used
in this interstitial requester
.addParameters(mapOfParameters);
Alerts and Messages
If the device’s Internet connection is down or an unknown error occurs either on the SDK or on DT’s backend while loading DT Offer Wall Edge, the OfferWallActivity
presents an alert dialog to the user.
The dialog contains a title, a message, and one single button to dismiss the alert. We have provided the following default messages in English:
Identifier | Description | Error |
---|---|---|
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 DT Offer Wall Edge cannot be loaded. | An error happened when loading the DT Offer Wall Edge (no internet connection)" |
ERROR_LOADING_OFFERWALL | Error message shown when an unknown issue has prevented the DT Offer Wall Edge from being loaded. | "An error happened when loading the DT Offer Wall Edge” |
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 DT Offer Wall Edge | “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 DT.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)
Allows you to 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)
Allows you to 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 are left to its default value.
setCustomString(UIString Identifier identifier, int message, Context context)
andsetCustomUIStrings(EnumMap<UIStringIdentifier, Integer> messages, Context context)
These 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! Refer to the Android documentation about localization for more details.
Active DT Debug Log
DT provides custom logging to help you troubleshoot your integration. You should activate logging before starting up the DT SDK to ensure you will have logs of the startup itself.
import com.fyber.Fyber;
[...]
protected void onResume() {
Fyber.with(appId, activity)
.withUserId(userId)
.withSecurityToken(securityToken)
.start();
}
Best Practice Check
We recommend you disable logging before going live.
It is also possible to activate logging on your test devices without having to make the specific call to enableLogging
. This is useful if you want to pull your live build from the Google Play Store and troubleshoot it.
You can activate logging via an adb
command:
adb shell setprop log.tag.Fyber VERBOSE
After making the adb
command, logging will be active on your test device for all apps until you disable the logging again. You can disable it again at any time with another adb
command:
adb shell setprop log.tag.Fyber SUPPRESS