VCS is the default rewarding option in the Console, 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.
Rewarding: VCS
Step 1: The Console
VCS (Virtual Currency Server) is configured by default.
Going to VCS
However, it can be turned On or Off by changing the Reward Handling mode in the Settings section at any time.
Adjusting Reward Handling
Now that VCS is configured, let's set up the SDK side.
Step 2: Conforming to the VCS Protocol
Handling VCS is based on asynchronous operations.
Make one of your classes conform to the FYBVirtualCurrencyClientDelegate
protocol and register it, via its delegate property:
#import "FyberSDK.h"
@interface GemStoreViewController : UIViewController
@end
class GemStoneDelegate: UIResponder, UIWindowSceneDelegate, FYBVirtualCurrencyClientDelegate {
// ...
}
Step 3: Request for New Rewards
To reward your users after they have engaged with a rewarded ad format, you request the delta of coins:
// Get the Virtual Currency Client
FYBVirtualCurrencyClient *virtualCurrencyClient = [FyberSDK virtualCurrencyClient];
virtualCurrencyClient.delegate = self; // self should conform to the FYBVirtualCurrencyClientDelegate protocol
// Request the delta of coins
[virtualCurrencyClient requestDeltaOfCoins];
// Get the Virtual Currency Client
let virtualCurrencyClient: FYBVirtualCurrencyClient = FyberSDK.virtualCurrencyClient()
virtualCurrencyClient.delegate = self // self should conform to the FYBVirtualCurrencyClientDelegate protocol
// Request the delta of coins
virtualCurrencyClient.requestDeltaOfCoins()
Best Practice Check
Some DT Offer Wall requests can take a few moments longer to load, so ensure that you've configured for a potential 5 second delay.
Although we recommend you call the VCS when returning from the DT Offer Wall (after a short delay; recommended 5 seconds), you can also call when you're loading the screen that shows currency or after the user comes back from the DT Offer Wall.
Handling Multiple Currencies
If you have created multiple currencies for your application on your dashboard, the previous usage returns the delta of coins to your default currency.
FYBVirtualCurrencyClient *virtualCurrencyClient = [FyberSDK virtualCurrencyClient];
virtualCurrencyClient.delegate = self;
// Specify the currency id parameter
FYBRequestParameters *parameters = [[FYBRequestParameters alloc] init];
parameters.currencyId = @"gems";
[virtualCurrencyClient requestDeltaOfCoinsWithParameters:parameters];
let virtualCurrencyClient: FYBVirtualCurrencyClient = FyberSDK.virtualCurrencyClient()
virtualCurrencyClient.delegate = self
// Specify the currency id parameter
let parameters: FYBRequestParameters = FYBRequestParameters.init(placementId: "Placement", currencyId: "gems")
virtualCurrencyClient.requestDeltaOfCoins(with: parameters)
Step 4: Handling the Response
You'll also need to implement the following method which will be called once the delta of coins has been requested:
- (void)virtualCurrencyClient:(FYBVirtualCurrencyClient *)client
didReceiveResponse:(FYBVirtualCurrencyResponse *)response
{
// Process the deltaOfCoins in the way that makes most sense for your application...
NSLog(@"Received delta of coins: %.2f %@ (currency id: %@)", response.deltaOfCoins, response.currencyName, response.currencyId);
}
func virtualCurrencyClient(_ client: FYBVirtualCurrencyClient!, didReceive response: FYBVirtualCurrencyResponse!) {
// Process the deltaOfCoins in the way that makes most sense for your application...
print(String(format: "Received delta of coins: %.2f %@ (currency id: %@)", response.deltaOfCoins, response.currencyName!, response.currencyId!))
}
You've set up DT Offer Wall via SDK!
Is your VCS throwing an error code? Review the VCS Error Types.
Optional: Disable the Toast Message
DT SDK displays a notification such as "Congratulations! You have earned 10 gold coins" whenever a reward is received. If you would like to disable the notification, add the following after starting the SDK:
[FyberSDK instance].shouldShowToastOnReward = NO;
FyberSDK.instance()?.shouldShowToastOnReward = false
VCS Error Types and 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 will be passed back to your system during the callback.
You can pass along custom parameters (e.g. pub0
, pub1
, …) with the request by calling the -[FYBRequestParameters addCustomParameterWithKey:value:]
method on your instance of the FYBRewardedVideoController
before requesting offers.
FYBRewardedVideoController *rewardedVideoController = [FyberSDK rewardedVideoController];
rewardedVideoController.delegate = self;
// add the custom parameters
FYBRequestParameters *parameters = [[FYBRequestParameters alloc] init];
[parameters addCustomParameterWithKey:@"pub0" value:@"value"];
[rewardedVideoController requestVideoWithParameters:parameters];
Naming Restriction
Our system will only process parameters named pub0-pub9. Any other custom parameter will not be sent back in the reward callback.
Activating DT Logging
DT provides custom logging to help you troubleshoot your integration. Activate logging before starting up the DT SDK to ensure you have logs of the startup itself.
Activate Logging[FyberSDK setLoggingLevel:FYBLogLevelDebug];
FYBSDKOptions *options = [FYBSDKOptions optionsWithAppId:@"0000" securityToken:@"0000000000000000000"];
[FyberSDK startWithOptions:options];
Best Practice Check
We recommend you disable logging before going live.