(EN) iOS AppWall, Native - adxcorp/ADXLibrary_Integration GitHub Wiki

AppWall Integration

Use App ID and Unit ID that were issued for AppWall as follows:

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [AppWallFactory init:@"<YOUR_APP_ID>" adUnitId:@"<YOUR_ADUNIT_ID>"];
    [AppWallFactory preloadAppWall];
}

- (IBAction)selectShowAd:(id)sender {
    [AppWallFactory showAppWall:self];
}

Native Ad Integration

1) Native Ad Custom View

Native Ad requires you to provide Icon Image, Title Text, CTA Button, Sponsored(AD) Tag, and Privacy Icon. Also, there must be no view that covers over ad content area. Finally, you are not allowed to change any text, image or touch actions related to the ad content.

YourNativeAdView.h

@interface YourNativeAdView : UIView <MPNativeAdRendering>
        
@property (strong, nonatomic) UILabel *titleLabel;
@property (strong, nonatomic) UILabel *mainTextLabel;
@property (strong, nonatomic) UILabel *callToActionLabel;
@property (strong, nonatomic) UIImageView *iconImageView;
@property (strong, nonatomic) UIImageView *mainImageView;
@property (strong, nonatomic) UIImageView *privacyInformationIconImageView;
        
@end

YourNativeAdView.m

@implementation YourNativeAdView
        
...
        
- (void)layoutSubviews
{
    [super layoutSubviews];
    // layout your views
}

- (UILabel *)nativeMainTextLabel
{
    return self.mainTextLabel;
}

- (UILabel *)nativeTitleTextLabel
{
    return self.titleLabel;
}

- (UILabel *)nativeCallToActionTextLabel
{
    return self.callToActionLabel;
}

- (UIImageView *)nativeIconImageView
{
    return self.iconImageView;
}

- (UIImageView *)nativeMainImageView
{
    return self.mainImageView;
}

- (UIImageView *)nativePrivacyInformationIconImageView
{
    return self.privacyInformationIconImageView;
}
        
@end

AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    MPMoPubConfiguration *sdkConfig = [[MPMoPubConfiguration alloc] initWithAdUnitIdForAppInitialization:<YOUR_ADUNIT_ID_HERE>];
    [[MoPub sharedInstance] initializeSdkWithConfiguration:sdkConfig
                                                completion:^{
                                                    [ADXGDPR.sharedInstance showADXConsent:^(ADXConsentState consentState, BOOL success) {
                                                        
                                                        [[NativeAdFactory sharedInstance] setRenderingViewClass:<YOUR_NATIVE_ADUNIT_ID_HERE>
                                                                                             renderingViewClass:[YourNativeAdView class]];
                                                    }];
                                                }];
    return YES;
}

2) Using a single view

MyViewController.m


- (void)viewDidLoad {
     [super viewDidLoad];
     // register renderingViewClass
     [NativeAdFactory sharedInstance] setRenderingViewClass:@"<YOUR_ADUNIT_ID_HERE>" renderingViewClass:[NativeAdView class](/adxcorp/ADXLibrary_Integration/wiki/NativeAdFactory-sharedInstance]-setRenderingViewClass:@"<YOUR_ADUNIT_ID_HERE>"-renderingViewClass:[NativeAdView-class);

}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    // native ad factory
    [[NativeAdFactory sharedInstance] addDelegate:self];
    [[NativeAdFactory sharedInstance] loadAd:@"<YOUR_ADUNIT_ID_HERE>"];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [[NativeAdFactory sharedInstance] removeDelegate:self];
}

#pragma mark - Native Ad Factory
- (void)onSuccess:(NSString *)adUnitId nativeAd:(MPNativeAd *)nativeAd {
    if([adUnitId isEqualToString:@"<YOUR_ADUNIT_ID_HERE>"]) {
        self.nativeAd = nativeAd;
        self.nativeAd.delegate = self;
            
        nativeAdView = [[NativeAdFactory sharedInstance] getNativeAdView:@"<YOUR_ADUNIT_ID_HERE>"];
        nativeAdView.frame = CGRectMake(0,
                                      280,
                                      [[UIScreen mainScreen].bounds.size.width,
                                      (126.f));
            
        [self.view addSubview:nativeAdView];
    }
}

- (void)onFailure:(NSString *)adUnitId {
        
}

3) Using Placer in TableView and CollectionView

When using Placer, Cell position changes. So make sure to use alternative methods by referring to MPTableViewAdPlacer header file in case of TableView, and MPCollectionViewAdPlacer header file in case of CollectionView.

  ex)
      setDelegate -> mp_setDelegate
      reloadData -> mp_reloadData

MyViewController.h

@interface CollectionNativeViewController : UIViewController<UICollectionViewDelegate, UICollectionViewDataSource>

@property (weak, nonatomic) IBOutlet UICollectionView *nativeCollectionView;

@end

MyViewController.m

@interface CollectionNativeViewController ()

@property (nonatomic, strong) MPCollectionViewAdPlacer *placer;

@end

...

- (void)viewDidLoad {
    [super viewDidLoad];

    ...
    // register renderingViewClass
    [NativeAdFactory sharedInstance] setRenderingViewClass:<YOUR_ADUNIT_ID_HERE> renderingViewClass:[NativeAdView class](/adxcorp/ADXLibrary_Integration/wiki/NativeAdFactory-sharedInstance]-setRenderingViewClass:<YOUR_ADUNIT_ID_HERE>-renderingViewClass:[NativeAdView-class);  
  
    self.placer = [[NativeAdFactory sharedInstance] getCollectionViewAdPlacer:@"<YOUR_ADUNIT_ID_HERE>"
                                                               collectionView:self.mainCollectionView
                                                               viewController:self
                                                              viewSizeHandler:^CGSize(CGFloat maximumWidth) {
                                                                  CGFloat width = [UIScreen mainScreen].bounds.size.width;
                                                                  return CGSizeMake(width, floor(width * 0.5225));
                                                              }];
	    
    [self.placer loadAdsForAdUnitID:@"<YOUR_ADUNIT_ID_HERE>"];
}