tenmax-native-ad-mobile-sdk-ios 1.0.9

tenmax-native-ad-mobile-sdk-ios 1.0.9

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2016年11月

tenmaxOpsliq维护。



  • 作者:
  • liq6

先决条件

  • iOS 部署目标至少 8.0 以上
  • 从 tenmax 获取一个唯一的广告识别码

步骤 2.import Oyster

在包含广告的类中导入 Oyster

#import <Oyster/Oyster.h>

步骤 3.init Oyster SDK

在 AppDelegate 中增加以下代码

#import <Oyster/Oyster.h>

@implementation AppDelegate
- (BOOL) application:(UIApplication*) application didFinishLaunchingWithOptions:(NSDictionary*) launchOptions {
  // Override point for customization after application launch.

  [Oyster initInstance];
  return YES;
}
@end

添加一个 Native Ad

步骤 1.添加以下代码

  OysterAdLoaderOptions* options = [[OysterAdLoaderOptions alloc] init];
  options.imageSize = MIDDLE;

  self.adLoader = [[OysterAdLoader alloc]
      initWithAdUnitID:@"AD_UNIT_ID" rootViewController:rootViewController adTypes:@[kOysterAdLoaderAdTypeContent] options:options];

  self.adLoader.delegate = self;
  [self.adLoader loadRequest];

步骤 2.实现 OysterContentAdLoaderDelegate

@interface YourController<OysterContentAdLoaderDelegate>
@end

@implementation YourController 

// 失敗回傳
- (void) adLoader:(OysterAdLoader*) adLoader didFailToReceiveAdWithError:(NSError*) error;

// 成功回傳
- (void) adLoader:(OysterAdLoader*) adLoader didReceiveNativeContentAd:(OysterContentAd*) oysterContentAd;

@end

步骤 3.制作 adView

首先生成.xib 文件,点击 Utilities 出现在 Xcode 右侧边栏,选择左边数来第三项的 identity inspector 如下图

AdView of Step 1

确定 Custom Class 有继承 OysterContentAdView。

接着即可生成5个 IBOutlet,如下图。

AdView of Step 2

分别为 UILabel的 headerlineView作为广告的标题,UIImageView的imageView作为广告的内图,UILabel的bodyView作为广告的内文,UILabel的advertiserView作为广告的赞助商名称,UIImageView的logoView作为广告的 logo。

步骤 4.Coding 放入广告内容

在制作好 xib 布局之后,在要执行的 ViewController 部分实现以下部分

- (void) adLoader:(OysterAdLoader*) adLoader didReceiveNativeContentAd:(OysterContentAd*) oysterContentAd {

   OysterContentAdView* oysterContentAdView = [[[NSBundle mainBundle]
      loadNibNamed:@"NativeContentAdView" owner:nil options:nil]
      firstObject];
  [self setAdView:oysterContentAdView];

  oysterContentAdView.oysterContentAd = oysterContentAd;

  ((UILabel*) oysterContentAdView.headlineView).text = oysterContentAd.headline;
  ((UILabel*) oysterContentAdView.bodyView).text = oysterContentAd.headline;
  ((UILabel*) oysterContentAdView.advertiserView).text = oysterContentAd.advertiser;
  ((UIImageView*) oysterContentAdView.imageView).image = oysterContentAd.adImage.image;
  ((UIImageView*) oysterContentAdView.logoView).image = oysterContentAd.adLogo.image;
  [((UIButton*) oysterContentAdView.callToAction) setTitle:oysterContentAd.callToAction forState:UIControlStateNormal];


}

添加一个 Banner Ad

步骤 1.storyboard 添加 OysterAdView

AdView of Step 2

  • 手机高度 -> 50
  • ipad 高度 -> 90

步骤 2.添加以下代码

- (void) viewDidLoad {
  [super viewDidLoad];
  self.oysterAdView.adUnitID = @"c145f1cd389e49a5";
  self.oysterAdView.rootViewController = self;

  [self.oysterAdView loadAds];
}

版本

1.0.8