次の方法で共有


iOS の広告応答情報クラス

この記事では、iOS Mobile SDK の広告応答情報クラスについて説明します。

ANAdResponseInfo クラスは、パブリッシャーに関連するユニバーサル タグ応答プロパティを保持するために作成された読み取り専用のパブリック利便性クラスです。 AdUnitメソッドからloadAd、完全に定義adObjectされた応答または入札なしの応答としてエラーなしで が返されると、ANAdResponseInfo返された広告ユニットのプロパティとして adResponseInfo がインスタンス化されます。

広告応答から adResponseInfo オブジェクトを取得するには、次のプロパティを使用します。

@property (nonatomic, readwrite, strong, nullable) ANAdResponseInfo *adResponseInfo;

プロパティ

プロパティ 説明
contentSource String Xandr contentSource。 contentSource には、RTB、CSM、または SSM を指定できます。
creativeId String 応答に関連付けられているクリエイティブの一意識別子。
memberID 整数 応答に関連付けられているメンバーの一意識別子。
networkName String 応答に関連付けられているネットワークの名前。
placementId String 応答に関連付けられている配置タグの一意の識別子。
auctionId String 現在の入札に対して生成される一意の識別子。
cpm NSNumber 現在のオークションの入札価格は、1 ミルあたりのコスト、または 1000 (ラテン語では mille = 千) で表されます。 広告主が広告を配信した 1,000 インプレッションごとに料金を支払う価格モデル。 これは、オンライン広告の標準的な基本価格モデルです。
cpmPublisherCurrency NSNumber 発行元の通貨で表される cpm。
publisherCurrencyCode NSString 発行元の通貨の通貨コード。 たとえば、米国ドル

コード サンプル (Objective C)

- (void)requestBannerAd
{
  // Make a banner ad view.
  self.banner = [ANBannerAdView adViewWithFrame:CGRectMake(0, 0, 300, 250) placementId:@“1” adSize:CGSizeMake(300,250)];
  self.banner.delegate = self;
  //... Add required configurations
  [self.banner loadAd];
}
// On Ad Loaded
- (void)adDidReceiveAd:(id)ad {
  NSLog(@“Ad did receive ad”);
  NSString* bannerCreativeId = self.banner.adResponseInfo.creativeId;
  NSString* bannerPlacementId = self.banner.adResponseInfo.placementId;
  NSString* bannerAuctionId = self.banner.adResponseInfo.auctionId;
  NSNumber* bannerCPM = self.banner.adResponseInfo.cpm;
  NSNumber* bannerCPMPublisherCurrency = self.banner.adResponseInfo.cpmPublisherCurrency;
  NSString* bannerPublisherCurrencyCode = self.banner.adResponseInfo.publisherCurrencyCode;
}

コード サンプル (Swift)

func requestBannerAd() {
       // Make a banner ad view.
       self.banner = ANBannerAdView(frame: CGRect(origin: CGPoint(x: 0,y :0), size: CGSize(width: 300, height: 250)), placementId: “1”, adSize: CGSize(width: 300, height: 250))
       self.banner!.rootViewController = self
       self.banner!.delegate = self
       //... Add required configurations
       self.banner!.loadAd()
   }
  // On Ad Loaded
   func adDidReceiveAd(_ ad: Any) {
       print(“Ad did receive ad”)
       let bannerCreativeId : String = (self.banner?.adResponseInfo?.creativeId)!
       let bannerPlacementId : String = (self.banner?.adResponseInfo?.placementId)!
       let bannerAuctionId : String = (self.banner?.adResponseInfo?.auctionId)!
       let bannerCPM = (self.banner?.adResponseInfo?.cpm)!
       let bannerCPMPublisherCurrency = (self.banner?.adResponseInfo?.cpmPublisherCurrency)!
       let bannerPublisherCurrencyCode = (self.banner?.adResponseInfo?.publisherCurrencyCode)!
}

注:

AdResponseInfo は、VideoAd インスタンス、スポット広告ビュー インスタンス、ネイティブ広告応答を使用して、バナー広告ビューとは別に取得できます。

コード サンプル (Objective C)

// For interstitialAd once adDidReceiveAd is callback
  NSString* interstitialAdCreativeId = self.interstitialAd.adResponseInfo.creativeId; // same will be followed to get other adResponseInfo from interstitialAd
 // For videoAd once adDidReceiveAd is callback
  NSString* videoAdCreativeId = self.videoAd.adResponseInfo.creativeId; // same will be followed to get other adResponseInfo from videoAd
 // For nativeAd once didReceiveResponse is callback
  ANAdResponseInfo nativeAdResponseInfo = nativeAdResponse;
   NSString* nativeAdCreativeId = nativeAdResponseInfo.creativeId; // same will be followed to get other adResponseInfo from videoAd

コード サンプル (Swift)

// For interstitialAd once adDidReceiveAd is callback
  let interstitialAdCreativeId : String = (self.interstitialAd.?.adResponseInfo?.creativeId)! // same will be followed to get other adResponseInfo from interstitialAd
 // For videoAd once adDidReceiveAd is callback
  let videoAdCreativeId : String = (self.videoAd.?.adResponseInfo?.creativeId)!  // same will be followed to get other adResponseInfo from videoAd
 // For nativeAd once didReceiveResponse is callback
  let nativeAdCreativeId : String = (self.nativeAdResponse.?.adResponseInfo?.creativeId)!  // same will be followed to get other adResponseInfo from nativeAd