Skip to main content

Splash

1. Methods that need to be rewritten

  • Developers need to inherit TradPlusBaseAdapter and rewrite related methods:
    • When developers call the loadAd API of TradPlusAdSplash, the loadAdWithWindow:bottomView: method of the custom Adapter will be called.
    • When developers call the isAdReady API of TradPlusAdSplash, the isReady method of the custom Adapter will be called
    • When developers call the show API of TradPlusAdSplash, the isReady and showAdInWindow:bottomView: methods of the custom Adapter will be called in sequence.
MethodParameter DescriptionReturn ValueFunction
- (void)loadAdWithWaterfallItem:(TradPlusAdWaterfallItem *)itemitem: Contains parameters sent by the server and locally configuredvoidUsed to obtain the parameters sent by the server and locally configured to implement the loading logic of custom ads
- (void)showAdInWindow:(UIWindow *)window bottomView:(UIView *)bottomViewwindow: UIWindow passed in when showing Ad
bottomView: UIView passed in when showing Ad
voidImplement the logic for displaying custom ads
- (BOOL)isReady-----BoolUsed to determine whether a custom ad is expired before displaying the ad

2.Callback method description

MethodDescription
- (void)AdConfigErrorAd configuration information is wrong
- (void)AdLoadFinshAd loading is complete
- (void)AdLoadFailWithError:(NSError *)errorAd loading fails
error: error message
- (void)AdShowAd is displayed
- (void)AdShowFailWithError:(NSError *)errorAd display fails
error: error message
- (void)AdClickAd is clicked
- (void)AdCloseAd is closed

3. Integration Instructions

  1. Create a custom class that you registered in the TradPlus background and inherit TradPlusBaseAdapter
#import <TradPlusAds/TradPlusBaseAdapter.h>
@interface ClassName : TradPlusBaseAdapter

@end
  1. Implement the initialization, loading and other logic of the custom platform in the loadAdWithWaterfallItem: method
  • Get the background configuration parameters through the TradPlusAdWaterfallItem class, item.config

  • Initialize a custom advertising platform, set the advertising platform parameters and overseas platform privacy settings (such as CCPA, COPPA, GDPR) according to your own needs.

  • Load the ad; after loading, call AdLoadFinsh or AdLoadFailWithError to notify whether the loading is successful or not

//example
- (void)loadAdWithWaterfallItem:(TradPlusAdWaterfallItem *)item
{
//Get background configuration information through item.config
NSString *placementId = item.config[@"placementId"];
if(placementId == nil)
{
//Configuration Error
[self AdConfigError]
return;
}
//Initialize third-party platforms, set parameters for advertising platforms, privacy settings for overseas platforms, etc.
GADRequest *request = [GADRequest request];
//Setting up GDPR
if (![MSConsentManager sharedManager].canCollectPersonalInfo)
{
GADExtras *extras = [[GADExtras alloc] init];
extras.additionalParameters = @{@"npa": @"1"};
[request registerAdNetworkExtras:extras];
}
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
__weak typeof(self) weakSelf = self;
[GADAppOpenAd loadWithAdUnitID:placementId request:request orientation:orientation completionHandler:^(GADAppOpenAd * _Nullable appOpenAd, NSError * _Nullable error) {
if(error == nil)
{
weakSelf.appOpenAd = appOpenAd;
//Loading Successfully
[weakSelf AdLoadFinsh];
}
else
{
//Loading failed
[weakSelf AdLoadFailWithError:error];
}
}];
}
  1. Implement the display of the custom platform in the showAdInWindow:bottomView: method
//example
//bottomView Some third-party platforms support adding custom views
- (void)showAdInWindow:(UIWindow *)window bottomView:(UIView *)bottomView
{
UIViewController *rootViewController = window.rootViewController;
NSError *error;
if(rootViewController != nil && [self.appOpenAd canPresentFromRootViewController:rootViewController error:&error])
{
self.appOpenAd.fullScreenContentDelegate = self;
//Call third-party API to display ads
[self.appOpenAd presentFromRootViewController:rootViewController];
}
else
{
//Display failure
[self AdShowFailWithError:error];
}
}
  1. Return whether the ad is expired in the isReady method
//example
- (BOOL)isReady
{
return (self.appOpenAd != nil);
}
  1. According to the API of each advertising platform, execute relevant methods to notify developers
//example
- (void)adDidRecordImpression:(nonnull id<GADFullScreenPresentingAd>)ad
{
//Ad display
[self AdShow];
}

- (void)adDidRecordClick:(nonnull id<GADFullScreenPresentingAd>)ad
{
//Ad click
[self AdClick];
}

- (void)ad:(nonnull id<GADFullScreenPresentingAd>)ad
didFailToPresentFullScreenContentWithError:(nonnull NSError *)error
{
//Display failure
[self AdShowFailWithError:error];
}


- (void)adDidDismissFullScreenContent:(nonnull id<GADFullScreenPresentingAd>)ad
{
//Ad Close
[self AdClose];
}

- (void)adDidPresentFullScreenContent:(nonnull id<GADFullScreenPresentingAd>)ad
{
}

- (void)adWillDismissFullScreenContent:(nonnull id<GADFullScreenPresentingAd>)ad
{
}

4.Others

Code Sample

How to obtain the overseas privacy permission setting parameters in TradPlusSDK

#import <TradPlusAds/MsCommon.h>
#import <TradPlusAds/MSConsentManager.h>
MethodDescription
[[NSUserDefaults standardUserDefaults] integerForKey:gTPCOPPAStorageKey]COPPA, Children's Online Privacy Protection Act
0=not set, 1=adult, 2=child
[[NSUserDefaults standardUserDefaults] integerForKey:gTPCCPAStorageKey]CCPA, California Consumer Privacy Act
0=not set, 1=do not report data, 2=report data
[MSConsentManager sharedManager].canCollectPersonalInfoGDPR, General Data Protection Regulation of the European Union (EU) and the European Economic Area (EEA)
yes=allow access to device data no=do not allow access to device data