SplashVC.m
in DemoAppDelegate.m
and AdSDKManager.m
- Only some ad platforms support the setting of containerView.
- The extra dictionary in this step supports passing in relevant parameters for configuring ads and your custom parameters. You can view more information about extra parameters here.
//Import header file
#import <AnyThinkSplash/AnyThinkSplash.h>
@interface SplashVC () <ATSplashDelegate>
@end
@implementation SplashVC
//Ad placement ID
#define SplashPlacementID @"b67f4ab43d2fe1"
//Scene ID, optional, can be generated in the backend. Pass empty string if not available
#define SplashSceneID @""
#pragma mark - Load Ad
/// Load ad
- (void)loadAd {
NSMutableDictionary *loadConfigDict = [NSMutableDictionary dictionary];
//Splash timeout duration
[loadConfigDict setValue:@(8) forKey:kATSplashExtraTolerateTimeoutKey];
//Custom load parameters
[loadConfigDict setValue:@"media_val_SplashVC" forKey:kATAdLoadingExtraMediaExtraKey];
[[ATAdManager sharedManager] loadADWithPlacementID:SplashPlacementID
extra:loadConfigDict
delegate:self
containerView:[self footLogoView]];
}
/// Optional splash bottom LogoView integration
- (UIView *)footLogoView {
//Width is screen width, height <= 25% of screen height (depending on ad platform requirements)
UIView * footerCtrView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kOrientationScreenWidth, 120)];
footerCtrView.backgroundColor = UIColor.whiteColor;
//Add image
UIImageView * logoImageView = [UIImageView new];
logoImageView.image = [UIImage imageNamed:@"logo"];
logoImageView.contentMode = UIViewContentModeCenter;
logoImageView.frame = footerCtrView.frame;
[footerCtrView addSubview:logoImageView];
//Add click event
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(footerImgClick:)];
logoImageView.userInteractionEnabled = YES;
[logoImageView addGestureRecognizer:tap];
return footerCtrView;
}
/// Footer click event
- (void)footerImgClick:(UITapGestureRecognizer *)tap {
ATDemoLog(@"footer click !!");
}
/// Splash ad loading completed
/// - Parameters:
/// - placementID: Ad placement ID
/// - isTimeout: Whether timeout occurred
- (void)didFinishLoadingSplashADWithPlacementID:(NSString *)placementID isTimeout:(BOOL)isTimeout {
if (!isTimeout) {
//Loading successful, no timeout
}else {
//Loading successful, but timeout occurred
}
}
/// Ad placement loading failed
/// - Parameters:
/// - placementID: Ad placement ID
/// - error: Error information
- (void)didFailToLoadADWithPlacementID:(NSString*)placementID error:(NSError*)error {
}
/// Splash ad loading timeout
/// - Parameter placementID: Ad placement ID
- (void)didTimeoutLoadingSplashADWithPlacementID:(NSString *)placementID {
}
- If you need to show ads in the loading success callback (didFinishLoadingADWithPlacementID:), to avoid ads not displaying properly, please ensure: the current app UIApplicationState==UIApplicationStateActive
- If a container containerView was created and set during loading, it needs to be added to the layout and be in a visible state
- Statistics for scene reach rate, displayed in the backend's Data Reports -> Funnel Analysis Report -> Reach Ad Scene, call before showing ads
#pragma mark - Show Ad
- (void)showSplash {
//Scene statistics function, displayed in the backend's Data Reports -> Funnel Analysis Report -> Reach Ad Scene, call before showing ads. Optional integration
[[ATAdManager sharedManager] entrySplashScenarioWithPlacementID:SplashPlacementID scene:SplashSceneID];
//Check if ready
if (![[ATAdManager sharedManager] splashReadyForPlacementID:SplashPlacementID]) {
[self loadAd];
return;
}
//Show configuration, pass in backend scene ID for Scene, pass empty string if not available, showCustomExt parameter can pass custom parameter string
ATShowConfig *config = [[ATShowConfig alloc] initWithScene:SplashSceneID showCustomExt:@"testShowCustomExt"];
//Splash related parameter configuration
NSMutableDictionary *configDict = [NSMutableDictionary dictionary];
//Show ad, display in app's original window
[[ATAdManager sharedManager] showSplashWithPlacementID:SplashPlacementID config:config window:[UIApplication sharedApplication].keyWindow inViewController:self.tabBarController extra:configDict delegate:self];
}
/// Get display revenue
/// - Parameters:
/// - placementID: Ad placement ID
/// - extra: Extra information dictionary
- (void)didRevenueForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
}
/// Splash ad has been shown
/// - Parameters:
/// - placementID: Ad placement ID
/// - extra: Extra information
- (void)splashDidShowForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
}
/// Splash ad has been closed
/// - Parameters:
/// - placementID: Ad placement ID
/// - extra: Extra information
- (void)splashDidCloseForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
// Hot start preloading (optional)
// [self loadAd];
}
/// Splash ad has been clicked
/// - Parameters:
/// - placementID: Ad placement ID
/// - extra: Extra information
- (void)splashDidClickForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
}
/// Splash ad show failed
/// - Parameters:
/// - placementID: Ad placement ID
/// - error: Error information
/// - extra: Extra information
- (void)splashDidShowFailedForPlacementID:(NSString*)placementID error:(NSError *)error extra:(NSDictionary *)extra {
}
/// Splash ad has opened or jumped to deep link page
/// - Parameters:
/// - placementID: Ad placement ID
/// - extra: Extra information
/// - success: Whether successful
- (void)splashDeepLinkOrJumpForPlacementID:(NSString *)placementID extra:(NSDictionary *)extra result:(BOOL)success {
}
/// Splash ad detail page has been closed
/// - Parameters:
/// - placementID: Ad placement ID
/// - extra: Extra information
- (void)splashDetailDidClosedForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
}
/// Splash ad close countdown
/// - Parameters:
/// - countdown: Remaining seconds
/// - placementID: Ad placement ID
/// - extra: Extra information
- (void)splashCountdownTime:(NSInteger)countdown forPlacementID:(NSString *)placementID extra:(NSDictionary *)extra {
}
/// Splash ad zoomout view has been clicked, only supported by Pangle, Tencent GDT, V+
/// - Parameters:
/// - placementID: Ad placement ID
/// - extra: Extra information
- (void)splashZoomOutViewDidClickForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
}
/// Splash ad zoomout view has been closed, only supported by Pangle, Tencent GDT, V+
/// - Parameters:
/// - placementID: Ad placement ID
/// - extra: Extra information
- (void)splashZoomOutViewDidCloseForPlacementID:(NSString*)placementID extra:(NSDictionary *)extra {
}
First time during application installation To load open-screen ads, Taku needs to first pull the configured ad placement information from the background and cache it locally, and then request ads from the advertising platform. This process involves two network requests (serial), which affects the loading efficiency of open-screen ads.
Preset Strategy: Can improve the ad loading effect of the first cold start by configuring preset strategies.