iOS のクリックスルー URL
クリックスルーという用語は、ユーザーが広告をクリックしたときに何が起こるかを処理する Mobile SDK の機能を指します。 このドキュメントでは、クリックスルーのしくみについて説明し、iOS 用にこの機能を実装する方法の例を示します。
Xandr の Mobile SDK を使用すると、ユーザーが広告をクリックしたときに入札応答の文字列の click_url
値がどのように処理されるかを決定できます。
次の 3 つの可能性があります。
- SDK ブラウザーでクリックスルー URL を開きます。
- 外部デバイス ブラウザーでクリックスルー URL を開きます。
- ブラウザーを開かずに、呼び出し元の環境に URL を返します。
ブラウザーを開くケースは、Android と iOS でを介して onAdClicked
呼び出し adWasClicked:withURL:
元に通知します。
ネイティブ広告リクエストの場合:
と の 2 つの URL が返されます
click_url
click_url_fallback
。呼び出し元は、その内容をユーザーに表示することで、クリックスルー URL を適切に処理することを前提としています。 が
click_url_fallback
定義されている場合は、何らかの理由でブラウザー表示システムによって解決できない場合click_url
にのみ使用されます。リスナー/デリゲート コールバック メソッドは、
onAdWasClicked(clickUrl, fallbackURL)
Android 用、adWasClickedWithURL:fallbackURL:
iOS 用です。
Mobile SDK の構造
- バナー、スポット、ビデオの場合、ANAdProtocol はデリゲート メソッド
adWasClicked:withURL:
を定義します。 - Native の場合、ANNativeAdDelegate はデリゲート メソッド
adWasClickedWithURL:fallbackURL:
を定義します。
例
ClickURL をフェッチしない場合は、 を返すclickURL
メソッドadWasClicked:withURL:
を実装する必要はありません。
ClickURL をフェッチする場合は、次のコード例を使用して開始できます。
// Enable RETURN_URL API
adObject.clickThroughAction = ANClickThroughActionReturnURL;
次に を追加 adWasClicked:withURL:
して を取得します urlString
。
// iOS: ObjC to show a banner ad
#import "MyViewController.h"
#import "ANBannerAdView.h"
@interface MyViewController ()
@property (nonatomic, strong) ANBannerAdView *banner;
@end
@implementation MyViewController
ANBannerAdView *banner = nil;
- (void) viewDidLoad
{
CGSize size = CGSizeMake(300, 250); // NOTE Setting size is necessary only for fetching banner and video ad objects.
// This field is ignored when the placement returns a native ad object.
CGRect someRect = CGRectMake(...);
// Create the banner ad view here, but wait until the delegate fires before displaying.
//
ANBannerAdView *banner = [ANBannerAdView adViewWithFrame:someRect placementId:@"13572468" adSize:size];
banner.rootViewController = self;
banner.clickThroughAction = ANClickThroughActionReturnURL;
// Load an ad!
[banner loadAd];
}
// Display all multi-format ads in success method from ANMultiFormatAdDelegate.
//
- (void) adDidReceiveAd:(id)adObject
{
[self.view addSubview:banner];
}
// optional method
- (void)adWasClicked:(id)ad withURL:(NSString *)urlString{
// the caller can handle it appropriately, displaying its content to the user.
}
@end