iOS AppWall, Native - adxcorp/ADXLibrary_Integration GitHub Wiki

AppWall Integration

AppWall 용으로 발급드린 App ID와 Unit ID를 사용하여 아래와 같이 구현해주시면 됩니다.

- (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 광고의 필수 구성 요소로는 Icon Image, Title Text, CTA Button, Sponsored(AD) Tag, Privacy Icon 이 있습니다. 이 요소들은 반드시 포함하여 구성하여 주시고, 광고 컨텐츠를 덮는 View 가 없어야 합니다. 또한 텍스트 변경, 이미지 변경, 터치시 액션 변경 등 광고 컨텐츠에 관련된 부분을 가공하거나 변경하지 않도록 주의 부탁드립니다.

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) 하나의 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) TableView, CollectionView에서 Placer를 사용하시는 경우

Placer를 사용하시는 경우 Cell의 position 정보가 달라지기 때문에, TableView는 MPTableViewAdPlacer, CollectionView는 MPCollectionViewAdPlacer의 header 파일을 참고하시어 대체 method를 사용해주시기 바랍니다.

  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>"];
}