Delegate Methods — iOS

Last Update:

 

 

 

The Chartboost SDK's delegate methods allow you to exercise a greater degree of control over your integration. For example, you can:

  • Log debug messages when your game attempts to load an interstitial.
  • Prevent ads from showing the first time a user plays your game.
  • Determine whether a user has clicked an ad or just closed it – and react accordingly.
  • Prevent an interstitial page appearing when and where it would interfere with your game.

You can view the Chartboost iOS SDK methods at your disposal in the Chartboost.h header file in the Chartboost framework. You can see many of these methods in use within the sample project included with your iOS SDK download.


▲ Back to top

 

Click here to view iOS SDK configuration methods.


▲ Back to top

 

Before using any delegate functions, set the Chartboost delegate with delegate:self in your Chartboost initialization code:

#import <Chartboost/Chartboost.h>
#import <Chartboost/CBNewsfeed.h>
#import "AppDelegate.h"

@interface AppDelegate ()
@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    [self initializeStoryBoardBasedOnScreenSize];

    // Begin a user session.
    // Must not be dependent on user actions or any prior network requests.
    [Chartboost startWithAppId:@"YOUR_CHARTBOOST_APP_ID"
                  appSignature:@"YOUR_CHARTBOOST_APP_SIGNATURE"
                      delegate:self];

    return YES;
}
      

▲ Back to top

 

// Called before requesting an interstitial via the Chartboost API server.
- (BOOL)shouldRequestInterstitial:(CBLocation)location;

// Called before an interstitial will be displayed on the screen.
- (BOOL)shouldDisplayInterstitial:(CBLocation)location;

// Called after an interstitial has been displayed on the screen.
- (void)didDisplayInterstitial:(CBLocation)location;

// Called after an interstitial has been loaded from the Chartboost API
// servers and cached locally.
- (void)didCacheInterstitial:(CBLocation)location;

// Called after an interstitial has attempted to load from the Chartboost API
// servers but failed.
 - (void)didFailToLoadInterstitial:(CBLocation)location
                         withError:(CBLoadError)error;

// Called after an interstitial has been dismissed.
- (void)didDismissInterstitial:(CBLocation)location;

// Called after an interstitial has been closed.
- (void)didCloseInterstitial:(CBLocation)location;

// Called after an interstitial has been clicked.
- (void)didClickInterstitial:(CBLocation)location;
    
Don't make cache or show calls inside didFailToLoad delegates or the universe will implode.

▲ Back to top

 

// Called after videos have been successfully prefetched.
- (void)didPrefetchVideos;

// Called before a rewarded video will be displayed on the screen.
- (BOOL)shouldDisplayRewardedVideo:(CBLocation)location;

// Called after a rewarded video has been displayed on the screen.
- (void)didDisplayRewardedVideo:(CBLocation)location;

// Called after a rewarded video has been loaded from the Chartboost API
// servers and cached locally.
- (void)didCacheRewardedVideo:(CBLocation)location;

// Called after a rewarded video has attempted to load from the Chartboost API
// servers but failed.
- (void)didFailToLoadRewardedVideo:(CBLocation)location
                         withError:(CBLoadError)error;

// Called after a rewarded video has been dismissed.
- (void)didDismissRewardedVideo:(CBLocation)location;

// Called after a rewarded video has been closed.
- (void)didCloseRewardedVideo:(CBLocation)location;

// Called after a rewarded video has been clicked.
- (void)didClickRewardedVideo:(CBLocation)location;

// Called after a rewarded video has been viewed completely and user is eligible for reward.
- (void)didCompleteRewardedVideo:(CBLocation)location
                      withReward:(int)reward;

// Implement to be notified of when a video will be displayed on the screen for
// a given CBLocation. You can then do things like mute effects and sounds.
- (void)willDisplayVideo:(CBLocation)location;
Don't make cache or show calls inside didFailToLoad delegates or the universe will implode.

▲ Back to top

 

// Called after the App Store sheet is dismissed, when displaying the embedded app sheet.
- (void)didCompleteAppStoreSheetFlow;

// Called after a click is registered, but the user is not forwarded to the App Store.
- (void)didFailToRecordClick:(CBLocation)location
                   withError:(CBClickError)error;

//Called after the SDK has been successfully initialized and video prefetching has been completed
- (void)didInitialize:(BOOL)status;
Don't make cache or show calls inside didFailToLoad delegates or the universe will implode.

▲ Back to top

 

// Called after a Native Ad object has been loaded from the Chartboost API
// servers and cached locally.
- (void)didCacheInPlay:(CBLocation)location;

// Called after a Native Ad has attempted to load from the Chartboost API
// servers but failed.
- (void)didFailToLoadInPlay:(CBLocation)location
                  withError:(CBLoadError)error;
Don't make cache or show calls inside didFailToLoad delegates or the universe will implode.

▲ Back to top

 

// Decide if Chartboost SDK should block for an age gate.
+ (void)setShouldPauseClickForConfirmation:(BOOL)shouldPause;

// Called if Chartboost SDK pauses click actions awaiting confirmation from the user. Use
// to implement an age gate in your game.
- (void)didPauseClickForConfirmation;

// Confirm if an age gate passed or failed. When specified Chartboost will wait for
// this call before showing the IOS App Store.
+ (void)didPassAgeGate:(BOOL)pass;
Don't make cache or show calls inside didFailToLoad delegates or the universe will implode.

▲ Back to top