Native - Atmosplay/AtmosplayAds-iOS Wiki

Access Native Ad (Templates)

Native Templates is a rendering mode of native ad. In this mode, ad will be rendered automatically. This approach simplifies the process of accessing native ad, and you can access native ad more convient since you do not need to deal with ad rendering related issues.

Initialize nativeExpressAd

  1. Import header files in your own ViewController. For example:
#import <AtmosplayAds/AtmosplayNativeExpressAd.h>

@interface NativeTemplatesAdViewController () <AtmosplayNativeExpressAdDelegate>
@property (nonatomic) AtmosplayNativeExpressAd *nativeExpressAd;

@end
  1. Initialize nativeExpressAd, get ad, and set callback.
CGFloat width = [UIScreen mainScreen].bounds.size.width;
// adSize (size of adUnit) is set by you,SDK will return an adview which suits for the adSize
self.nativeExpressAd = [[AtmosplayNativeExpressAd alloc] initWithAppID:@"Your_App_ID" 
                                                              adUnitID:@"Your_AdUnitID" 
                                                                adSize:CGSizeMake(width, 300)];
self.nativeExpressAd.delegate = self;

Load Native Ad

[self.nativeExpressAd loadAd];

Render and Display

You need to check callback state in AtmosplayNativeExpressAd. If the state is successful, a PANativeExpressAdView type object will be returned. You can call addSubview: method to display ads in proper place.

When you display ads, you need to call reportImpressionNativeExpressAd method to notify Atmosplay Ads that ad has been displayed.

Implementing AtmosplayNativeExpressAd events

/// Tells the delegate that an ad has been successfully loaded.
- (void)atmosplayNativeExpressAdDidLoad:(PANativeExpressAdView *)nativeExpressAd {
}
/// Tells the delegate that a request failed.
- (void)atmosplayNativeExpressAdDidFailWithError:(NSError *)error {
}
/// Tells the delegate that the Native view has been clicked.
- (void)atmosplayNativeExpressAdDidClick:(PANativeExpressAdView *)nativeExpressAd {
}

Access Native Ad (Self Rendering)

Self rendering is another rendering mode, which has high flexibility of native ad. You can splice ad style according to your needs to make ad more suitable for your app.

Initialize nativeAd

  1. Import header files in your own ViewController. For example:
#import <AtmosplayAds/AtmosplayNative.h>

@interface NativeAdViewController () <AtmosplayNativeDelegate>
@property (nonatomic) AtmosplayNative *nativeAd;

@end
  1. Initialize nativeAd, get ad, and set callback.
self.nativeAd = [[AtmosplayNative alloc] initWithAppID:@"Your_AppIDs" adUnitID:@"Your_AdUnitID"];
self.nativeAd.delegate = self;

Load Native Ad

[self.nativeAd loadAd];

Render and Display

You need to check callback state in AtmosplayNative. If the state is successful, a AtmosplayNativeAdModel type object will be returned. Then you need to render ad in proper time and display the ad.

Attention:
- When the ad has been rendered and displayed, you need to notify Atmosplay Ads by calling reportImpression:view: method.
- Call registerViewForInteraction: nativeAd: method to binding AtmosplayNative and UIView (view you used to display native ad). Please make view.userInteractionEnabled = YES;

Implementing AtmosplayNative events

/// Tells the delegate that an ad has been successfully loaded.
- (void)atmosplayNativeAdDidLoad:(AtmosplayNativeAdModel *)nativeAd {
}
/// Tells the delegate that a request failed.
- (void)atmosplayNativeAdDidFailWithError:(NSError *)error {
}
/// Tells the delegate that the Native view has been clicked.
- (void)atmosplayNativeAdDidClick:(AtmosplayNativeAdModel *)nativeAd {
}