Introduction
Rewarded ads are an engaging ad format that shows a short video ad to the user and in exchange the user will earn a reward. The user must consent and watch the video completely through to the end in order to earn the reward.
Important
The speed and stability of users internet connections may vary. It is highly recommended to fetch as far in advance of showing an ad as possible. This helps to ensure that all necessary assets are downloaded. For example, you may want to fetch an ad when a level starts, or after a previous ad has been shown.
Make an Ad Request
The following example shows how to import the Rewarded class, followed by making a request to display the Rewarded ads.
FYBRewarded.delegate = [[MyRewardedDelegate alloc] init];
NSString *placementId = @"1234";
[FYBRewarded request:placementId];
FYBRewarded.delegate = MyRewardedDelegate()
let placementId = "1234"
FYBRewarded.request(placementId)
Adding Callbacks
The callback code below is required for SDK to properly track the activity of your ad
@interface MyRewardedDelegate : NSObject <FYBRewardedDelegate>
@end
@implementation MyRewardedDelegate
- (void)rewardedIsAvailable:(NSString *)placementId {
// Called when a rewarded ad from placement becomes available
}
- (void)rewardedIsUnavailable:(NSString *)placementId {
// Called when a rewarded ad from placement becomes unavailable
}
- (void)rewardedDidShow:(NSString *)placementId impressionData:(FYBImpressionData *)impressionData {
// Called when a rewarded ad from placement shows up. Audio play will start here.
}
- (void)rewardedDidFailToShow:(NSString *)placementId withError:(NSError *)error impressionData:(FYBImpressionData *)impressionData {
// Called when an error arises when showing a rewarded ad from placement
}
- (void)rewardedDidClick:(NSString *)placementId {
// Called when a rewarded ad from placement is clicked
}
- (void)rewardedDidDismiss:(NSString *)placementId {
// Called when a rewarded ad from placement hides. Audio play will stop here.
}
- (void)rewardedDidComplete:(NSString *)placementId userRewarded:(BOOL)userRewarded {
// Called when a rewarded ad finishes playing
}
- (void)rewardedWillRequest:(NSString *)placementId {
// Called when a rewarded ad is going to be requested.
}
@end
class MyRewardedDelegate: NSObject, FYBRewardedDelegate {
func rewardedIsAvailable(_ placementName: String) {}
func rewardedIsUnavailable(_ placementName: String) {}
func rewardedDidShow(_ placementName: String, impressionData: FYBImpressionData) {}
func rewardedDidFail(toShow placementName: String, withError error: Error, impressionData: FYBImpressionData) {}
func rewardedDidClick(_ placementName: String) {}
func rewardedDidComplete(_ placementName: String, userRewarded: Bool) {}
func rewardedDidDismiss(_ placementName: String) {}
func rewardedWillRequest(_ placementId: String) {}
}
Example showing an ad
The following example checks to see if a
NSString *placementId = @"1234";
if ([FYBRewarded isAvailable:placementId]) {
[FYBRewarded show:placementId];
}
let placementId = "1234"
if (FYBRewarded.isAvailable(placementId)) {
FYBRewarded.show(placementId)
}
Stop Requesting An Ad
If a placement is no longer relevant for your user, you can stop requesting it.
NSString *placementId = @"1234";
[FYBRewarded stopRequesting:placementId];
let placementId = "1234"
FYBRewarded.stopRequesting(placementId)
Important
Use stopRequesting to disable the FairBid SDK Auto-Request functionality for a specific placement. If you continue requesting ads for placements that are not shown, the performance of your placement can be impacted.
For details on configuring Server Side Rewarding, click here.
What's Next
GDPR |
Integrate Mediation partners |