Splash
1. Methods that need to be rewritten
- Developers need to inherit TradPlusBaseAdapter and rewrite related methods:
- When developers call the
loadAdAPI ofTradPlusAdSplash, theloadAdWithWindow:bottomView:method of the custom Adapter will be called. - When developers call the
isAdReadyAPI ofTradPlusAdSplash, theisReadymethod of the custom Adapter will be called - When developers call the
showAPI ofTradPlusAdSplash, theisReadyandshowAdInWindow:bottomView:methods of the custom Adapter will be called in sequence.
- When developers call the
| Method | Parameter Description | Return Value | Function |
|---|---|---|---|
| - (void)loadAdWithWaterfallItem:(TradPlusAdWaterfallItem *)item | item: Contains parameters sent by the server and locally configured | void | Used 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 *)bottomView | window: UIWindow passed in when showing Ad bottomView: UIView passed in when showing Ad | void | Implement the logic for displaying custom ads |
| - (BOOL)isReady | ----- | Bool | Used to determine whether a custom ad is expired before displaying the ad |
2.Callback method description
| Method | Description |
|---|---|
| - (void)AdConfigError | Ad configuration information is wrong |
| - (void)AdLoadFinsh | Ad loading is complete |
| - (void)AdLoadFailWithError:(NSError *)error | Ad loading fails error: error message |
| - (void)AdShow | Ad is displayed |
| - (void)AdShowFailWithError:(NSError *)error | Ad display fails error: error message |
| - (void)AdClick | Ad is clicked |
| - (void)AdClose | Ad is closed |
3. Integration Instructions
- Create a custom class that you registered in the TradPlus background and inherit TradPlusBaseAdapter
#import <TradPlusAds/TradPlusBaseAdapter.h>
@interface ClassName : TradPlusBaseAdapter
@end
- Implement the initialization, loading and other logic of the custom platform in the
loadAdWithWaterfallItem:method
-
Get the background configuration parameters through the
TradPlusAdWaterfallItemclass,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
AdLoadFinshorAdLoadFailWithErrorto 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];
}
}];
}
- 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];
}
}
- Return whether the ad is expired in the
isReadymethod
//example
- (BOOL)isReady
{
return (self.appOpenAd != nil);
}
- 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
How to obtain the overseas privacy permission setting parameters in TradPlusSDK
#import <TradPlusAds/MsCommon.h>
#import <TradPlusAds/MSConsentManager.h>
| Method | Description |
|---|---|
| [[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].canCollectPersonalInfo | GDPR, 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 |