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 you want to modify the rewarding settings, you can refer back to modifying your app settings.
Request for New Rewards
To reward your users after they have engaged with a rewarded ad format, you must make a request to VCS. Unless specified otherwise, a request to VCS asks for the default currency.
C# - Example: Requesting Rewardsusing FyberPlugin; [...]
VirtualCurrencyRequester
virtualCurrencyRequester
=
VirtualCurrencyRequester.Create();
[...] virtualCurrencyRequester.Request();
Best Practice Check
When most DT Offer Wall offers are complete they reward the user immediately when the user has 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 comes 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 can 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 the Response
Handling the VCS request response can be accomplished through events or callbacks. Select the option you want to use in your project.
Events
The class FyberCallback
contains the events VirtualCurrencySuccess
and VirtualCurrencyError
to notify the corresponding result of the request to the VCS.
void OnEnable() {
FyberCallback.VirtualCurrencySuccess
+=
OnCurrencyResponse;
FyberCallback.VirtualCurrencyError
+=
OnCurrencyErrorResponse; }
void
OnDisable() {
FyberCallback.VirtualCurrencySuccess
+=
OnCurrencyResponse;
FyberCallback.VirtualCurrencyError
+=
OnCurrencyErrorResponse; } [...]
public
void
OnCurrencyResponse(VirtualCurrencyResponse
response) {
Debug.Log("Delta of coins: "
+
response.DeltaOfCoins.ToString()
+
". Transaction ID: "
+
response.LatestTransactionId
+
".\nCurreny ID: "
+
response.CurrencyId
+
". Currency Name: "
+
response.CurrencyName
+
". Is the default currency?: "
+
response.DefaultCurrency);
} public
void
OnCurrencyErrorResponse(VirtualCurrencyErrorResponse
vcsError) {
Debug.Log(string.Format("Delta of coins request failed.\n"
+
"Error Type: {0}\nError Code: {1}\nError Message: {2}",
vcsError.Type,
vcsError.Code,
vcsError.Message));
}
On a successful request, the parameter of type VirtualCurrencyResponse
provides you with information about the reward that is provided to your user. In particular, use DeltaOfCoins
to receive the total reward amount to provide to the user and LatestTransactionId
if you’re interested in the user’s latest Transaction ID.
The passed response parameter returned on the first call to VCS from a new installation of your app always contains the reward amount and Transaction ID of the user's latest transaction in our system. To avoid rewarding a user for a second time if they have uninstalled and re-installed your app, you can do one of two things:
Option 1: Store it
Store the most recent Transaction ID somewhere that can survive an uninstall, and compare it to the transaction ID returned from response.LatestTransactionId
. Only rewarding when the stored ID and returned ID don't match.
Option 2: Fresh install
Ignore the first response from VCS from a fresh install of your app. All subsequent calls to VCS then behave normally.
Callbacks
The interface VirtualCurrencyCallback
contains the following methods:
Method | Description |
---|---|
OnSuccess | Successful. The parameter of type VirtualCurrencyResponse contains the response data. |
OnError | Fired in the case of an error related specifically to the Virtual Server request. The parameter of type VirtualCurrencyErrorResponse contains data about the error. |
OnRequestError | Triggered in the case of any other error. |
public class
VCSCallback :
VirtualCurrencyCallback {
public
void
OnSuccess(VirtualCurrencyResponse
response) {
Debug.Log("Virtual currency response success. Delta of coins: "
+
response.DeltaOfCoins.ToString()
+
". Transaction ID: "
+
response.LatestTransactionId
+
".\nCurreny ID: "
+
response.CurrencyId
+
". Currency Name: "
+
response.CurrencyName
+
". Is the default currency?: "
+
response.DefaultCurrency);
} public
void
OnError(VirtualCurrencyErrorResponse
vcsError) {
Debug.Log(string.Format("Delta of coins request failed.\n"
+
"Error Type: {0}\nError Code: {1}\nError Message: {2}",
vcsError.Type,
vcsError.Code,
vcsError.Message));
} public
void
OnRequestError(RequestError
error) {
Debug.Log("OnRequestError: "
+
error.Description);
} }
To be notified through the implemented VirtualCurrencyCallback
instead of through events, you must pass an instance of it, using the method WithCallback
, before calling the method Request
of the VirtualCurrencyRequester
.
private VCSCallback vcsCallback = new VCSCallback(); [...] private
void RequestVCS () { VirtualCurrencyRequester.Create() .WithCallback(vcsCallback)
.Request();
On a successful request, the parameter of type VirtualCurrencyResponse
provides you with information about the reward that is to be provided to your user. Use DeltaOfCoins
to receive the total reward amount to provide to the user and LatestTransactionId
if you’re interested in the user’s latest Transaction ID.
The passed response parameter returned on the first call to VCS from a new installation of your app always contains the reward amount and Transaction ID of the user's latest transaction in our system. To avoid rewarding a user for a second time if they have uninstalled and re-installed your app, you can do one of two options:
Option 1: Store it
Store the most recent Transaction ID somewhere that can survive an uninstall, and compare it to the Transaction ID returned from response.LatestTransactionId
. Only rewarding when the stored ID and returned ID don't match.
Option 2: Fresh install
Ignore the first response from VCS from a fresh install of your app. All subsequent calls to VCS can then behave normally.
Handling Multiple Currencies
If you have created multiple currencies for your application on your dashboard, you can call the method ForCurrencyId
of the VirtualCurrencyRequester
before making the request. This allows you to query VCS for a specific currency.
using FyberPlugin; [...]
// We can create the requester, set the currency we want, and make the request in the same line
VirtualCurrencyRequester.Create()
.ForCurrencyId(currencyId)
.Request();
Notifying the User
A user notification with the message: "Congratulations! You've earned XX coins!" is shown by default after a successful response in which the delta of coins is larger than 0. You can override this behavior by calling the method NotifyUserOnReward
of the VirtualCurrencyRequester
before making the request.
VirtualCurrencyRequester.Create()
.NotifyUserOnReward(false)
.Request();
You have now successfully set up the DT Offer Wall via DT Unity Plugin.
Active DT Debug Log
DT provides custom logging to help you troubleshoot your integration. Activate logging before starting up the DT Unity Plugin to ensure you have logs of the startup itself.
Call the following method:
Activate LoggingFyberLogger.EnableLogging(true);
Best Practice Check
We recommend you disable logging before going live.
Optional Android Method
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:
Activate Logging
adb shell setprop log.tag.Fyber VERBOSE
After making the adb
command, logging will be active on your test device until you disable the logging again. You can disable it again at any time with another adb
command:
Deactivate Logging
adb shell setprop log.tag.Fyber SUPPRESS