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.

  • extension AppDelegate: 
    
  • @interface AppDelegate () <HeliumSdkDelegate>
    

This will allow you to implement the following method:

  • func heliumDidStartWithError(_ error: ChartboostMediationSDK.ChartboostMediationError?) {
        if let error = error {
            print("Chartboost Mediation did not start due to error: \(error)")
        } else {
            print("Chartboost Mediation Started Successfully")
        }
    }
    
  • - (void)heliumDidStartWithError:(nullable ChartboostMediationError *)error {
        if (error)
            NSLog(@"Mediation did not start due to error: %@", error);
        else
            NSLog(@"Mediation Started Successfully");
    }
    

Interstitial Ad Delegates πŸ”—

Implement the CHBHeliumInterstitialAdDelegate protocol to receive notifications about interstitial ads loading, displaying, and closing.

  • extension ViewController: CHBHeliumInterstitialAdDelegate
    
  • @interface ViewController () <CHBHeliumInterstitialAdDelegate>
    

This will allow you to implement the following methods:

  • func heliumInterstitialAd(
        withPlacementName placementName: String,
        requestIdentifier: String,
        winningBidInfo: [String : Any]?,
        didLoadWithError error: ChartboostMediationSDK.ChartboostMediationError?
    ) {
        if let error = error {
            print("Interstitial with Placement Name:\(placementName) failed to load with error:\(error.localizedDescription)")
        } else {
            print("Interstitial with Placement Name:\(placementName) didLoad")
        }
    }
    
    func heliumInterstitialAd(
        withPlacementName placementName: String,
        didShowWithError error: ChartboostMediationSDK.ChartboostMediationError?
    ) {
        if let error = error {
            print("Interstitial with Placement Name:\(placementName) failed to show with error:\(error.localizedDescription)")
        } else {
            print("Interstitial with Placement Name:\(placementName) didShow")
        }
    }
    
    func heliumInterstitialAd(
        withPlacementName placementName: String,
        didCloseWithError error: ChartboostMediationSDK.ChartboostMediationError?
    ) {
        if let error = error {
            print("Interstitial with Placement Name:\(placementName) failed to close with error:\(error.localizedDescription)")
        } else {
            print("Interstitial with Placement Name:\(placementName) didClose")
        }
    }
    
    func heliumInterstitialAdDidRecordImpression(withPlacementName placementName: String) {
        print("Impression recorded")
    }
    
    
  • 
    - (void)heliumInterstitialAdWithPlacementName:(NSString * _Nonnull)placementName
                                requestIdentifier:(NSString * _Nonnull)requestIdentifier
                                   winningBidInfo:(NSDictionary<NSString *,id> * _Nullable)winningBidInfo
                                 didLoadWithError:(ChartboostMediationError * _Nullable)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 * _Nonnull)placementName
                                 didShowWithError:(ChartboostMediationError * _Nullable)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 * _Nonnull)placementName
                                didCloseWithError:(ChartboostMediationError * _Nullable)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)heliumInterstitialAdDidRecordImpressionWithPlacementName:(NSString *)placementName
    {
        NSLog(@"Impression recorded");
    }
    
    
    

Rewarded Ad Delegates πŸ”—

Implement the CHBHeliumRewardedAdDelegate protocol to receive notifications about rewarded ads loading, displaying, and closing.

  • @interface ViewController () <CHBHeliumRewardedAdDelegate>
    
  • extension ViewController: CHBHeliumRewardedAdDelegate
    

This will allow you to implement the following methods:

  • func heliumRewardedAd(
            withPlacementName placementName: String,
            requestIdentifier: String,
            winningBidInfo: [String : Any]?,
            didLoadWithError error: ChartboostMediationSDK.ChartboostMediationError?
        ) {
            if let error = error {
                print("Rewarded with Placement Name:\(placementName) failed to load with error:\(error.localizedDescription)")
            } else {
                print("Rewarded with Placement Name:\(placementName) didLoad")
            }
        }
    
        func heliumRewardedAd(
            withPlacementName placementName: String,
            didShowWithError error: ChartboostMediationSDK.ChartboostMediationError?
        ) {
            if let error = error {
                print("Rewarded with Placement Name:\(placementName) failed to show with error:\(error.localizedDescription)")
            } else {
                print("Rewarded with Placement Name:\(placementName) didShow")
            }
        }
    
        func heliumRewardedAd(
            withPlacementName placementName: String,
            didCloseWithError error: ChartboostMediationSDK.ChartboostMediationError?
        ) {
            if let error = error {
                print("Rewarded with Placement Name:\(placementName) failed to close with error:\(error.localizedDescription)")
            } else {
                print("Rewarded with Placement Name:\(placementName) didClose")
            }
        }
    
        func heliumRewardedAdDidGetReward(withPlacementName placementName: String) {
            print("Got Reward for RV with placementName:\(placementName)")
        }
    
        func heliumRewardedAdDidRecordImpression(withPlacementName placementName: String) {
            print("Impression recorded")
        }
    
  • 
    - (void)heliumRewardedAdWithPlacementName:(NSString * _Nonnull)placementName
                            requestIdentifier:(NSString * _Nonnull)requestIdentifier
                               winningBidInfo:(NSDictionary<NSString *,id> * _Nullable)winningBidInfo
                             didLoadWithError:(ChartboostMediationError * _Nullable)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 * _Nonnull)placementName
                             didShowWithError:(ChartboostMediationError * _Nullable)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 * _Nonnull)placementName
                            didCloseWithError:(ChartboostMediationError * _Nullable)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)heliumRewardedAdDidGetRewardWithPlacementName:(NSString * _Nonnull)placementName
    {
        NSLog(@"Got Reward for RV with placementName:%@", placementName);
    }
    
    - (void)heliumRewardedAdDidRecordImpressionWithPlacementName:(NSString *)placementName
    {
        NSLog(@"Impression recorded");
    }
    

Implement the CHBHeliumBannerAdDelegate protocol to receive notifications about banner ads loading, displaying, and closing.

  • extension ViewController: HeliumBannerAdDelegate
    
  • @interface ViewController () <CHBHeliumBannerAdDelegate>
    

This will allow you to implement the following methods:

  • func heliumBannerAd(
            placementName: String,
            requestIdentifier: String,
            winningBidInfo: [String : Any]?,
            didLoadWithError error: ChartboostMediationSDK.ChartboostMediationError?
        ) {
            if let error = error {
                print("Banner with Placement Name:\(placementName) failed to load with error:\(error.localizedDescription)")
            } else {
                print("Banner with Placement Name:\(placementName) didLoad")
            }
        }
    
        func heliumBannerAd(
            placementName: String,
            didClickWithError error: ChartboostMediationError?
        ) {
            if let error = error {
                print("Banner with Placement Name:\(placementName) didClick with error:\(error.localizedDescription)")
            } else {
                print("Banner with Placement Name:\(placementName) didClick")
            }
        }
    
        func heliumBannerAdDidRecordImpression(placementName: String) {
            print("Impression recorded")
        }
    
  • - (void)heliumBannerAdWithPlacementName:(NSString * _Nonnull)placementName
                          requestIdentifier:(NSString * _Nonnull)requestIdentifier
                             winningBidInfo:(NSDictionary<NSString *,id> * _Nullable)winningBidInfo
                           didLoadWithError:(ChartboostMediationError * _Nullable)error
    {
        if (error)
        {
            NSLog(@"Banner with Placement Name:%@ failed to load with error:%@", placementName, error.description);
        }
        else
        {
            NSLog(@"Banner with Placement Name:%@ didLoad", placementName);
        }
    }
    
    - (void)heliumBannerAdWithPlacementName:(NSString *)placementName
                          didClickWithError:(ChartboostMediationError *)error
    {
        if (error)
        {
            NSLog(@"Banner with Placement Name:%@ didClick with error:%@", placementName, error.description);
        }
        else
        {
            NSLog(@"Banner with Placement Name:%@ didClick", placementName);
        }
    }
    
    - (void)heliumBannerAdDidRecordImpressionWithPlacementName:(NSString *)placementName
    {
        NSLog(@"Impression recorded");
    }