Delegate Usage
By implementing Mediation delegate protocols you can get notifications about the success, failure, or lifecycle events of the Mediation SDK and its ad objects.
Mediation Start Delegate
Implement the HeliumSdkDelegate
protocol to receive notifications about the Mediation SDK’s initialization process.
@interface AppDelegate () <HeliumSdkDelegate>
This will allow you to implement the following method:
- (void)heliumDidStartWithError:(HeliumError *)error
{
if (error)
NSLog(@"Helium did not start due to error: %@",error);
else
NSLog(@"Helium Started Successfully");
}
Interstitial Ad Delegates
Implement the CHBHeliumInterstitialAdDelegate
protocol to receive notifications about interstitial ads loading, displaying, and closing.
@interface ViewController () <CHBHeliumInterstitialAdDelegate>
This will allow you to implement the following methods:
- (void)heliumInterstitialAdWithPlacementName:(NSString*)placementName
didLoadWithError:(HeliumError *)error
{
if (error)
{
NSLog(@"Interstitial with Placement Name:%@ failed to load with error:%@",placementName,error.description);
}
else
{
NSLog(@"Interstitial with Placement Name:%@ didLoad",placementName);
}
}
- (void)heliumInterstitialAdWithPlacementName:(NSString*)placementName
didShowWithError:(HeliumError *)error
{
if (error)
{
NSLog(@"Interstitial with Placement Name:%@ failed to show with error:%@",placementName,error.description);
}
else
{
NSLog(@"Interstitial with Placement Name:%@ didSHow",placementName);
}
}
- (void)heliumInterstitialAdWithPlacementName:(NSString*)placementName
didCloseWithError:(HeliumError *)error
{
if (error)
{
NSLog(@"Interstitial with Placement Name:%@ failed to close with error:%@",placementName,error.description);
}
else
{
NSLog(@"Interstitial with Placement Name:%@ didClose",placementName);
}
}
- (void)heliumInterstitialAdWithPlacementName:(NSString*)placementName
didLoadWinningBidWithInfo:(NSDictionary *)bidInfo
{
NSLog(@"Placement:%@,%@",placementName,bidInfo);
}
- (void)heliumInterstitialAdDidRecordImpressionWithPlacementName:(NSString *)placementName
{
NSLog(@"Impression recorded");
}
- (void)heliumInterstitialAdWithPlacementName:(NSString*)placementName
didLoadWithError:(HeliumError *)error
{
if (error)
{
NSLog(@"Interstitial with Placement Name:%@ failed to load with error:%@",placementName,error.description);
}
else
{
NSLog(@"Interstitial with Placement Name:%@ didLoad",placementName);
}
}
- (void)heliumInterstitialAdWithPlacementName:(NSString*)placementName
didShowWithError:(HeliumError *)error
{
if (error)
{
NSLog(@"Interstitial with Placement Name:%@ failed to show with error:%@",placementName,error.description);
}
else
{
NSLog(@"Interstitial with Placement Name:%@ didSHow",placementName);
}
}
- (void)heliumInterstitialAdWithPlacementName:(NSString*)placementName
didCloseWithError:(HeliumError *)error
{
if (error)
{
NSLog(@"Interstitial with Placement Name:%@ failed to close with error:%@",placementName,error.description);
}
else
{
NSLog(@"Interstitial with Placement Name:%@ didClose",placementName);
}
}
- (void)heliumInterstitialAdWithPlacementName:(NSString*)placementName
didLoadWinningBidWithInfo:(NSDictionary *)bidInfo
{
NSLog(@"Placement:%@,%@",placementName,bidInfo);
}
Rewarded Ad Delegates
Implement the CHBHeliumRewardedAdDelegate
protocol to receive notifications about rewarded ads loading, displaying, and closing.
@interface ViewController () <CHBHeliumRewardedAdDelegate>
This will allow you to implement the following methods:
- (void)heliumRewardedAdWithPlacementName:(NSString*)placementName
didLoadWithError:(HeliumError *)error
{
if (error)
{
NSLog(@"Rewarded with Placement Name:%@ failed to load with error:%@",placementName,error.description);
}
else
{
NSLog(@"Rewarded with Placement Name:%@ didLoad",placementName);
}
}
- (void)heliumRewardedAdWithPlacementName:(NSString*)placementName
didShowWithError:(HeliumError *)error
{
if (error)
{
NSLog(@"Rewarded with Placement Name:%@ failed to show with error:%@",placementName,error.description);
}
else
{
NSLog(@"Rewarded with Placement Name:%@ didSHow",placementName);
}
}
- (void)heliumRewardedAdWithPlacementName:(NSString*)placementName
didCloseWithError:(HeliumError *)error
{
if (error)
{
NSLog(@"Rewarded with Placement Name:%@ failed to close with error:%@",placementName,error.description);
}
else
{
NSLog(@"Rewarded with Placement Name:%@ didClose",placementName);
}
}
- (void)heliumRewardedAdWithPlacementName:(NSString*)placementName
didGetReward:(NSInteger)reward {
NSLog(@"Got Reward for RV with placementName:%@, reward: %ld",placementName, (long)reward);
}
- (void)heliumRewardedAdWithPlacementName:(NSString*)placementName
didLoadWinningBidWithInfo:(NSDictionary *)bidInfo
{
NSLog(@"Placement:%@,%@",placementName,bidInfo);
}
- (void)heliumRewardedAdDidRecordImpressionWithPlacementName:(NSString *)placementName
{
NSLog(@"Impression recorded");
}
- (void)heliumRewardedAdWithPlacementName:(NSString*)placementName
didLoadWithError:(HeliumError *)error
{
if (error)
{
NSLog(@"Rewarded with Placement Name:%@ failed to load with error:%@",placementName,error.description);
}
else
{
NSLog(@"Rewarded with Placement Name:%@ didLoad",placementName);
}
}
- (void)heliumRewardedAdWithPlacementName:(NSString*)placementName
didShowWithError:(HeliumError *)error
{
if (error)
{
NSLog(@"Rewarded with Placement Name:%@ failed to show with error:%@",placementName,error.description);
}
else
{
NSLog(@"Rewarded with Placement Name:%@ didSHow",placementName);
}
}
- (void)heliumRewardedAdWithPlacementName:(NSString*)placementName
didCloseWithError:(HeliumError *)error
{
if (error)
{
NSLog(@"Rewarded with Placement Name:%@ failed to close with error:%@",placementName,error.description);
}
else
{
NSLog(@"Rewarded with Placement Name:%@ didClose",placementName);
}
}
- (void)heliumRewardedAdWithPlacementName:(NSString*)placementName
didGetReward:(NSInteger)reward {
NSLog(@"Got Reward for RV with placementName:%@, reward: %ld",placementName, (long)reward);
}
- (void)heliumRewardedAdWithPlacementName:(NSString*)placementName
didLoadWinningBidWithInfo:(NSDictionary *)bidInfo
{
NSLog(@"Placement:%@,%@",placementName,bidInfo);
}
Banner Ad Delegates
Implement the CHBHeliumBannerAdDelegate
protocol to receive notifications about banner ads loading, displaying, and closing.
@interface ViewController () <CHBHeliumBannerAdDelegate>
This will allow you to implement the following methods:
- (void)heliumBannerAdWithPlacementName:(NSString *)placementName didLoadWithError:(HeliumError *)error {
if (error)
{
[self.txtOutput addNewLine:[NSString stringWithFormat:@"Banner with Placement Id:%@ failed to load with error:%@",placementName,error.errorDescription]];
NSLog(@"Banner with Placement Id:%@ failed to load with error:%@",placementName,error.errorDescription);
}
else
{
[self.txtOutput addNewLine:[NSString stringWithFormat:@"Banner with Placement Id:%@ didLoad",placementName]];
NSLog(@"Banner with Placement Id:%@ didLoad",placementName);
}
}
- (void)heliumBannerAdWithPlacementName:(NSString*)placementName
didLoadWinningBidWithInfo:(NSDictionary *)bidInfo
{
[self.txtOutput addNewLine:[NSString stringWithFormat:@"Banner with Placement Id:%@ didLoadWiningBid:%@",placementName,bidInfo[@"price"]]];
NSLog(@"Placement:%@,%@",placementName,bidInfo);
}
- (void)heliumBannerAdWithPlacementName:(NSString *)placementName didClickWithError:(HeliumError *)error
{
if (error) {
[self.txtOutput addNewLine:[NSString stringWithFormat:@"Banner with Placement Id:%@ didClick with error: %@", placementName, error]];
} else {
[self.txtOutput addNewLine:[NSString stringWithFormat:@"Banner with Placement Id:%@ didClick", placementName]];
}
}
- (void)heliumBannerAdDidRecordImpressionWithPlacementName:(NSString *)placementName
{
NSLog(@"Impression recorded");
}
- (void)heliumBannerAdWithPlacementName:(NSString *)placementName didCloseWithError:(HeliumError *)error {
}
- (void)heliumBannerAdWithPlacementName:(NSString *)placementName didLoadWithError:(HeliumError *)error {
if (error)
{
[self.txtOutput addNewLine:[NSString stringWithFormat:@"Banner with Placement Id:%@ failed to load with error:%@",placementName,error.errorDescription]];
NSLog(@"Banner with Placement Id:%@ failed to load with error:%@",placementName,error.errorDescription);
}
else
{
[self.txtOutput addNewLine:[NSString stringWithFormat:@"Banner with Placement Id:%@ didLoad",placementName]];
NSLog(@"Banner with Placement Id:%@ didLoad",placementName);
}
}
- (void)heliumBannerAdWithPlacementName:(NSString *)placementName didShowWithError:(HeliumError *)error {
if (error)
{
[self.txtOutput addNewLine:[NSString stringWithFormat:@"Banner with Placement Id:%@ failed to show with error:%@",placementName,error.errorDescription]];
NSLog(@"Banner with Placement Id:%@ failed to show with error:%@",placementName,error.errorDescription);
}
else
{
[self.txtOutput addNewLine:[NSString stringWithFormat:@"Banner with Placement Id:%@ didShow",placementName]];
NSLog(@"Banner with Placement Id:%@ didShow",placementName);
}
}
- (void)heliumBannerAdWithPlacementName:(NSString*)placementName
didLoadWinningBidWithInfo:(NSDictionary *)bidInfo
{
[self.txtOutput addNewLine:[NSString stringWithFormat:@"Banner with Placement Id:%@ didLoadWiningBid:%@",placementName,bidInfo[@"price"]]];
NSLog(@"Placement:%@,%@",placementName,bidInfo);
}
- (void)heliumBannerAdWithPlacementName:(NSString *)placementName didClickWithError:(HeliumError *)error
{
if (error) {
[self.txtOutput addNewLine:[NSString stringWithFormat:@"Banner with Placement Id:%@ didClick with error: %@", placementName, error]];
} else {
[self.txtOutput addNewLine:[NSString stringWithFormat:@"Banner with Placement Id:%@ didClick", placementName]];
}
}
Note
- (void)heliumBannerAdWithPlacementName:(NSString _)placementName didLoadWinningBidWithInfo:(NSDictionary<NSString _, id> _)bidInfo
will only return information for non-refresh banner configurations.
Updated 5 days ago