「NativeAd」修訂間的差異

出自TAMedia
跳至導覽 跳至搜尋
imported>Wikiuser
imported>Wikiuser
(取消由Wikiuser對話)所作出的修訂 1430)
 
(未顯示同一使用者於中間所作的 9 次修訂)
行 1: 行 1:
[[IOS SDK Developer Guide v2|回iOS首頁]]<br>
請依照  開始使用Getting Started 章節進行SDK 的安裝
請依照  開始使用Getting Started 章節進行SDK 的安裝
並以下述的方式啟動原生性廣告服務
並以下述的方式啟動原生性廣告服務
行 4: 行 5:
// NADViewController.h
// NADViewController.h
// 匯入 TAMedia SDK 定義
// 匯入 TAMedia SDK 定義
#import "TADNativeAd.h"
#import <TAMediaAdsFramework/TAMediaAdsFramework.h>
@interface NADViewController: UIViewController <TADNativeAdDelegate>
@interface NADViewController: UIViewController <TADNativeAdDelegate>
{
{
行 29: 行 30:
[self.view addSubview:fireButton1];
[self.view addSubview:fireButton1];
}
}
</source>
請求廣告
<source lang="object-c" collapse="false" title="Native Ad">
- (void)requestAd1
- (void)requestAd1
{
{
行 38: 行 42:
// Set location
// Set location
[request setLocationWithLatitude:[_LATITUDE_] longitude:[_LONGITUDE_] accuracy:[_ACCURACY_]];
[request setLocationWithLatitude:[_LATITUDE_] longitude:[_LONGITUDE_] accuracy:[_ACCURACY_]];
</source>
<source lang="object-c" collapse="false" title="Native Ad">
// NAD 物件初始化, 帶入自訂的origin
// NAD 物件初始化, 帶入自訂的origin
if (!nativeAd) {
if (!nativeAd) {
行 50: 行 51:
[nativeAd loadRequest:request];
[nativeAd loadRequest:request];
}
}
</source>
收到廣告廣告,開發商可依照APP最恰當的方式來將取得的廣告內容佈局在APP的呈現上,點擊時可使用下敘兩種方式開啟廣告<br/>
1.使用[nativeAd handleClick];<br/>
2.使用[UIApplication sharedApplication] openURL:"開啟dictionary中的nurl"]<br/>
<source lang="object-c" collapse="false" title="Native Ad">
- (void)nativeAdDidReceiveAd:(TADNativeAd *)ad {
- (void)nativeAdDidReceiveAd:(TADNativeAd *)ad {
// 表示本次請求收到廣告, 藉由 getNativeAdContent 取得包含回覆內容的 NSDictionary
// 表示本次請求收到廣告, 藉由 getNativeAdContent 取得包含回覆內容的 NSDictionary
NSDictionary *dicNad = [nativeAd getNativeAdContent];
NSDictionary *dicNad = [nativeAd getNativeAdContent];
/*利用拿到的Dictionary依所需要的方式呈現廣告
  當user點擊廣告時提供兩種方式開啟廣告
  1.使用[nativeAd handleClick];
  2.使用[UIApplication sharedApplication] openURL:"開啟dictionary中的nurl"]
*/
}
</source>
<b>原生性廣告內容</b>
前述之getNativeAdContent 所取回的NSDictionary 詳細內容如後
<source lang="object-c" collapse="false" title="Native Ad">
{
"LONGSUBJECT": "長標題 long subject ,※預設值為空字串",
"SHORTSUBJECT": "短標題 short subject ,※預設值為空字串",
"BODY": "內文 body ,※預設值為空字串",
"ICONSQUARE": "小圖示 方 icon square ,※預設值為空字串",
"ICONRECTANGLE": "小圖示 長 icon rectangle,※預設值為空字串",
"VIDEO": "影片 video,※預設值為空字串",
"IMAGE1280X720": "大圖 1280x720,※預設值為空字串",
"IMAGE960X640": "大圖 960x640,※預設值為空字串",
"IMAGE1200X627": "大圖 1200x627,※預設值為空字串"
"nurl": "廣告檔次Target URL", //當廣告發生點擊時回報的url
}
}
</source>
</source>
行 79: 行 107:
- (void)nativeAd:(TADNativeAd *)ad didFailToReceiveAdWithError:(TADRequestError *)error;
- (void)nativeAd:(TADNativeAd *)ad didFailToReceiveAdWithError:(TADRequestError *)error;
@end
@end
</source>
<b>原生性廣告內容</b>
前述之getNativeAdContent 所取回的NSDictionary 詳細內容如後
<source lang="object-c" collapse="false" title="Native Ad">
{
"LONGSUBJECT": "長標題 long subject ", //表長標題文字, 最長30 個字
"SHORTSUBJECT": "短標題 short subject", // 短標題, 最長4 個字
"BODY": "內文 body",// 內文,提供最長70 個文字
"ICONSQUARE": "小圖示 方 icon square",//提供64x64(px)的圖檔url
"ICONRECTANGLE": "小圖示 長 icon rectangle",//提供96x64(px)的圖檔url
"VIDEO": "影片 video", // 影片內容的url
"IMAGE1280X720": "大圖 1280x720",// 提供1280x720(px)的圖檔url
"IMAGE720X1280": "大圖 720x1280",// 提供˙720x1280(px)的圖檔url
"IMAGE960X640": "大圖 960x640", // 提供960x640(px)的圖檔url
"IMAGE640X960": "大圖 640x960", // 提供640x960(px)的圖檔url
"nurl": "廣告檔次Target URL", //當廣告發生點擊時回報的url
}
</source>
</source>


行 105: 行 115:
| align="center" | 限制條件
| align="center" | 限制條件
| align="center" | 條列式
| align="center" | 條列式
| align="center" | 圖片式 (直9:16)
| align="center" | 圖片式 (橫 16:9)
| align="center" | 圖片式 (橫 16:9)
| align="center" | 圖片式 (直2:3)
| align="center" | 圖片式 (橫 3:2)
| align="center" | 圖片式 (橫 3:2)
| align="center" | 小圖式
| align="center" | 小圖式
行 113: 行 121:
|-
|-
| align="center" | 長標題<br/>(LONGSUBJECT)
| align="center" | 長標題<br/>(LONGSUBJECT)
| align="center" | 30字內
| align="center" | 25字內
| align="center" | V
| align="center" | V
| align="center" | V
| align="center" | V
| align="center" | V
| align="center" | V
行 123: 行 129:
|-
|-
| align="center" | 短標題<br/>(SHORTSUBJECT)
| align="center" | 短標題<br/>(SHORTSUBJECT)
| align="center" | 4字內
| align="center" | 10字內
| align="center" |
| align="center" | V
| align="center" | V
| align="center" | V
| align="center" | V
| align="center" | V
行 134: 行 138:
| align="center" | 內文<br/>(BODY)
| align="center" | 內文<br/>(BODY)
| align="center" | 70字內
| align="center" | 70字內
| align="center" | V
| align="center" | V
| align="center" | V
| align="center" | V
| align="center" | V
| align="center" | V
行 143: 行 145:
|-
|-
| align="center" | 小圖 (方)<br/>(ICONSQUARE)
| align="center" | 小圖 (方)<br/>(ICONSQUARE)
| align="center" | 64x64<br/>jpg/png
| align="center" | 120x120<br/>jpg/png
| align="center" | V
| align="center" | V
| align="center" |
| align="center" |
| align="center" |  
| align="center" |  
| align="center" |  
| align="center" |  
行 155: 行 155:
| align="center" | 96x64<br/>jpg/png
| align="center" | 96x64<br/>jpg/png
| align="center" | V
| align="center" | V
| align="center" |
| align="center" |
| align="center" |  
| align="center" |  
| align="center" |  
| align="center" |  
行 164: 行 162:
| align="center" | 影片<br/>(VIDEO)
| align="center" | 影片<br/>(VIDEO)
| align="center" | 96x64<br/>MP4, 10mb
| align="center" | 96x64<br/>MP4, 10mb
| align="center" |
| align="center" |
| align="center" |  
| align="center" |  
| align="center" |  
| align="center" |  
行 171: 行 167:
| align="center" |  
| align="center" |  
| align="center" | V
| align="center" | V
|-
| align="center" | 大圖 (直 9:16)<br/>(IMAGE720X1280)
| align="center" | 720x1280<br/>jpg/png
| align="center" |
| align="center" | V
| align="center" |
| align="center" |
| align="center" |
| align="center" |
| align="center" |
|-
|-
| align="center" | 大圖 (橫 16:9)<br/>(IMAGE1280X720)
| align="center" | 大圖 (橫 16:9)<br/>(IMAGE1280X720)
| align="center" | 1280x720<br/>jpg/png
| align="center" | 1280x720<br/>jpg/png
| align="center" |
| align="center" |  
| align="center" |  
| align="center" | V
| align="center" | V
| align="center" |
| align="center" |  
| align="center" |  
| align="center" |  
| align="center" |  
| align="center" |
| align="center" |
|-
|-
| align="center" | 大圖 (橫 2:3)<br/>(IMAGE640X960)
| align="center" | 大圖 (橫 3:2)<br/>(IMAGE960X640)
| align="center" | 640x960<br/>jpg/png
| align="center" | 960x640<br/>jpg/png
| align="center" |  
| align="center" |  
| align="center" |  
| align="center" |  
| align="center" | V
| align="center" |  
| align="center" |  
| align="center" | V
| align="center" | V
| align="center" |
| align="center" |
| align="center" |
|-
|-
| align="center" | 大圖 (橫 3:2)<br/>(IMAGE960X640)
| align="center" | 大圖<br/>(IMAGE1200X627)
| align="center" | 960x640<br/>jpg/png
| align="center" | 1200x627<br/>jpg/png
| align="center" |  
| align="center" | V
| align="center" |  
| align="center" | V
| align="center" |  
| align="center" | V
| align="center" |
| align="center" | V
| align="center" | V
| align="center" |
| align="center" | V
| align="center" | V
|}
|}

於 2021年8月3日 (二) 08:46 的最新修訂

回iOS首頁
請依照 開始使用Getting Started 章節進行SDK 的安裝 並以下述的方式啟動原生性廣告服務

// NADViewController.h
// 匯入 TAMedia SDK 定義
 #import <TAMediaAdsFramework/TAMediaAdsFramework.h>
@interface NADViewController: UIViewController <TADNativeAdDelegate>
{
// 以 instant variable 的方式, 宣告 TADNatvieAd 物件
TADNativeAd * nativeAd;
}
@end
// NADViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor whiteColor];
self.title = @"TAMedia NAD";
UIButton *fireButton1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
fireButton1.frame = CGRectMake(10, 120, 200, 40);
fireButton1.backgroundColor = [UIColor colorWithRed:239/255.0 green:239/255.0 blue:239/255.0 alpha:1.0];
[fireButton1 setTitle:@"Native Ad" forState:UIControlStateNormal];
[fireButton1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[fireButton1 addTarget:self action:@selector(requestAd1) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:fireButton1];
}

請求廣告

- (void)requestAd1
{
TADRequest *request = [TADRequest request];
// Type: TADGender
request.gender = [_GENDER_];
// Set birthday
[request setBirthdayWithYear:[_YEAR_] month:[_MONTH_] day:[_DAY_]];
// Set location
[request setLocationWithLatitude:[_LATITUDE_] longitude:[_LONGITUDE_] accuracy:[_ACCURACY_]];
// NAD 物件初始化, 帶入自訂的origin
if (!nativeAd) {
nativeAd = [[TADNativeAd alloc] initWithAdUnitId: [_YOUR_AD_UNIT_ID_]];
}
// 必須要設定delegate
nativeAd.delegate = self;
// 載入廣告
[nativeAd loadRequest:request];
}

收到廣告廣告,開發商可依照APP最恰當的方式來將取得的廣告內容佈局在APP的呈現上,點擊時可使用下敘兩種方式開啟廣告
1.使用[nativeAd handleClick];
2.使用[UIApplication sharedApplication] openURL:"開啟dictionary中的nurl"]

- (void)nativeAdDidReceiveAd:(TADNativeAd *)ad {
// 表示本次請求收到廣告, 藉由 getNativeAdContent 取得包含回覆內容的 NSDictionary
NSDictionary *dicNad = [nativeAd getNativeAdContent];
/*利用拿到的Dictionary依所需要的方式呈現廣告
  當user點擊廣告時提供兩種方式開啟廣告
  1.使用[nativeAd handleClick];
  2.使用[UIApplication sharedApplication] openURL:"開啟dictionary中的nurl"]
*/
}

原生性廣告內容 前述之getNativeAdContent 所取回的NSDictionary 詳細內容如後

{
"LONGSUBJECT": "長標題 long subject ,※預設值為空字串",
"SHORTSUBJECT": "短標題 short subject ,※預設值為空字串",
"BODY": "內文 body ,※預設值為空字串",
"ICONSQUARE": "小圖示 方 icon square ,※預設值為空字串",
"ICONRECTANGLE": "小圖示 長 icon rectangle,※預設值為空字串",
"VIDEO": "影片 video,※預設值為空字串",
"IMAGE1280X720": "大圖 1280x720,※預設值為空字串",
"IMAGE960X640": "大圖 960x640,※預設值為空字串",
"IMAGE1200X627": "大圖 1200x627,※預設值為空字串"
"nurl": "廣告檔次Target URL", //當廣告發生點擊時回報的url
}

特別注意, 在 ViewController 的 view 即將消失前, 必須要將 nativeAd 本身以及其 delegate 設定為 nil

// NADViewController.m
- (void)viewWillDisappear:(BOOL)animated {
// viewController 的 view 消失前, 必須將 nativeAd 及其 delegate 設為 nil
 if (nativeAd!= nil) {
 nativeAd.delegate = nil;
 nativeAd = nil;
 }
}

TADNativeAdDelegate

@protocol TADNativeAdDelegate <NSObject>
@optional
//廣告載入成功後被呼叫, 在這裏利用 [nativeAd getNativeAdContent] 取得回覆的 dictionary
- (void)nativeAdDidReceiveAd:(TADNativeAd *)ad;
//廣告載入失敗後被呼叫
- (void)nativeAd:(TADNativeAd *)ad didFailToReceiveAdWithError:(TADRequestError *)error;
@end

※重要, 下表所描述的廣告素材有可能因廣告主未提供素材, 而以空字串提供, 使用上請特別留意

素材 \ 版位 限制條件 條列式 圖片式 (橫 16:9) 圖片式 (橫 3:2) 小圖式 影音式
長標題
(LONGSUBJECT)
25字內 V V V V
短標題
(SHORTSUBJECT)
10字內 V V V V
內文
(BODY)
70字內 V V V V
小圖 (方)
(ICONSQUARE)
120x120
jpg/png
V V V
小圖 (長)
(ICONRECTANGLE)
96x64
jpg/png
V V
影片
(VIDEO)
96x64
MP4, 10mb
V
大圖 (橫 16:9)
(IMAGE1280X720)
1280x720
jpg/png
V
大圖 (橫 3:2)
(IMAGE960X640)
960x640
jpg/png
V V
大圖
(IMAGE1200X627)
1200x627
jpg/png
V V V V V